diff --git a/docs/skills/validation/SKILL.md b/docs/skills/validation/SKILL.md index 3a7d602e..a8dba134 100644 --- a/docs/skills/validation/SKILL.md +++ b/docs/skills/validation/SKILL.md @@ -37,6 +37,7 @@ Do not run the full application suite for documentation-only changes. 8. For live-data cache updates, keep the cached file path list identical in order and content across `update-content.yml` (restore and save), `deploy.yml` (restore), and `preview.yml` (restore). 9. When modifying a Vue component under `src/components/`, check `src/tests/` for existing component unit tests and keep test assertions aligned with the runtime contract. 10. For CI concurrency changes, keep pull-request runs grouped by PR and non-PR runs unique; `scripts/tests/workflow-concurrency.test.ts` checks cancellation and group isolation. Assert the parsed YAML expressions directly instead of executing them as JavaScript. +11. Renovate's npm pin (`constraints.npm` in `renovate.json`) must match the npm CI runs, which is the one bundled with Node (`node-version: '26'` → npm 11). With npm 12, Renovate's lock-file updates failed (#1009, `EALLOWREMOTE`). Renovate doesn't offer updates to the pin, so a Node major PR that brings a newer npm fails `scripts/tests/npm-constraint.test.ts` with the exact value to set. Fix it by raising `constraints.npm` in that same PR, not by editing or skipping the test. Documentation-only check: diff --git a/renovate.json b/renovate.json index 79ba16aa..b8d3c564 100644 --- a/renovate.json +++ b/renovate.json @@ -10,6 +10,9 @@ "rebaseWhen": "behind-base-branch", "osvVulnerabilityAlerts": true, "minimumReleaseAge": "3 days", + "constraints": { + "npm": "^11.20.0" + }, "packageRules": [ { "description": "Automerge only pin/pinDigest updates: they record the exact ref of an already-referenced version and introduce no new upstream code. Every other update requires a human merge.", @@ -19,6 +22,28 @@ ], "automerge": true, "platformAutomerge": true + }, + { + "description": "Don't offer updates to the npm pin under constraints: it must match the npm version CI runs (Node 26 ships npm 11), not the newest npm. Raise it in the same change that moves CI to a newer npm; scripts/tests/npm-constraint.test.ts fails CI until then.", + "matchManagers": [ + "renovate-config" + ], + "matchDepTypes": [ + "tool-constraint" + ], + "enabled": false + }, + { + "description": "A Node major brings a newer bundled npm. Remind whoever merges it to raise constraints.npm in the same PR, since updates to that pin are switched off above.", + "matchDepNames": [ + "node" + ], + "matchUpdateTypes": [ + "major" + ], + "prBodyNotes": [ + "**Before merging:** this Node version may bundle a newer npm. Check `npm --version` in this PR's CI log and set `constraints.npm` in `renovate.json` to match, in this same PR." + ] } ], "vulnerabilityAlerts": { diff --git a/scripts/tests/npm-constraint.test.ts b/scripts/tests/npm-constraint.test.ts new file mode 100644 index 00000000..07f341f0 --- /dev/null +++ b/scripts/tests/npm-constraint.test.ts @@ -0,0 +1,21 @@ +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' +import { describe, expect, it } from 'vitest' + +// renovate.json's constraints.npm sets the npm version Renovate writes +// package-lock.json with. It must match the npm CI runs, which is the one +// bundled with Node, so a Node major can move it. Renovate doesn't offer +// updates to the pin, so this fails the Node major PR until someone raises it. +const [running = '', runningMajor = ''] = (process.env.npm_config_user_agent ?? '').match(/\bnpm\/(\d+)\.\d+\.\d+/) ?? [] + +describe('renovate npm pin', () => { + it.skipIf(!running)('matches the npm running the tests', () => { + const config = JSON.parse(readFileSync(resolve(process.cwd(), 'renovate.json'), 'utf8')) as { constraints?: { npm?: string } } + const pin = config.constraints?.npm ?? '' + const version = running.slice(4) + expect( + pin.match(/\d+/)?.[0], + `renovate.json has constraints.npm "${pin}", but the tests run npm ${version}. Set constraints.npm to "^${version}" in this pull request.`, + ).toBe(runningMajor) + }) +})