ci: detect package.json dep/peerDep changes without a matching changeset#2627
Conversation
Add `.github/scripts/check-dep-changes-have-changeset.cjs` that compares the changeset status report against the set of package.json files whose `dependencies` or `peerDependencies` actually changed in the PR. Any non-private package with a dep/peer-dep diff but no changeset bump is reported with an actionable message and the script exits non-zero. Hook it into the existing `code-style-check` job after the other changeset checks, and run the script's own unit tests in the same step. Verified locally: re-running this check against the state of PR #2423 (where `react-refresh-webpack-plugin/package.json` had its peer range widened but the changeset bumped only three other packages) reproduces the catch — the script flags `@lynx-js/react-refresh-webpack-plugin` and fails. With this check in place, the omission would have been surfaced at review time.
|
📝 WalkthroughWalkthroughThis PR adds a new dependency changeset validation system: a Node.js CLI script that scans package.json changes between git refs, compares dependency maps, and ensures packages with dependency updates have corresponding changesets. The script is then integrated as a new CI workflow step to enforce this validation. ChangesDependency Changeset Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will degrade performance by 8.34%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
React MTF Example#1304 Bundle Size — 207.46KiB (0%).e437712(current) vs bdbcf79 main#1294(baseline) Bundle metrics
|
| Current #1304 |
Baseline #1294 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
192 |
192 |
|
77 |
77 |
|
44.38% |
44.38% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1304 |
Baseline #1294 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
96.23KiB |
96.23KiB |
Bundle analysis report Branch feat/dep-changeset-check Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#438 Bundle Size — 197.79KiB (0%).e437712(current) vs bdbcf79 main#428(baseline) Bundle metrics
Bundle size by type
|
| Current #438 |
Baseline #428 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
52.03KiB |
52.03KiB |
Bundle analysis report Branch feat/dep-changeset-check Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#9746 Bundle Size — 901.38KiB (0%).e437712(current) vs bdbcf79 main#9736(baseline) Bundle metrics
Bundle size by type
|
| Current #9746 |
Baseline #9736 |
|
|---|---|---|
497.1KiB |
497.1KiB |
|
402.06KiB |
402.06KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch feat/dep-changeset-check Project dashboard
Generated by RelativeCI Documentation Report issue
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/scripts/check-dep-changes-have-changeset.cjs:
- Around line 55-60: The try/catch that parses package.json (parsing into curPkg
and basePkg from cur and base) should fail-fast instead of silently continuing;
in the catch block capture the thrown error and the filename being parsed and
terminate with a non-zero exit (e.g., throw or process.exit(1)) while logging a
clear message containing the filename and error details so a malformed
package.json cannot bypass the CI gate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2d88e61f-86e6-45c8-b787-8a75d4b330cc
📒 Files selected for processing (2)
.github/scripts/check-dep-changes-have-changeset.cjs.github/workflows/test.yml
React Example#8171 Bundle Size — 236.51KiB (0%).e437712(current) vs bdbcf79 main#8161(baseline) Bundle metrics
|
| Current #8171 |
Baseline #8161 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
197 |
197 |
|
80 |
80 |
|
44.87% |
44.87% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8171 |
Baseline #8161 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
90.75KiB |
90.75KiB |
Bundle analysis report Branch feat/dep-changeset-check Project dashboard
Generated by RelativeCI Documentation Report issue
React External#1286 Bundle Size — 693.04KiB (0%).e437712(current) vs bdbcf79 main#1276(baseline) Bundle metrics
|
| Current #1286 |
Baseline #1276 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch feat/dep-changeset-check Project dashboard
Generated by RelativeCI Documentation Report issue
Summary
Add a CI check that catches the case where a PR modifies a package's
dependenciesorpeerDependenciesbut the changesets in that PR don't bump the affected package. Without this guard, the dep change lands onmainand sits there until someone makes another change that triggers a release — silently shipping broken peer ranges and tripping the kind of npm hoist conflict that surfaced as #2624.Concrete motivation
#2423 widened the
@lynx-js/react-webpack-pluginpeer range on@lynx-js/react-refresh-webpack-plugin, but the changeset only bumped@lynx-js/react,@lynx-js/react-webpack-plugin, and@lynx-js/react-rsbuild-plugin. The peer-range fix sat unreleased;npm installconsumers continued to pull the old@lynx-js/react-refresh-webpack-plugin@0.3.5with the narrow peer range, force a parallel@lynx-js/react-webpack-plugin@0.8.0install, pin@lynx-js/template-webpack-plugin@0.10.9at the top ofnode_modulesnext to nested0.11.0copies, and ultimately produce the build error tracked in #2624. The missed-changeset follow-up is #2626.Running this new check against the
#2423state (locally, with--since=$(git rev-parse 1f4f1171^)) reproduces the catch:Exit code is non-zero — CI would have blocked the PR until either a changeset was added or the dep change was reverted.
What the check does
For each
package.jsonmodified relative to the PR's base ref:private: truepackages (not published, so no release-time impact).dependenciesandpeerDependenciesagainst the base.devDependenciesis intentionally ignored — those don't affect downstream consumers.isShallowEqualis tolerant of key reordering and ignores anything outside the two examined fields, so changes that don't actually move the resolution surface (formatting, version-field re-sorts viapnpm meta-updater) don't trip the check.Integration
Inserted in the existing
code-style-checkjob, immediately afterChangeset Heading Check. The script's own unit-test file is also exercised in the same step vianode --test, so the helper logic gets regression coverage without spinning up a separate runner.Test plan
node --test .github/scripts/check-dep-changes-have-changeset.test.cjs— 10 cases, all pass (key reorder tolerance, dev-deps-only skip, private-pkg skip, newly-added-pkg skip, multi-package flagging, etc.)#2423state reproduces the catch and exits non-zeroSummary by CodeRabbit
Note: This release includes internal infrastructure improvements with no direct impact to end-user functionality.