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

Fix: CI - Hard Reset at changeset versioning #118 #119

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

black7375
Copy link
Contributor

@black7375 black7375 commented Oct 1, 2024

Description

  1. Create changeset-release/main branch with PR_SHA
  2. Perform a hard reset when versioning.

Related Issue

Summary by CodeRabbit

  • New Features

    • Enhanced PR merging checks with a retry mechanism.
    • Introduced a new step to identify versioning PRs based on changeset files.
  • Improvements

    • Added output variable to capture PR commit SHA.
    • Improved error handling for better workflow stability.

Additional context

Even if this PR is merged, you cannot be sure that it will be fixed, so you should not close it.

Checklist

Copy link

changeset-bot bot commented Oct 1, 2024

⚠️ No Changeset found

Latest commit: d5e2ba2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Oct 1, 2024

Walkthrough

The pull request introduces enhancements to the GitHub Actions workflow defined in .github/workflows/fast-forward.yml. It adds an output variable for the pull request's head commit SHA, implements a retry mechanism for checking if a pull request has been merged, and introduces a step to identify versioning pull requests that create a branch based on the presence of specific Markdown files. Additionally, error handling has been improved for better robustness.

Changes

File Change Summary
.github/workflows/fast-forward.yml - Added output variable pr_sha in the fast-forward job.
- Introduced step Is versioning PR in the release job to check for Markdown files in .changeset.
- Modified Create Release Pull Request or Publish to npm to reset git state before versioning.
- Improved error handling in "Show log on failure" step.

Possibly related PRs

🐇 In the meadow, changes bloom,
A workflow brightens, banishing gloom.
With checks and branches, all in line,
The code now dances, oh so fine!
Versioning whispers, a new dawn's light,
Hopping forward, everything's right! 🌼


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.

@black7375 black7375 added the bug Something isn't working label Oct 1, 2024
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Triggered from #119 by @​black7375.

Checking if we can fast forward main (3b26c19) to versioning-pr (a622db0).

Target branch (main):

commit 3b26c193de8b4a5e4acd651f4d82cf706e01d35b (HEAD -> main, tag: @mincho-js/transform-to-vanilla@0.0.3, tag: @mincho-js/css@0.0.4, origin/main, origin/HEAD)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Mon Sep 30 19:42:10 2024 +0900

    Chore: Version Packages

Pull request (versioning-pr):

commit a622db098de896208b38b097783448a1287e698c (pull_request/versioning-pr)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Tue Oct 1 16:13:57 2024 +0900

    Fix: CI - Hard Reset at changeset versioning #118

It is possible to fast forward main (3b26c19) to versioning-pr (a622db0). If you have write access to the target repository, you can add a comment with /fast-forward to fast forward main to versioning-pr.

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

🧹 Outside diff range and nitpick comments (3)
.github/workflows/fast-forward.yml (3)

Line range hint 59-99: Excellent addition of PR merge check with retry mechanism

The implementation of check_pr_merged function with a retry mechanism is a great improvement. It ensures that the workflow doesn't fail due to potential delays in PR merging. The code is well-structured and includes proper error handling.

One minor suggestion for improvement:

Consider extracting the max_attempts and sleep_duration as variables at the beginning of the script. This would make it easier to adjust these values in the future if needed. For example:

MAX_ATTEMPTS=30
SLEEP_DURATION=1

# ... rest of the script

Line range hint 152-158: Improved error handling in log display

The adjustment to the "Show log on failure" step is a good improvement. By adding || exit to the cd command, you ensure that the script exits gracefully if it can't access the log directory. This prevents potential issues with trying to read logs from an incorrect location.

One minor suggestion for further improvement:

Consider adding an error message when the directory change fails. This will make it clearer what went wrong if the step fails. Here's an example:

      - name: Show log on failure
        if: failure()
        run: |
          cd /home/runner/.npm/_logs/ || { echo "Failed to change to log directory"; exit 1; }
          for file in *; do
            echo "=== File: $file ==="
            cat "$file"
            echo -e "\n\n"
          done

This change will provide more context in case of a failure, making it easier to diagnose issues.


127-127: Minor: Quote variables to prevent word splitting

To address the static analysis hint and improve script safety:

Consider quoting the $md_files variable to prevent potential word splitting issues. While it's likely safe in the current context, it's a good shell scripting practice. Here's the suggested change:

-          if [ -n "$md_files" ]; then
+          if [ -n "${md_files}" ]; then

This change ensures that the variable is treated as a single entity, preventing any potential issues with word splitting or globbing.

🧰 Tools
🪛 actionlint

127-127: shellcheck reported issue in this script: SC2086:info:4:35: Double quote to prevent globbing and word splitting

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3b26c19 and a622db0.

