-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Validate necessary branches for the workflow release-commits-and-contributors.yml
exist
#59768
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
Conversation
Testing GuidelinesHi @prettyboymp @woocommerce/flux, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
📝 WalkthroughWalkthroughA new validation step was added to the GitHub Actions workflow for releases. This step checks if the current and previous release branches exist in the remote repository before proceeding, ensuring that the workflow only continues if both branches are present. Changes
Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Nitpick comments (1)
.github/workflows/release-commits-and-contributors.yml (1)
82-90
: Minor nit: prefer quoting branch variables ingit ls-remote
Quoting prevents word-splitting should a branch name ever contain special characters (unlikely but free safety). No functional change otherwise.
- if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${CURRENT_BRANCH} > /dev/null; then + if ! git ls-remote --exit-code --heads "https://github.com/${GITHUB_REPOSITORY}" "${CURRENT_BRANCH}" > /dev/null; thenRepeat for the previous-branch check below.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/release-commits-and-contributors.yml
(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: prettyboymp
PR: woocommerce/woocommerce#59048
File: .github/workflows/cherry-pick-milestoned-prs.yml:118-131
Timestamp: 2025-07-11T13:05:08.430Z
Learning: In GitHub Actions workflows, when reviewing steps that access event data like `github.event.pull_request.milestone`, check the entire job dependency chain and conditional logic. If upstream jobs already validate the data exists (like checking `github.event.pull_request.milestone != null` in a prerequisite job), then downstream jobs don't need redundant null-checks since the data is guaranteed to exist by that point.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:48-65
Timestamp: 2025-07-15T15:39:21.815Z
Learning: In WooCommerce core repository, changelog entries for all PRs live in `plugins/woocommerce/changelog/` directory and are processed during releases, not at the repository root level.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-06-30T09:26:55.361Z
Learning: Provide clear, step-by-step instructions for how to test the changes in the PR description.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-06-30T09:26:55.361Z
Learning: Applies to .github/PULL_REQUEST_TEMPLATE.md : Do not remove or alter required markdown sections in the PR description, especially those used by automation (e.g., changelog entry details and comments).
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/generate-pr-description.mdc:0-0
Timestamp: 2025-06-30T09:26:55.361Z
Learning: Applies to .github/PULL_REQUEST_TEMPLATE.md : The changelog section in the PR description must keep the markdown structure from the PR template exactly as-is, including all checkboxes, comments, and headings. Only the appropriate checkbox may be checked, and the changelog message must be placed under the `#### Comment` heading and before the closing `</details>` tag. Do not add, remove, or reformat any part of the changelog section except for checking the box and adding the message in the correct place.
Learnt from: albarin
PR: woocommerce/woocommerce#59445
File: .github/workflows/release-update-stable-tag.yml:81-108
Timestamp: 2025-07-08T12:03:29.871Z
Learning: In GitHub Actions workflows, when using matrix strategy with `fail-fast: false`, individual matrix jobs can fail without stopping the entire workflow or affecting other matrix jobs. This allows graceful handling of scenarios where some matrix entries may be invalid (like non-existent branches) while still processing valid entries successfully.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-06-30T09:27:06.883Z
Learning: Branch names should follow the structure: 'release/{version}' for release branches.
.github/workflows/release-commits-and-contributors.yml (2)
Learnt from: prettyboymp
PR: woocommerce/woocommerce#59048
File: .github/workflows/cherry-pick-milestoned-prs.yml:118-131
Timestamp: 2025-07-11T13:05:08.430Z
Learning: In GitHub Actions workflows, when reviewing steps that access event data like `github.event.pull_request.milestone`, check the entire job dependency chain and conditional logic. If upstream jobs already validate the data exists (like checking `github.event.pull_request.milestone != null` in a prerequisite job), then downstream jobs don't need redundant null-checks since the data is guaranteed to exist by that point.
Learnt from: CR
PR: woocommerce/woocommerce#0
File: .cursor/rules/git.mdc:0-0
Timestamp: 2025-06-30T09:27:06.883Z
Learning: Branch names should follow the structure: 'release/{version}' for release branches.
- name: Check the necessary branches exist | ||
run: | | ||
CURRENT_BRANCH="release/${{ steps.calculate-versions.outputs.current_version }}" | ||
PREVIOUS_BRANCH="release/${{ steps.calculate-versions.outputs.previous_version }}" | ||
|
||
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${CURRENT_BRANCH} > /dev/null; then | ||
echo "::error::Branch '$CURRENT_BRANCH' for the ${{ steps.calculate-versions.outputs.current_version }} version does not exist." | ||
exit 1 | ||
fi | ||
|
||
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${PREVIOUS_BRANCH} > /dev/null; then | ||
echo "::error::Branch '$PREVIOUS_BRANCH' for the ${{ steps.calculate-versions.outputs.previous_version }} version does not exist." | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use set -eo pipefail
for more predictable failure handling
The step relies on early exits (exit 1
) but still executes several shell commands that are piped to /dev/null
.
Explicitly enabling set -eo pipefail
at the top of the script guarantees that any non-zero status—including a failure inside a future multi-command pipeline—immediately aborts the step, mirroring the intent of an early-fail guard.
- - name: Check the necessary branches exist
- run: |
- CURRENT_BRANCH="release/${{ steps.calculate-versions.outputs.current_version }}"
+ - name: Check the necessary branches exist
+ run: |
+ set -eo pipefail
+
+ CURRENT_BRANCH="release/${{ steps.calculate-versions.outputs.current_version }}"
PREVIOUS_BRANCH="release/${{ steps.calculate-versions.outputs.previous_version }}"
📝 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.
- name: Check the necessary branches exist | |
run: | | |
CURRENT_BRANCH="release/${{ steps.calculate-versions.outputs.current_version }}" | |
PREVIOUS_BRANCH="release/${{ steps.calculate-versions.outputs.previous_version }}" | |
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${CURRENT_BRANCH} > /dev/null; then | |
echo "::error::Branch '$CURRENT_BRANCH' for the ${{ steps.calculate-versions.outputs.current_version }} version does not exist." | |
exit 1 | |
fi | |
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${PREVIOUS_BRANCH} > /dev/null; then | |
echo "::error::Branch '$PREVIOUS_BRANCH' for the ${{ steps.calculate-versions.outputs.previous_version }} version does not exist." | |
exit 1 | |
fi | |
- name: Check the necessary branches exist | |
run: | | |
set -eo pipefail | |
CURRENT_BRANCH="release/${{ steps.calculate-versions.outputs.current_version }}" | |
PREVIOUS_BRANCH="release/${{ steps.calculate-versions.outputs.previous_version }}" | |
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${CURRENT_BRANCH} > /dev/null; then | |
echo "::error::Branch '$CURRENT_BRANCH' for the ${{ steps.calculate-versions.outputs.current_version }} version does not exist." | |
exit 1 | |
fi | |
if ! git ls-remote --exit-code --heads https://github.com/${GITHUB_REPOSITORY} ${PREVIOUS_BRANCH} > /dev/null; then | |
echo "::error::Branch '$PREVIOUS_BRANCH' for the ${{ steps.calculate-versions.outputs.previous_version }} version does not exist." | |
exit 1 | |
fi |
🤖 Prompt for AI Agents
In .github/workflows/release-commits-and-contributors.yml around lines 77 to 90,
add the line 'set -eo pipefail' at the very beginning of the run script block to
ensure that any command failure, including those in pipelines, causes the step
to exit immediately. This will make failure handling more robust and predictable
by stopping execution on any error without relying solely on explicit exit
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked as expected.
Submission Review Guidelines:
Changes proposed in this Pull Request:
Closes #59742
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
woocommerce/woocommerce
repo with all branches into your GH account.Settings > Secrets and variables > Actions
and create 3 new repository secrets:CODE_FREEZE_BOT_TOKEN
, get the token value from theTest Assistant bot
from the secret store.WOO_RELEASE_SLACK_NOTIFICATION_CHANNEL
: You can use the test channeltest-woo-core-release-notifications
.59742/validate-branch
and merge it (to get this new workflow intotrunk
).Actions
and manually run theRelease: Generate Number of Commits and Contributors
with a version without a corresponding branch in your fork, for example:12.1
.Error: Branch 'release/12.1' for the 12.1 version does not exist.
release/12.1
branch, run the workflow again with the same version.Error: Branch 'release/12.0' for the 12.0 version does not exist.
release/12.0
branch, run the workflow again with the same version.and we don't need to check any more changes.
Testing that has already taken place:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Changelog Entry Comment
Comment