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 reactions to /update-vrt comment #3789

Merged
merged 6 commits into from
Nov 6, 2024

Conversation

UnderKoen
Copy link
Member

No description provided.

@actual-github-bot actual-github-bot bot changed the title ci: add reactions to /update-vrt comment [WIP] ci: add reactions to /update-vrt comment Nov 4, 2024
Copy link

netlify bot commented Nov 4, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit d23fe86
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/672a1b4f577c4e0008c032db
😎 Deploy Preview https://deploy-preview-3789.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
10 5.34 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/AppliedFilters.js 21.3 kB 0%
static/js/narrow.js 82.57 kB 0%
static/js/wide.js 239.81 kB 0%
static/js/ReportRouter.js 1.5 MB 0%
static/js/index.js 3.35 MB 0%

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.27 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.27 MB 0%

@UnderKoen UnderKoen changed the title [WIP] ci: add reactions to /update-vrt comment ci: add reactions to /update-vrt comment Nov 4, 2024
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The pull request introduces several modifications to the GitHub Actions workflow configuration in the file .github/workflows/update-vrt.yml. Key changes include a reduction in permissions for pull requests and contents, changing from write to read. The concurrency group name has been updated to check for the presence of the string '/update-vrt' in the comment body, affecting concurrent execution management. Two new jobs, add-starting-reaction and push-patch, have been added, both conditioned to run when the event is a pull request and the comment body contains '/update-vrt'. The add-starting-reaction job executes to react with a "+1" emoji, while the push-patch job, which runs after the update-vrt job completes, is responsible for applying a patch and pushing changes back to the pull request. The update-vrt job has been modified to create a patch file instead of committing and pushing changes directly, with additional steps for resetting the git state, adding modified PNG files, and uploading the created patch as an artifact.

Possibly related PRs

  • ci: /update-vrt #3764: Introduces the update-vrt.yml workflow, which is directly related to the changes made in the main PR that modifies the same workflow file.
  • fix: /update-vrt on forks #3773: Updates the update-vrt job within the same workflow file, indicating a direct connection to the modifications made in the main PR.
  • fix: /update-vrt #3787: Modifies the update-vrt.yml workflow, specifically in the "Commit and push changes" step, which aligns with the overall focus of the main PR on the same workflow file.

Suggested labels

::sparkles: Merged

Suggested reviewers

  • joel-jeremy
  • youngcw

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.

Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (2)
.github/workflows/update-vrt.yml (2)

11-11: Simplify concurrency group name.

The command check in the concurrency group name is redundant since the jobs already have if conditions checking for /update-vrt. The group name can be simplified to just use the workflow and PR number.

-  group: ${{ github.workflow }}-${{ github.event.issue.number }}-${{ contains(github.event.comment.body, '/update-vrt') }}
+  group: ${{ github.workflow }}-${{ github.event.issue.number }}

51-79: Consider reducing duplication in reaction jobs.

Both reaction jobs share similar configuration. Consider using a reusable workflow or composite action to reduce duplication.

Example approach using a reusable workflow:

# .github/workflows/add-reaction.yml
name: 'Add Reaction'
on:
  workflow_call:
    inputs:
      reaction:
        required: true
        type: string
    secrets:
      token:
        required: true
jobs:
  add-reaction:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: dkershner6/reaction-action@v2
        with:
          token: ${{ secrets.token }}
          commentId: ${{ github.event.comment.id }}
          reaction: ${{ inputs.reaction }}

Then update the current workflow:

  add-starting-reaction:
-    runs-on: ubuntu-latest
    if: |
      github.event.issue.pull_request &&
      contains(github.event.comment.body, '/update-vrt')
-    permissions:
-      contents: write
-    steps:
-      - name: React to comment
-        uses: dkershner6/reaction-action@v2
-        with:
-          token: ${{ secrets.GITHUB_TOKEN }}
-          commentId: ${{ github.event.comment.id }}
-          reaction: "+1"
+    uses: ./.github/workflows/add-reaction.yml
+    with:
+      reaction: "+1"
+    secrets:
+      token: ${{ secrets.GITHUB_TOKEN }}

  add-finished-reaction:
-    runs-on: ubuntu-latest
    needs: update-vrt
    if: |
      github.event.issue.pull_request &&
      contains(github.event.comment.body, '/update-vrt')