📒 Files selected for processing (1)
  • .github/workflows/fast-forward.yml (4 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/fast-forward.yml

127-127: shellcheck reported issue in this script: SC2086:info:4:35: Double quote to prevent globbing and word splitting

(shellcheck)


134-134: property "pr_sha" is not defined in object type {should_run: string}

(expression)

🔇 Additional comments (2)
.github/workflows/fast-forward.yml (2)

136-142: Effective implementation of hard reset before versioning

The modification to the version command in the "Create Release Pull Request or Publish to npm" step is well-implemented. By resetting to the changeset-release/main branch before running the versioning command, you ensure that the versioning process is based on the most recent and accurate state of the codebase.

This change aligns perfectly with the PR objectives of implementing a hard reset during the versioning process. It should effectively address the issues mentioned in the related issue #118.


Line range hint 1-158: Overall: Excellent improvements to the workflow

This pull request introduces several valuable enhancements to the "fast-forward and release" workflow:

  1. The addition of a retry mechanism for checking PR merge status improves reliability.
  2. The new "Is versioning PR" step effectively manages the versioning process.
  3. The implementation of a hard reset before versioning ensures accuracy.
  4. Error handling has been improved throughout the workflow.

These changes align well with the PR objectives and should effectively address the issues mentioned in #118. The code quality is high, and the modifications are well-thought-out.

A few minor suggestions have been made to further improve the code, but these are not critical. Great work on enhancing this workflow!

🧰 Tools
🪛 actionlint

124-124: description is required in metadata of "Setup" action at "/cache/34/d5746033-993b-42a9-becb-d6907f600eac/home/jailuser/git/.github/actions/node-setup/action.yml"

(action)


127-127: shellcheck reported issue in this script: SC2086:info:4:35: Double quote to prevent globbing and word splitting

(shellcheck)


134-134: property "pr_sha" is not defined in object type {should_run: string}

(expression)

.github/workflows/fast-forward.yml Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Triggered from #119 by @​black7375.

Checking if we can fast forward main (3b26c19) to versioning-pr (d5e2ba2).

Target branch (main):

commit 3b26c193de8b4a5e4acd651f4d82cf706e01d35b (HEAD -> main, tag: @mincho-js/transform-to-vanilla@0.0.3, tag: @mincho-js/css@0.0.4, origin/main, origin/HEAD)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Mon Sep 30 19:42:10 2024 +0900

    Chore: Version Packages

Pull request (versioning-pr):

commit d5e2ba2028355f39deb4990d9312faf1d2ea3eda (pull_request/versioning-pr)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Tue Oct 1 16:34:08 2024 +0900

    Fix: CI - Hard Reset at changeset versioning #118

It is possible to fast forward main (3b26c19) to versioning-pr (d5e2ba2). If you have write access to the target repository, you can add a comment with /fast-forward to fast forward main to versioning-pr.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a622db0 and d5e2ba2.

📒 Files selected for processing (1)
  • .github/workflows/fast-forward.yml (5 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/fast-forward.yml

128-128: shellcheck reported issue in this script: SC2086:info:4:35: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (4)
.github/workflows/fast-forward.yml (4)

19-20: LGTM: New output for PR SHA

The addition of the pr_sha output to the fast-forward job is a good improvement. It allows the SHA of the pull request to be passed to subsequent jobs, which can be useful for various operations, such as the new versioning step added later in this workflow.


Line range hint 60-97: Excellent addition: Robust PR merge check

The new check_pr_merged function is a great improvement to the workflow. It implements a retry mechanism that checks the merge status of a PR up to 30 times with a 1-second delay between attempts. This approach effectively addresses potential race conditions in the CI process and improves the overall reliability of the workflow.

Key benefits:

  1. Increased resilience against temporary API issues or delays in merge status updates.
  2. Improved handling of fast-forward scenarios where the merge might not be immediately reflected.
  3. Clear error handling if the maximum number of attempts is reached.

This change demonstrates thoughtful consideration of real-world CI challenges.


98-100: LGTM: Storing PR SHA for later use

This change correctly retrieves the HEAD SHA of the merged PR and stores it as an output variable. This is a crucial step that enables the new versioning process introduced later in the workflow. The implementation is straightforward and effective.


143-143: LGTM: Improved versioning process

The modification to the version command in the "Create Release Pull Request or Publish to npm" step is an excellent improvement. By performing a hard reset to the changeset-release/main branch before running the versioning command, this change ensures that:

  1. The versioning process always starts from a clean, known state.
  2. Any potential conflicts or inconsistencies from previous runs are eliminated.
  3. The versioning accurately reflects the most recent state of the codebase.

This change directly addresses the PR objective of implementing a hard reset during versioning, which should lead to more reliable and consistent release processes.

.github/workflows/fast-forward.yml Show resolved Hide resolved
@black7375
Copy link
Contributor Author

/fast-forward

Copy link
Contributor

github-actions bot commented Oct 1, 2024

Triggered from #119 (comment) by @​black7375.

Trying to fast forward main (3b26c19) to versioning-pr (d5e2ba2).

Target branch (main):

commit 3b26c193de8b4a5e4acd651f4d82cf706e01d35b (HEAD -> main, tag: @mincho-js/transform-to-vanilla@0.0.3, tag: @mincho-js/css@0.0.4, origin/main, origin/HEAD)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Mon Sep 30 19:42:10 2024 +0900

    Chore: Version Packages

Pull request (versioning-pr):

commit d5e2ba2028355f39deb4990d9312faf1d2ea3eda (pull_request/versioning-pr)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Tue Oct 1 16:34:08 2024 +0900

    Fix: CI - Hard Reset at changeset versioning #118

Fast forwarding main (3b26c19) to versioning-pr (d5e2ba2).

$ git push origin d5e2ba2028355f39deb4990d9312faf1d2ea3eda:main
To https://github.com/mincho-js/mincho.git
   3b26c19..d5e2ba2  d5e2ba2028355f39deb4990d9312faf1d2ea3eda -> main

@github-actions github-actions bot merged commit d5e2ba2 into main Oct 1, 2024
7 checks passed
@github-actions github-actions bot deleted the versioning-pr branch October 1, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant