-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
ci: add changelog lint to catch malformed CHANGELOG.md #33117
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
+51
−0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e0c71a2
add changelog linter to ci
tommasini 4a0377a
changelog lint
tommasini 5faf22d
change linter
tommasini 807fc82
Merge branch 'main' into chore/add-lint-changelog-to-ci
tommasini 6fbb41f
Merge branch 'main' into chore/add-lint-changelog-to-ci
tommasini 12fe393
remove unnecessary flag and code
tommasini e081453
Merge branch 'main' into chore/add-lint-changelog-to-ci
tommasini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,6 +270,7 @@ jobs: | |
| scripts: | ||
| - lint | ||
| - lint:tsc | ||
| - lint:changelog | ||
| - format:check | ||
| - audit:ci | ||
| - test:depcheck | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Validates CHANGELOG.md with @metamask/auto-changelog, mirroring the pattern used | ||
| # by metamask-extension (see .github/workflows/repository-health-checks.yml there). | ||
| # | ||
| # On release-oriented branches, `--rc` is added so validation also enforces that the | ||
| # branch's current package.json version has a corresponding changelog section. This | ||
| # is what should have caught the malformed '### **Before**' header that broke the | ||
| # 8.3.0 -> 8.4.0 release-cut automation before it ever reached CI. | ||
| # | ||
| # Branch shapes treated as release-oriented: | ||
| # release/X.Y.Z, release/X.Y.Z-ota (release branches, incl. OTA hotfixes) | ||
| # release-changelog/X.Y.Z[...] (the changelog-generation working branch) | ||
| # | ||
| # package.json's "repository" field supplies the repo URL automatically (Yarn | ||
| # 3.x/Berry sets PROJECT_CWD, which @metamask/auto-changelog reads), so --repo | ||
| # does not need to be passed explicitly here. | ||
| # | ||
| # --prettier tells the validator to expect the changelog in Prettier-formatted | ||
| # Markdown (blank line after headings), which matches this repo's existing | ||
| # CHANGELOG.md style. Without it, validation would fail against a stricter, | ||
| # denser canonical form (no blank line after headings) hardcoded in | ||
| # @metamask/auto-changelog's stringifier, which would otherwise force | ||
| # reformatting the entire file's history to pass. | ||
|
|
||
| branch="${GITHUB_HEAD_REF:-}" | ||
| if [[ -z "$branch" ]]; then | ||
| branch="${GITHUB_REF_NAME:-}" | ||
| fi | ||
| if [[ -z "$branch" ]]; then | ||
| branch="$(git branch --show-current 2>/dev/null || true)" | ||
| fi | ||
|
|
||
| rc_flag=() | ||
| if [[ "$branch" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+(-ota)?$ ]] || [[ "$branch" =~ ^release-changelog/[0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
| echo "Branch '${branch}' is release-oriented: validating with --rc" | ||
| rc_flag=(--rc) | ||
| else | ||
| echo "Branch '${branch}' is not release-oriented: validating without --rc" | ||
| fi | ||
|
|
||
| yarn auto-changelog validate --prettier "${rc_flag[@]+"${rc_flag[@]}"}" | ||
Oops, something went wrong.
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.
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.
RC lint ignores PR base branch
Medium Severity
lint-changelog.shonly treatsGITHUB_HEAD_REF(thenGITHUB_REF_NAME/ current git branch) as release-oriented for--rc. Pull requests that targetrelease/*orrelease-changelog/*with a non-matching head branch skip--rc, so CI may not verify thatpackage.json’s version has a changelog section on those release PRs.Reviewed by Cursor Bugbot for commit e081453. Configure here.