[CI] Add Buildkite step to validate changelog PR links#19171
Open
mrodm wants to merge 40 commits into
Open
Conversation
Add a new script `.buildkite/scripts/check_changelog_entries.sh` that inspects any `changelog.yml` files modified in a pull request and verifies that newly added `link:` entries point to the current PR. Issue links (`/issues/<n>`) are accepted as-is. A matching Buildkite step is wired into `.buildkite/pipeline.yml`, gated on PR builds and triggered only when a `changelog.yml` file is changed (`if_changed`). Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract the validation logic of check_changelog_entries.sh into discrete, testable functions (github_repo_path, get_added_links, check_changelog_file) guarded by a BASH_SOURCE main guard so the script can be sourced by tests without executing. Fix the common.sh source path to be relative to the script's own directory. Add test_check_changelog_entries.sh covering URL parsing, correct PR links, wrong PR links, issue link exemption, no new entries, deleted files, and multiple-error accumulation. Hook the new test file into run_dev_scripts_tests.sh so it runs in the existing CI step. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract all tests for get_release_commit.sh from run_dev_scripts_tests.sh into a dedicated dev/scripts/test_get_release_commit.sh, following the same pattern established for test_check_changelog_entries.sh. The runner run_dev_scripts_tests.sh is now a thin orchestrator that delegates to each test file in sequence. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Rename run_dev_scripts_tests.sh to run_shell_scripts_tests.sh and update the Buildkite step label and key accordingly (check-shell-scripts). Update all references in common.sh and the test file comments. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
🚀 Benchmarks reportTo see the full report comment with |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
|
/test |
This comment has been minimized.
This comment has been minimized.
…iles Refactor notify_changelog_mismatch to accept a combined message and a fixed annotation context, then accumulate all failing changelog files into an array during the loop and call the function once after it with a bulleted list of every affected file instead of one notification per file. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Add a depends_on on check-shell-scripts (allow_failure: false) to the check-changelog-pr-links step so it only runs once the shell unit tests have completed successfully. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Add edit_gh_pr_comment_if_exists to common.sh next to add_or_edit_gh_pr_comment: it edits an existing PR comment identified by its marker, and does nothing if no matching comment is found. Use it in check_changelog_entries.sh to update the mismatch comment with a resolved message when all changelog links are correct, avoiding a spurious success comment on clean runs. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Add delete_and_create_gh_pr_comment to common.sh: it deletes any existing comment with the given marker and posts a fresh one, moving the status to the bottom of the PR thread for visibility. Use it in check_changelog_entries.sh on the success path instead of edit_gh_pr_comment_if_exists, so the resolved message appears as a new comment rather than an in-place edit. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace add_or_edit_gh_pr_comment with delete_and_create_gh_pr_comment in notify_changelog_mismatch so that repeated failures always post a fresh comment at the bottom of the PR thread instead of editing in place. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix skip-label check using wrong label string ('skip-changelog' instead
of 'changelog-link-check:skip'); extract into should_skip_changelog_check()
with tests
- Fix unquoted word-splitting in changelog file loop; use while/read
- Add --repo flag to gh pr comment in delete_and_create_gh_pr_comment()
- Add check_changelog_entries.sh and test file to non_package_patterns
- Guard dev/scripts copy in backport_branch.sh with git ls-tree existence check
Made with Claude
Made with Claude
Made with Claude
|
Changelog link mismatch — expected
|
mrodm
commented
May 25, 2026
Collaborator
Author
There was a problem hiding this comment.
Moved tests from ".buildkite/scripts/run_dev_scripts_tests.sh"
mrodm
commented
May 25, 2026
| allow_failure: false | ||
| if: | | ||
| build.env('BUILDKITE_PULL_REQUEST') != "false" && | ||
| !(build.env("GITHUB_PR_LABELS") =~ /changelog-link-check:skip/) |
Collaborator
Author
There was a problem hiding this comment.
What about this label ? Any other suggestion?
There is already a skip-changelog but I think it could be misunderstood the expected actions.
mrodm
commented
May 25, 2026
| while IFS= read -r link; do | ||
| [[ -z "${link}" ]] && continue | ||
| if [[ "${link}" =~ /issues/[0-9]+$ ]]; then | ||
| echo "SKIP: '${link}' (issue link, not required to match PR)" |
Collaborator
Author
There was a problem hiding this comment.
Allowed to set links to issues. But if this is done, it does not validate anything.
This validation is intended (as it is) for pull request links.
Collaborator
Author
|
/test |
4 tasks
💔 Build Failed
Failed CI StepsHistory
cc @mrodm |
7 tasks
This was referenced May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
WHAT:
Add a new Buildkite CI step that inspects
changelog.ymlfiles modified in a pull request and verifies that newly addedlink:entries point to the current PR URL. The check:changelog.ymlfile changed at any directory depth (supporting both flat and nested package layouts)./issues/<n>) without requiring them to match the PR URL.changelog.ymlis part of the changed files (if_changed).The validation logic is extracted into discrete, testable shell functions (
github_repo_path,get_added_links,check_changelog_file) with aBASH_SOURCEmain guard so the script can be sourced by tests without executing.A dedicated test file (
test_check_changelog_entries.sh) is added covering: SSH/HTTPS URL parsing, correct PR links, wrong PR links, issue link exemption, no new entries, deleted files, and multiple-error accumulation.As part of this work, the existing
run_dev_scripts_tests.shis refactored into a thin orchestrator (run_shell_scripts_tests.sh) and theget_release_commit.shtests are moved to their own self-contained file (dev/scripts/test_get_release_commit.sh), following the same pattern.WHY:
Changelog entries with wrong PR links (e.g. copied from another PR) are a recurring source of noise in the release process. Automating this check at CI time catches the mistake before merge without requiring manual review of every changelog entry.
Author's Checklist
.buildkite/scripts/run_shell_scripts_tests.shsoft_fail). https://buildkite.com/elastic/integrations/builds/43361github-actions[bot]must notifyecosystemteam.How to test this PR locally
Run the shell script test suite:
To simulate the changelog link check against a PR branch manually (this is based on the remote
originand it must be updated):Related issues
Screenshots
soft_fail: