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 dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "astro dev",
"build:astro": "astro check && astro build",
"postbuild:search": "pagefind --site dist --output-path dist/pagefind",
"prebuild": "node scripts/check-npm-pin.mjs",
"build": "npm run build:astro && npm run postbuild:search",
"preview": "astro preview"
},
Expand Down
27 changes: 27 additions & 0 deletions dashboard/scripts/check-npm-pin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// renovate.json's constraints.npm sets the npm version Renovate writes
// dashboard/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's dashboard
// build until someone raises it. Enforced in CI only, so a local build on
// another npm isn't blocked.
import { readFileSync } from "node:fs";

const running = (process.env.npm_config_user_agent ?? "").match(
/\bnpm\/(\d+)\.\d+\.\d+/,
);
if (!process.env.CI || !running) process.exit(0);

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.

correctness (low, advisory): CI is also set in publish-to-pages.yml, which runs npm run build (.github/workflows/publish-to-pages.yml:127-130) every 2 hours on main. Both workflows float on node-version: '26' (publish-to-pages.yml:118, dashboard-build.yml:41). A Node minor can bring a new npm major without any Renovate PR; Node 18.19 moved npm 9 to 10. If that happens, the scheduled publish stops deploying the dashboard, and there is no PR where the pin could be raised. Today a lock written by npm 11 would still install under npm 12, so the only cost is a stale pin. Suggest enforcing only on PR and merge-queue builds, where a person can fix it:

Suggested change
if (!process.env.CI || !running) process.exit(0);
const enforced = ["pull_request", "merge_group"].includes(process.env.GITHUB_EVENT_NAME ?? "");
if (!process.env.CI || !enforced || !running) process.exit(0);

If you take this, also update SKILL.md point 12 ("it only enforces when CI is set").


const config = JSON.parse(
readFileSync(new URL("../../renovate.json", import.meta.url), "utf8"),
);
const pin = config.constraints?.npm ?? "";
const version = running[0].slice(4);

if (pin.match(/\d+/)?.[0] !== running[1]) {
console.error(
`renovate.json has constraints.npm "${pin}", but CI runs npm ${version}. ` +
`Set constraints.npm to "^${version}" in this pull request.`,
);
process.exit(1);
}
console.log(`renovate.json constraints.npm "${pin}" matches npm ${version}.`);
2 changes: 2 additions & 0 deletions docs/skills/ci-ops/dashboard-metrics/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ This skill guides agents through modifying, compiling, and deploying the QA dash

11. **`publish-to-pages.yml` is not exercised by PR checks**: the workflow only triggers on `schedule`, `workflow_dispatch`, and pushes to `main` under `dashboard/**`. A dependency PR can therefore merge fully green and only break the dashboard hours later on the next 2-hourly cron. Any PR touching `dashboard/package.json`, `dashboard/package-lock.json`, or `dashboard/scripts/**` must be validated locally with `npm ci && npm run build` before merge.

12. **Renovate's npm pin must match CI's npm**: `renovate.json` sets `constraints.npm` (`^11.20.0`, #1255) so Renovate writes `dashboard/package-lock.json` with the same npm CI uses; npm 12 could not update that lock file (#1257). CI's npm is the one bundled with Node (`node-version: '26'` → npm 11), and Renovate doesn't offer updates to the pin. So a Node major PR that brings a newer npm fails `dashboard-build` at `prebuild` (`dashboard/scripts/check-npm-pin.mjs`), with the exact value to set. Fix it by raising `constraints.npm` in that same PR, not by editing or skipping the check. Local builds skip the check; it only enforces when `CI` is set.

## Common Rationalizations

| Rationalization | Reality |
Expand Down
14 changes: 14 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
"matchUpdateTypes": ["major"],
"enabled": false
},
{
"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 (#1257 was closed for this). Raise it in the same change that moves CI to a newer npm; dashboard/scripts/check-npm-pin.mjs fails the dashboard build 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."
]
},
{
"description": "A major update always waits for a person. automerge false only stops Renovate; the hive merges trusted-bot pull requests itself, so label the update needs-owner-merge (the hive's auto_merge.human_merge_labels default): the hive never merges a PR with it, and only the owner's merge click lands it. hold was used first (#1233) but a held PR merges as soon as someone removes hold. The hive merged #1229 and #1230 before any label, and #1230 broke the dashboard publish. Last matching rule wins, so keep this rule last.",
"matchUpdateTypes": ["major"],
Expand Down