Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add GH workflow to build app & deploy to GH Pages; Update demo link to point at GH Pages deployment. #114

Merged
merged 22 commits into from
Nov 10, 2024

Conversation

junhaoliao
Copy link
Member

@junhaoliao junhaoliao commented Nov 9, 2024

References

Resolves #102 (comment)

Description

  1. Add workflow to build the application and deploy to GitHub pages.
  2. Update demo link in README.md to refer to the deployment.

Validation performed

On @junhaoliao 's fork:

  1. Observed the GitHub workflow completed without error: https://github.com/junhaoliao/yscope-log-viewer/actions/runs/11752079920
  2. Accessed the application at https://junhaoliao.github.io/yscope-log-viewer/ which was successful.

Summary by CodeRabbit

  • New Features

    • Updated the online demo URL for the log viewer to ensure users access the correct location.
    • Introduced a new GitHub Actions workflow for automated deployment to GitHub Pages.
  • Documentation

    • Revised the README.md to reflect the updated online demo link.

Copy link

coderabbitai bot commented Nov 9, 2024

Walkthrough

The pull request includes updates to the README.md file, specifically changing the URL for the online demo of the log viewer to a new location. Additionally, it introduces a new GitHub Actions workflow file named deploy-gh-pages.yaml, which automates the deployment process of the project to GitHub Pages upon updates to the main branch. The workflow consists of two jobs: one for building the project and another for deploying it.

Changes

File Change Summary
README.md Updated online demo URL from https://yscope.com/log-viewer to https://y-scope.github.io/yscope-log-viewer/.
.github/workflows/deploy-gh-pages.yaml Added a new GitHub Actions workflow for automated deployment to GitHub Pages on main branch updates.

Assessment against linked issues

Objective Addressed Explanation
Update deployment at demo link once the new log viewer is released (#102)

Possibly related PRs

Suggested reviewers

  • kirkrodrigues

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ba82b3a and 8bccb9a.

📒 Files selected for processing (1)
  • .github/workflows/deploy-gh-pages.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/deploy-gh-pages.yaml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@junhaoliao junhaoliao changed the title Add workflow to build the application and deploy to GitHub pages. gh-actions: Add workflow to build the application and deploy to GitHub Pages; Update demo link in README.md to refer to the deployment. Nov 9, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
.github/workflows/deploy-gh-pages.yml (1)

29-29: Remove trailing space in npm install command.

Apply this diff:

- run: "npm install "
+ run: "npm install"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2d38f38 and df4a275.

📒 Files selected for processing (2)
  • .github/workflows/deploy-gh-pages.yml (1 hunks)
  • README.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md
🧰 Additional context used
🪛 actionlint
.github/workflows/deploy-gh-pages.yml

20-20: shellcheck reported issue in this script: SC2016:info:1:6: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)


20-20: shellcheck reported issue in this script: SC2086:info:1:39: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/deploy-gh-pages.yml (3)

1-6: LGTM! Workflow trigger configuration is appropriate.

The workflow is correctly configured to run only on pushes to the main branch, which is the standard practice for GitHub Pages deployments.


37-51: LGTM! Deploy job configuration follows best practices.

The deployment configuration is well-structured with:

  • Appropriate permission scoping for Pages and ID token
  • Correct job dependencies
  • Proper environment configuration

32-35: Verify build output and deployment artifacts.

Let's ensure the build process generates the expected files in the dist directory.

✅ Verification successful

Let me gather more information about the webpack configuration and build process.


Let me check the webpack configuration to verify the build output settings.


Build configuration and deployment path are properly configured

The verification confirms that:

  • Webpack is correctly configured to output build files to ./dist directory
  • The build process includes proper bundling of assets, styles, and scripts
  • Production build configuration is set up with appropriate optimizations
  • HTML template and static assets are properly handled
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify build configuration and output directory
# Test 1: Check if build script is defined in package.json
echo "Checking build script configuration:"
jq '.scripts.build' package.json

# Test 2: Check if dist directory is specified in .gitignore
echo -e "\nVerifying .gitignore configuration:"
rg "^dist/?$" .gitignore

# Test 3: Look for any existing build configuration files
echo -e "\nChecking for build configuration files:"
fd -e config.js -e config.ts -e vite.config.js -e webpack.config.js

Length of output: 429


Script:

#!/bin/bash
# Check webpack configuration files and dist directory structure
echo "Checking for webpack config files:"
fd webpack

echo -e "\nChecking package.json dependencies for webpack:"
jq '.dependencies + .devDependencies | with_entries(select(.key | contains("webpack")))' package.json

echo -e "\nChecking for any existing dist directory structure:"
fd -t d dist

echo -e "\nChecking for HTML entry points:"
fd -e html

Length of output: 925


Script:

#!/bin/bash
# Check webpack production configuration
echo "Checking webpack.prod.js configuration:"
cat webpack.prod.js

echo -e "\nChecking webpack.common.js configuration:"
cat webpack.common.js

echo -e "\nChecking index.html template:"
cat public/index.html

Length of output: 6365

Comment on lines 14 to 16
- uses: "actions/setup-node@v4"
with:
node-version: "22"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider using a stable Node.js version.

Node.js 22 is currently in pre-release status. For production deployments, it's recommended to use the current LTS version (20.x).

Apply this diff:

- node-version: "22"
+ node-version: "20"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: "actions/setup-node@v4"
with:
node-version: "22"
- uses: "actions/setup-node@v4"
with:
node-version: "20"

Comment on lines 18 to 20
- name: "Get npm cache directory"
id: "get-npm-cache-dir"
run: "echo 'dir=$(npm config get cache)' >> ${GITHUB_OUTPUT}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix shell script quoting issues.

The echo command should use double quotes to allow variable expansion and prevent word splitting.

Apply this diff:

- run: "echo 'dir=$(npm config get cache)' >> ${GITHUB_OUTPUT}"
+ run: "echo \"dir=$(npm config get cache)\" >> \"${GITHUB_OUTPUT}\""
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: "Get npm cache directory"
id: "get-npm-cache-dir"
run: "echo 'dir=$(npm config get cache)' >> ${GITHUB_OUTPUT}"
- name: "Get npm cache directory"
id: "get-npm-cache-dir"
run: "echo \"dir=$(npm config get cache)\" >> \"${GITHUB_OUTPUT}\""
🧰 Tools
🪛 actionlint

20-20: shellcheck reported issue in this script: SC2016:info:1:6: Expressions don't expand in single quotes, use double quotes for that

(shellcheck)


20-20: shellcheck reported issue in this script: SC2086:info:1:39: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/deploy-gh-pages.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-gh-pages.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-gh-pages.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-gh-pages.yml Outdated Show resolved Hide resolved
.github/workflows/deploy-gh-pages.yml Outdated Show resolved Hide resolved
kirkrodrigues
kirkrodrigues previously approved these changes Nov 9, 2024
Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the PR title, how about:

ci: Add GH workflow to build app & deploy to GH pages; Update demo link to point at GH pages deployment.

build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4"
Copy link
Member Author

@junhaoliao junhaoliao Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add

        with:
          submodules: "recursive"

here or remove it in ?

with:
submodules: "recursive"

Copy link
Member

@kirkrodrigues kirkrodrigues Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would either add it here or leave both as is. Although we don't need it in lint.yaml currently, hopefully we'll add yscope-dev-utils to this repo soon in service of adding more automated linting. So in that case, changing lint.yaml would be unnecessary; I'm not sure whether we would need to change deploy-gh-pages.yml at that point.

Speaking of, I just noticed that we should rename this workflow file with .yaml.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
.github/workflows/deploy-gh-pages.yaml (2)

21-23: Enhance build step reliability and performance.

Add error handling and caching for build outputs:

-     - run: "npm install"
+     - name: "Install dependencies"
+       run: "npm ci"
+       if: steps.npm-cache.outputs.cache-hit != 'true'
 
-     - run: "npm run build"
+     - name: "Build application"
+       run: "npm run build"
+       id: build
+       continue-on-error: false

30-45: Enhance deployment reliability with timeouts and verification.

Add timeout and post-deployment verification:

  deploy:
    needs: "build"
+   timeout-minutes: 10
    permissions:
      pages: "write"
      id-token: "write"
    runs-on: "ubuntu-latest"
    environment:
      name: "github-pages"
      url: "${{steps.deployment.outputs.page_url}}"
    steps:
      - name: "Deploy to GitHub Pages"
        id: "deployment"
        uses: "actions/deploy-pages@v4"
+     - name: "Verify deployment"
+       run: |
+         # Wait for DNS propagation
+         sleep 30
+         # Verify deployment is accessible
+         curl --retry 3 --retry-delay 5 -sSf "${{steps.deployment.outputs.page_url}}" > /dev/null
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a0ab914 and 37911e7.

📒 Files selected for processing (1)
  • .github/workflows/deploy-gh-pages.yaml (1 hunks)

Comment on lines +15 to +18
- uses: "actions/setup-node@v4"
with:
node-version: "22"
cache: "npm"
Copy link

@coderabbitai coderabbitai bot Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use LTS version of Node.js for production deployments.

Node.js v22 is currently in beta. For production deployments, use an LTS version:

      - uses: "actions/setup-node@v4"
        with:
-         node-version: "22"
+         node-version: "20"
          cache: "npm"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- uses: "actions/setup-node@v4"
with:
node-version: "22"
cache: "npm"
- uses: "actions/setup-node@v4"
with:
node-version: "20"
cache: "npm"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of "22" is intended.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junhaoliao, understood. I've noted that using Node.js version 22 is intended for this project.

(꒦_꒦)


✏️ Learnings added
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#114
File: .github/workflows/deploy-gh-pages.yaml:24-27
Timestamp: 2024-11-09T21:02:27.209Z
Learning: In the yscope-log-viewer project, specifically in the `.github/workflows/deploy-gh-pages.yaml` file, Node.js version 22 is intentionally used in GitHub Actions workflows.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines +1 to +6
name: "deploy-github-pages"

on:
push:
branches: ["main"]

Copy link

@coderabbitai coderabbitai bot Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add workflow concurrency control to prevent deployment conflicts.

To prevent race conditions when multiple workflow runs are triggered, add concurrency control:

name: "deploy-github-pages"

on:
  push:
    branches: ["main"]

+concurrency:
+  group: "pages"
+  cancel-in-progress: true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: "deploy-github-pages"
on:
push:
branches: ["main"]
name: "deploy-github-pages"
on:
push:
branches: ["main"]
concurrency:
group: "pages"
cancel-in-progress: true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a fix in commit ba82b3a, please review it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junhaoliao, thank you for adding the concurrency control to the workflow. This should effectively prevent deployment conflicts. The fix looks good.


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

@junhaoliao junhaoliao changed the title gh-actions: Add workflow to build the application and deploy to GitHub Pages; Update demo link in README.md to refer to the deployment. ci: Add GH workflow to build app & deploy to GH pages; Update demo link to point at GH pages deployment. Nov 9, 2024
@junhaoliao junhaoliao changed the title ci: Add GH workflow to build app & deploy to GH pages; Update demo link to point at GH pages deployment. ci: Add GH workflow to build app & deploy to GH Pages; Update demo link to point at GH Pages deployment. Nov 9, 2024
Comment on lines 7 to 9
permissions:
# So the workflow can cancel in-progress jobs
actions: "write"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my mistake in previous workflow PRs, but I found that this permission is not necessary for cancelling in-progress jobs. I think we should set these permissions to {} instead.

.github/workflows/deploy-gh-pages.yaml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new-log-viewer: Update deployment at demo link once the new log viewer is released.
2 participants