-    permissions:
-      contents: write
-    steps:
-      - name: React to comment
-        uses: dkershner6/reaction-action@v2
-        with:
-          token: ${{ secrets.GITHUB_TOKEN }}
-          commentId: ${{ github.event.comment.id }}
-          reaction: "rocket"
+    uses: ./.github/workflows/add-reaction.yml
+    with:
+      reaction: "rocket"
+    secrets:
+      token: ${{ secrets.GITHUB_TOKEN }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 19c6f85 and 263694d.

📒 Files selected for processing (1)
  • .github/workflows/update-vrt.yml (2 hunks)
🔇 Additional comments (1)
.github/workflows/update-vrt.yml (1)

51-64: LGTM! Good addition of progress feedback.

The starting reaction provides clear feedback that the command was recognized and execution has begun.

.github/workflows/update-vrt.yml Show resolved Hide resolved
Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (1)
.github/workflows/update-vrt.yml (1)

56-84: Consider optimizing reaction jobs

While the implementation is functional, there's some code duplication between the two reaction jobs. Consider these improvements:

  1. Create a reusable workflow or composite action for adding reactions
  2. Combine both jobs into one with multiple reaction steps

Example of a combined job approach:

add-reactions:
  runs-on: ubuntu-latest
  needs: update-vrt
  if: |
    github.event.issue.pull_request &&
    contains(github.event.comment.body, '/update-vrt')
  permissions:
    contents: write
  steps:
    - name: Add starting reaction
      uses: dkershner6/reaction-action@v2
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        commentId: ${{ github.event.comment.id }}
        reaction: "+1"
    - name: Add finished reaction
      if: success()
      uses: dkershner6/reaction-action@v2
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        commentId: ${{ github.event.comment.id }}
        reaction: "rocket"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 263694d and 0616c6e.

📒 Files selected for processing (1)
  • .github/workflows/update-vrt.yml (2 hunks)
🔇 Additional comments (1)
.github/workflows/update-vrt.yml (1)

11-11: LGTM! Improved concurrency handling

The updated concurrency group name provides better isolation by considering the comment content. This ensures that only relevant workflow runs are grouped together.

Copy link
Contributor

@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: 1

🧹 Outside diff range and nitpick comments (1)
.github/workflows/update-vrt.yml (1)

Line range hint 59-90: Consider improving error handling in push-patch job

While the implementation is generally good, consider these improvements:

  1. The continue-on-error on artifact download could silently fail
  2. The patch application doesn't verify if the patch exists first

Consider this more robust implementation:

      - uses: actions/download-artifact@v4
-       continue-on-error: true
        with:
          name: patch
      - name: Apply patch and push
        run: |
+         if [ ! -f Update-VRT.patch ]; then
+           echo "No patch file found. Skipping."
+           exit 0
+         fi
          git apply Update-VRT.patch
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0616c6e and a44a2f0.

📒 Files selected for processing (1)
  • .github/workflows/update-vrt.yml (3 hunks)
🔇 Additional comments (4)
.github/workflows/update-vrt.yml (4)

11-11: LGTM: Improved concurrency control

The concurrency group name now includes the comment body check, which prevents unnecessary concurrent runs when comments don't contain '/update-vrt'.


44-57: LGTM: Improved change management using patches

The modification to create and upload patches instead of direct commits is a good architectural improvement:

  • Separates the concerns of generating and applying changes
  • Makes the process more transparent and reviewable
  • Handles the case of no changes gracefully

90-95: LGTM: Good user feedback with reactions

Adding a rocket reaction upon completion provides good visual feedback to users.


97-110: LGTM: Well-structured feedback mechanism

The add-starting-reaction job is well implemented:

  • Correct permission scoping
  • Matching conditions with the main job
  • Provides immediate feedback to users

.github/workflows/update-vrt.yml Show resolved Hide resolved
matt-fidd
matt-fidd previously approved these changes Nov 5, 2024
Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Contributor

@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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a44a2f0 and d23fe86.

📒 Files selected for processing (1)
  • .github/workflows/update-vrt.yml (3 hunks)
🧰 Additional context used
📓 Learnings (1)
.github/workflows/update-vrt.yml (1)
Learnt from: UnderKoen
PR: actualbudget/actual#3789
File: .github/workflows/update-vrt.yml:7-8
Timestamp: 2024-11-05T12:55:47.018Z
Learning: In the `.github/workflows/update-vrt.yml` file, the `update-vrt` job does not require `contents: write` permission; `contents: read` is sufficient because it does not push commits. Write permissions are only needed in the `push-patch` job.
🔇 Additional comments (4)
.github/workflows/update-vrt.yml (4)

7-8: LGTM! Well-considered permission and concurrency updates.

The changes demonstrate good security practices:

  • Reduced permissions align with the principle of least privilege
  • Concurrency group modification prevents unnecessary workflow cancellations

Also applies to: 11-11


44-57: LGTM! Robust patch creation process.

The new patch-based approach is more secure and reliable:

  • Separates change detection from applying changes
  • Includes proper checks for actual changes
  • Uses artifacts for safe transfer between jobs

98-111: LGTM! Good user feedback implementation.

The reaction job provides immediate feedback to users and has correctly scoped permissions.


74-77: Verify error handling for artifact download.

The continue-on-error: true on the artifact download could mask important failures. Consider handling the error explicitly if the patch doesn't exist.

✅ Verification successful

Let me gather more context about how the patch artifact is used to better understand the error handling requirements.


Let me try a different approach to understand the workflow context.


The continue-on-error usage is appropriate here

The error handling for the artifact download is properly implemented in this workflow:

  1. The update-vrt job creates a patch only when there are actual VRT changes (checks git diff --staged --quiet)
  2. The push-patch job has proper error handling after the download:
    • If no patch exists (download fails), the subsequent git apply will fail safely
    • The commit and push steps check git diff --staged --quiet again to ensure there are changes
    • The workflow provides user feedback via GitHub reactions regardless of the outcome

The continue-on-error is actually desirable here as it allows the workflow to handle the "no changes needed" case gracefully.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are other error handling mechanisms in place
rg -A 3 'continue-on-error|if.*exists|test.*-f' .github/workflows/update-vrt.yml

Length of output: 185


Script:

#!/bin/bash
# Check the full workflow context around the artifact download and usage
rg -B 5 -A 10 'download-artifact.*patch' .github/workflows/update-vrt.yml

Length of output: 75


Script:

#!/bin/bash
# Get the full content of the workflow file to understand the context
cat .github/workflows/update-vrt.yml

Length of output: 3865

.github/workflows/update-vrt.yml Show resolved Hide resolved
@UnderKoen UnderKoen merged commit c3b9588 into master Nov 6, 2024
19 of 20 checks passed
@UnderKoen UnderKoen deleted the UnderKoen/ci/update-vrt-reactions branch November 6, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants