Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ jobs:
scripts:
- lint
- lint:tsc
- lint:changelog
- format:check
- audit:ci
- test:depcheck
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "metamask",
"version": "8.4.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/metamask-mobile.git"
},
"scripts": {
"install:foundryup": "yarn mm-foundryup",
"anvil": "node_modules/.bin/anvil",
Expand All @@ -19,6 +23,8 @@
"lint:fix": "NODE_OPTIONS='--max-old-space-size=12288' eslint '**/*.{js,ts,tsx}' --fix --cache && yarn messenger-action-types:generate",
"lint:clean": "rm -f .eslintcache",
"lint:tsc": "NODE_OPTIONS='--max-old-space-size=12288' tsc --project ./tsconfig.json",
"lint:changelog": "./scripts/lint-changelog.sh",
"lint:changelog:rc": "auto-changelog validate --rc --prettier",
"format": "prettier '**/*.{js,ts,tsx,json}' --write",
"format:check": "prettier '**/*.{js,ts,tsx,json}' --check",
"format:check:changed": "git diff --name-only --diff-filter=ACM HEAD~1 | { grep -E '\\.(js|ts|tsx|json)$' || true; } | xargs --no-run-if-empty prettier --check",
Expand Down
44 changes: 44 additions & 0 deletions scripts/lint-changelog.sh
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

Copy link
Copy Markdown
Contributor

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.sh only treats GITHUB_HEAD_REF (then GITHUB_REF_NAME / current git branch) as release-oriented for --rc. Pull requests that target release/* or release-changelog/* with a non-matching head branch skip --rc, so CI may not verify that package.json’s version has a changelog section on those release PRs.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e081453. Configure here.


yarn auto-changelog validate --prettier "${rc_flag[@]+"${rc_flag[@]}"}"
Loading