Commit c4cb337
authored
ci: add changelog lint to catch malformed CHANGELOG.md (#33117)
## **Description**
<!-- mms-check: type=text required=true -->
The automated main-version-bump PR for the 8.3.0 release cut never got
created: `MetaMask/github-tools`'s `create-release-pr` action crashed
with `Error: Malformed category header: '### **Before**'` while
regenerating `CHANGELOG.md` on the `release-changelog/8.3.0` branch,
because a prior PR's raw "Screenshots/Recordings" template text had been
committed verbatim into the changelog instead of a clean entry. Nothing
in mobile's CI validates `CHANGELOG.md` formatting today, so this kind
of corruption is invisible until it silently breaks the release-cut
pipeline.
This adds a changelog lint, mirroring the pattern `metamask-extension`
already uses:
- `scripts/lint-changelog.sh`: a branch-aware wrapper around
`@metamask/auto-changelog validate` (the same non-mutating parser the
release pipeline's `auto-changelog update` uses internally, so it fails
on the exact same malformed input). On release-oriented branches
(`release/X.Y.Z(-ota)?`, `release-changelog/X.Y.Z*`) it adds `--rc`,
which also verifies the current `package.json` version has a changelog
section.
- `lint:changelog` / `lint:changelog:rc` scripts in `package.json`,
wired into the existing `scripts` lint matrix in
`.github/workflows/ci.yml` so it runs on every PR — including changelog
PRs into `release/*` and release PRs into `stable` — without needing a
new job.
- A one-time normalization of `CHANGELOG.md` via `auto-changelog
validate --fix`, which stripped 718 extraneous blank lines (verified
zero content lines added/removed) so the new check starts green instead
of failing immediately on `main`.
## **Changelog**
<!-- mms-check: type=changelog required=true blocking=true -->
CHANGELOG entry: null
## **Related issues**
<!-- mms-check: type=issue-link required=true -->
Fixes:
## **Manual testing steps**
<!-- mms-check: type=manual-testing required=true -->
```gherkin
Feature: Changelog validation in CI
Scenario: CI catches a malformed changelog entry before it reaches the release pipeline
Given a PR modifies CHANGELOG.md with an invalid category header (e.g. "### **Before**")
When the `scripts` CI job runs `yarn lint:changelog`
Then the job should fail with "Malformed category header"
Scenario: CI validates release-branch changelogs in --rc mode
Given a PR's head or base branch matches `release/X.Y.Z` or `release-changelog/X.Y.Z`
When `yarn lint:changelog` runs
Then it should invoke `auto-changelog validate --rc`
And fail if the branch's current package.json version has no changelog section
Scenario: main's CHANGELOG.md passes validation
Given the CHANGELOG.md normalization included in this PR
When `yarn lint:changelog` runs on `main`
Then it should exit 0 with no errors
```
Locally verified: `yarn lint:changelog` passes on `main`; re-injecting
the exact `### **Before**` corruption that broke the 8.3.0 release cut
reproduces the identical `Malformed category header` error; simulating
`release/8.3.0` / `release-changelog/8.3.0` branch names via
`GITHUB_REF_NAME` / `GITHUB_HEAD_REF` correctly switches the script into
`--rc` mode.
## **Screenshots/Recordings**
<!-- mms-check: type=screenshot required=true -->
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
<!-- mms-check: type=checklist required=true -->
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [x] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [x] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [x] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- Generated with the help of the pr-description AI skill -->
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Changes are limited to CI and changelog tooling; no runtime app
behavior, with the main effect being failed PRs when CHANGELOG.md is
invalid.
>
> **Overview**
> Adds **CHANGELOG.md validation** to the existing CI `scripts` matrix
so every PR runs `yarn lint:changelog`, catching malformed changelog
entries (e.g. invalid category headers) before they break release-cut
automation.
>
> Introduces `scripts/lint-changelog.sh`, which runs
`@metamask/auto-changelog validate --prettier` and turns on **`--rc`**
on `release/*`, `release/*-ota`, and `release-changelog/*` branches so
the current `package.json` version must have a matching changelog
section. `package.json` gains `lint:changelog`, `lint:changelog:rc`, and
a **`repository`** field so auto-changelog can resolve the repo URL
under Yarn Berry.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e081453. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent d0795b6 commit c4cb337
3 files changed
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
0 commit comments