Skip to content

Improve the release-compile-changelog.yml workflow #59786

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

Merged
merged 5 commits into from
Jul 21, 2025

Conversation

albarin
Copy link
Contributor

@albarin albarin commented Jul 18, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request:

  • Added input validation for version format (X.Y or X.Y.Z) and release date format (YYYY-MM-DD).
  • Removed the option to leave the input version empty and run the workflow from a branch.
  • Implemented branch detection that falls back from patch version branches (release/X.Y.Z) to minor version branches (release/X.Y).
  • Enhanced error handling with clear error messages for invalid inputs and missing branches.

Closes #59629

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Fork the woocommerce/woocommerce repo with all branches into your GH account.
  2. In the forked repo, create a PR with the branch 59629/improve-compile-changelog and merge it (to get this new workflow into trunk).
  3. In the forked repo, go to Actions, Release: Compile changelog, click on Run workflow, and test the following test cases:

Test 1: Invalid date
Write a random string in the date input and make sure the workflow fails with the error: Invalid release date format. The release date must be in the format YYYY-MM-DD.

Test 2: Invalid version
Write a random string in the version input and make sure the workflow fails with the error: Invalid version format. The version must be in the format X.Y or X.Y.Z.

Test 3: No branch patch or minor branch exists

  1. Make sure branches release/12.1.1 and release/12.1 don't exist on your fork.
  2. Run the workflow with a patch version like 12.1.1.
  3. Make sure it fails with the error: Neither branch 'release/12.1.1' nor 'release/12.1' exists.

Test 4: No branch patch exists

  1. Make sure the branch release/12.1.1 doesn't exist, but the release/12.1 does exist on your fork.
  2. Run the workflow with a patch version like 12.1.1
  3. Make sure it succeeds and the Check the necessary branch exists step prints Using branch: release/12.1.

Test 5: Minor version

  1. Make sure the branch release/12.1 exists on your fork.
  2. Run the workflow with a patch version like 12.1
  3. Make sure it succeeds and the Check the necessary branch exists step prints Using branch: release/12.1.

Testing that has already taken place:

All listed tests have been tested in my fork https://github.com/albarin/woocommerce/actions/workflows/release-compile-changelog.yml

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions bot added the focus: monorepo infrastructure Issues and PRs related to monorepo tooling. label Jul 18, 2025
@albarin albarin marked this pull request as ready for review July 18, 2025 14:44
@albarin albarin requested a review from a team as a code owner July 18, 2025 14:44
@albarin albarin requested review from kalessil and removed request for a team July 18, 2025 14:44
@woocommercebot woocommercebot requested a review from a team July 18, 2025 14:44
Copy link
Contributor

github-actions bot commented Jul 18, 2025

Testing Guidelines

Hi @kalessil @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:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link
Contributor

coderabbitai bot commented Jul 18, 2025

📝 Walkthrough

Walkthrough

The GitHub Actions workflow for release compilation and changelog generation was updated to require an explicit version input, enforce stricter validation for version and release date formats, and verify the existence of the corresponding release branch before proceeding. Workflow steps were streamlined to use these validated inputs directly.

Changes

File(s) Change Summary
.github/workflows/release-compile-changelog.yml Made version input required, added strict validation for version and release_date, enforced existence check for release branch, updated changelog step to use validated inputs, and removed legacy normalization and conditional logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions Workflow
    participant Remote Repo

    User->>GitHub Actions Workflow: Trigger workflow with version and optional release_date
    GitHub Actions Workflow->>GitHub Actions Workflow: Validate version format (X.Y or X.Y.Z)
    GitHub Actions Workflow->>GitHub Actions Workflow: Validate release_date (if provided, YYYY-MM-DD)
    GitHub Actions Workflow->>Remote Repo: Check if release/{version} branch exists
    alt Branch exists
        GitHub Actions Workflow->>GitHub Actions Workflow: Use release/{version}
    else Branch does not exist
        GitHub Actions Workflow->>Remote Repo: Check if release/{minor_version} branch exists
        alt Minor branch exists
            GitHub Actions Workflow->>GitHub Actions Workflow: Use release/{minor_version}
        else Neither branch exists
            GitHub Actions Workflow->>User: Fail workflow with error
        end
    end
    GitHub Actions Workflow->>GitHub Actions Workflow: Generate changelog with validated inputs
Loading

Estimated code review effort

1 (<30 minutes)

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f180b5 and d4ec735.

📒 Files selected for processing (1)
  • .github/workflows/release-compile-changelog.yml (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/release-compile-changelog.yml

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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

🧹 Nitpick comments (4)
.github/workflows/release-compile-changelog.yml (4)

6-8: default: '' is redundant (and potentially confusing) when required: true.

Because the input is now mandatory, the empty‐string default can never be used. Dropping it makes the intent clearer and avoids questions about whether an empty value is still allowed.

-        required: true
-        default: ''
+        required: true

33-56: Minor: eliminate the extra process.exit(1) calls after core.setFailed.

core.setFailed() already marks the step as failed and terminates execution; the explicit process.exit(1) is unnecessary noise.

-  core.setFailed('Invalid version format. The version must be in the format X.Y or X.Y.Z');
-  process.exit(1);
+  core.setFailed('Invalid version format. The version must be in the format X.Y or X.Y.Z');

57-83: Consistent pattern: pass release_date via env instead of inlining into the script.

Embedding the expression ${{ github.event.inputs.release_date }} directly into the script string risks YAML-quoting issues if the date ever contains unusual characters. Follow the same pattern as the version-validation step for consistency and robustness.

-        with:
-          script: |
-            const releaseDate = '${{ github.event.inputs.release_date }}';
+        env:
+          RELEASE_DATE: ${{ github.event.inputs.release_date }}
+        with:
+          script: |
+            const releaseDate = process.env.RELEASE_DATE;

89-116: Consider short-circuiting the remote look-ups to reduce latency.

For large repos with many branches, two separate git ls-remote calls introduce ~2× network latency. You can fetch all heads once and test locally:

refs=$(git ls-remote --heads origin)
if echo "$refs" | grep -qE "refs/heads/${VERSION_BRANCH}$"; then
  ...
elif echo "$refs" | grep -qE "refs/heads/${MINOR_BRANCH}$"; then
  ...
fi

Not critical, but it will shave a second or two off every run.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 109fba0 and 4f180b5.

📒 Files selected for processing (1)
  • .github/workflows/release-compile-changelog.yml (5 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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: prettyboymp
PR: woocommerce/woocommerce#59048
File: .github/workflows/cherry-pick-milestoned-prs.yml:118-131
Timestamp: 2025-07-11T13:05:08.440Z
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.856Z
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: 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: lysyjan
PR: woocommerce/woocommerce#59632
File: packages/js/email-editor/src/layouts/flex-email.tsx:116-122
Timestamp: 2025-07-14T10:41:46.200Z
Learning: In WooCommerce projects, formatting suggestions should respect the project's Prettier configuration and linting rules. Changes that would break the lint job should be avoided, even if they appear to improve readability.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:57-57
Timestamp: 2025-07-15T15:39:02.479Z
Learning: GitHub Actions ubuntu-latest runner image includes Composer by default as part of the preinstalled software, so no additional installation step is needed when using Composer commands in workflows.
Learnt from: jorgeatorres
PR: woocommerce/woocommerce#59675
File: .github/workflows/release-bump-as-requirement.yml:57-57
Timestamp: 2025-07-15T15:39:02.479Z
Learning: GitHub Actions ubuntu-latest runner image includes Composer by default as part of the PHP tools, so no additional installation step is needed when using Composer commands in workflows.
.github/workflows/release-compile-changelog.yml (4)
Learnt from: prettyboymp
PR: woocommerce/woocommerce#59048
File: .github/workflows/cherry-pick-milestoned-prs.yml:118-131
Timestamp: 2025-07-11T13:05:08.440Z
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/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: 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.
🪛 actionlint (1.7.7)
.github/workflows/release-compile-changelog.yml

85-85: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

Copy link
Contributor

@prettyboymp prettyboymp left a comment

Choose a reason for hiding this comment

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

Changes look good and worked as expected.

@prettyboymp prettyboymp merged commit f06c713 into trunk Jul 21, 2025
12 checks passed
@prettyboymp prettyboymp deleted the 59629/improve-compile-changelog branch July 21, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: monorepo infrastructure Issues and PRs related to monorepo tooling.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compile changelog workflow input is a bit confusing
2 participants