|
| 1 | +name: Lockfile Dedupe |
| 2 | + |
| 3 | +# objectui#8333 — the committed `pnpm-lock.yaml` must already be DEDUPED, i.e. |
| 4 | +# `pnpm dedupe` on it may not collapse anything. The mechanism, what it catches |
| 5 | +# and what its green does NOT mean are documented at length in |
| 6 | +# `scripts/check-lockfile-dedupe.mjs`. |
| 7 | +# |
| 8 | +# ── Why this exists next to `lockfile-integrity.yml` rather than inside it ──── |
| 9 | +# |
| 10 | +# They answer different questions. objectui#8326's gate reports a DELTA against |
| 11 | +# the merge base — "did THIS change duplicate something?" — and needs two |
| 12 | +# revisions of one file to do it. This one reports a PROPERTY of a single tree — |
| 13 | +# "would `pnpm dedupe` still have work to do here?" — and needs no base at all, |
| 14 | +# but does need pnpm and the registry. Different subject, different cost, |
| 15 | +# different failure modes, so they are separate jobs and each stays readable. |
| 16 | +# |
| 17 | +# ── Why it is path-filtered ────────────────────────────────────────────────── |
| 18 | +# |
| 19 | +# Its subject is one file. A pull request that does not touch `pnpm-lock.yaml` |
| 20 | +# cannot change whether that lockfile is deduped, so the filter costs no |
| 21 | +# coverage. A manifest edit that WOULD change the resolution cannot reach `main` |
| 22 | +# without moving the lockfile either, because `ci.yml` installs with |
| 23 | +# `--frozen-lockfile` and fails first. Same argument shape as its neighbour. |
| 24 | +# |
| 25 | +# The filter also lists this gate's RUNTIME CLOSURE — the files the job actually |
| 26 | +# executes — which is this repository's convention for a path-filtered gate |
| 27 | +# (`performance-budget.yml` states it at length): without that, a change to the |
| 28 | +# checker itself ships having never run once, and the wiring bug then surfaces on |
| 29 | +# somebody else's next lockfile PR, reading to them as a problem of their own. |
| 30 | +# |
| 31 | +# ⚠️ The filter is also what makes it UNREQUIRABLE: objectui#3523's rule, |
| 32 | +# enforced by `scripts/__tests__/dependabot-merge-gate.test.ts`, is that a |
| 33 | +# REQUIRED context must come from a workflow whose `pull_request` trigger has no |
| 34 | +# path filter. It is enrolled as an OPTIONAL context instead — blocking when it |
| 35 | +# runs, not waited for when the filter keeps it out. `Bundle Analysis` is |
| 36 | +# enrolled on exactly those terms and its filter also includes `pnpm-lock.yaml`. |
| 37 | +# |
| 38 | +# ── ⚠️ It IS a blocking context, and that is a decision, not a default ──────── |
| 39 | +# |
| 40 | +# `scripts/dependabot-merge-gate.mjs` classifies `Lockfile Dedupe Check` in |
| 41 | +# `OPTIONAL_CONTEXTS`, so a red here stops a Dependabot auto-merge. Its |
| 42 | +# neighbour `Lockfile Integrity Check` is deliberately NOT enrolled, and that |
| 43 | +# difference is intentional rather than an inconsistency to tidy away: |
| 44 | +# |
| 45 | +# * #8326's gate reports a duplication and leaves the ANSWER open — re-lock, |
| 46 | +# pin, or accept the split — so enrolling it would block pull requests on a |
| 47 | +# judgement call with no mechanical remedy. Its header reserves that for the |
| 48 | +# maintainer, and ⛔ this file does not touch that reservation. |
| 49 | +# * This gate has exactly ONE remedy and pnpm prints it: run `pnpm dedupe` and |
| 50 | +# commit the lockfile. No declaration, range or override changes. There is no |
| 51 | +# judgement call to reserve. |
| 52 | +# |
| 53 | +# The cost of enrolling it was measured before it was taken, and it is near zero |
| 54 | +# TODAY only because objectui#9215 landed first: on `main` after that collapse |
| 55 | +# this gate is green, so nothing currently-mergeable is blocked by it. On `main` |
| 56 | +# BEFORE it, the same command reds. ⇒ what this gate really defends is that |
| 57 | +# objectui#9215's paydown does not silently accrue again — which is the whole |
| 58 | +# reason the bump PR's `pnpm dedupe` is cheap enough to require at all. |
| 59 | +# |
| 60 | +# ⇒ ⚠️ If this ever needs to stop blocking, the flip is one line: move |
| 61 | +# `Lockfile Dedupe Check` from `OPTIONAL_CONTEXTS` to `NOT_A_GATE` in |
| 62 | +# `scripts/dependabot-merge-gate.mjs`. The partition test keeps either state |
| 63 | +# honest; ⛔ deleting the name from both buckets fails that test rather than |
| 64 | +# quietly shrinking the gate. |
| 65 | +# |
| 66 | +# ── No `merge_group` trigger ───────────────────────────────────────────────── |
| 67 | +# |
| 68 | +# Deliberate, and the same shape as `lockfile-integrity.yml` and |
| 69 | +# `performance-budget.yml`: under objectui#3523 a required context that does not |
| 70 | +# report on a queue build stalls the queue until the ruleset timeout fails it, so |
| 71 | +# a path-filtered, non-required gate must not subscribe one. |
| 72 | + |
| 73 | +on: |
| 74 | + pull_request: |
| 75 | + branches: [main, develop] |
| 76 | + paths: |
| 77 | + - 'pnpm-lock.yaml' |
| 78 | + # This gate's runtime closure — the files this job executes. An edit to any |
| 79 | + # of them must be able to red this gate on its OWN pull request. |
| 80 | + - '.github/workflows/lockfile-dedupe.yml' |
| 81 | + - 'scripts/check-lockfile-dedupe.mjs' |
| 82 | + # `isEntrypoint` decides whether `main()` runs at all, so a regression in it |
| 83 | + # makes this checker exit 0 having measured nothing — the exact silent-green |
| 84 | + # failure the rest of this gate exists to prevent. Same reason |
| 85 | + # `performance-budget.yml` and `half-state-patrol.yml` list it. |
| 86 | + - 'scripts/invoked-as.mjs' |
| 87 | + # The toolchain step this job runs before pnpm is on PATH. |
| 88 | + - 'scripts/ci-setup-pnpm.sh' |
| 89 | + workflow_dispatch: |
| 90 | + |
| 91 | +concurrency: |
| 92 | + group: lockfile-dedupe-${{ github.event.pull_request.number || github.ref }} |
| 93 | + cancel-in-progress: true |
| 94 | + |
| 95 | +permissions: |
| 96 | + contents: read |
| 97 | + |
| 98 | +jobs: |
| 99 | + lockfile-dedupe: |
| 100 | + name: Lockfile Dedupe Check |
| 101 | + runs-on: ubuntu-latest |
| 102 | + |
| 103 | + # ── The job ceiling, DERIVED FOR THIS JOB ──────────────────────────────── |
| 104 | + # |
| 105 | + # ⛔ NOT inherited from `lockfile-integrity.yml`'s 5 or `ci.yml`'s ladder — |
| 106 | + # objectui#7048 fences exactly that. The arithmetic below is this job's own, |
| 107 | + # and its weakness is stated rather than hidden. |
| 108 | + # |
| 109 | + # - Population: `pnpm dedupe --check` on a clean `origin/main` worktree, |
| 110 | + # n=3 consecutive runs, pnpm 10.31.0 / Node 22.22.2, WARM pnpm metadata |
| 111 | + # cache, on a developer box and not a runner: 22.8s / 22.9s / 23.2s, all |
| 112 | + # exit 0. Spread 0.4s, so the command itself is not variable. |
| 113 | + # - ⚠️ That population is the wrong one for a ceiling and is known to be: |
| 114 | + # this workflow has no run history yet, and a runner starts with a COLD |
| 115 | + # metadata cache, which is the dominant term. So the max is not measured |
| 116 | + # but BOUNDED, pessimistically, at 5 minutes for checkout + Node + the |
| 117 | + # Corepack fetch + a cold resolve of ~1,767 identities. |
| 118 | + # |
| 119 | + # Ceiling = the smallest round number that is both >= 3x that bound (15min) |
| 120 | + # and >= bound + 15min (20min); the second leg binds => 20. |
| 121 | + # |
| 122 | + # ⚠️ Re-derive this from real runs once this workflow has a history — the |
| 123 | + # instrument is the Actions jobs endpoint (`completed_at` minus |
| 124 | + # `started_at`, per job, never the run total), the same one |
| 125 | + # `performance-budget.yml` names. ⛔ Do not copy the number above forward as |
| 126 | + # if it were a measurement of this job in CI; it is a bound on one. |
| 127 | + timeout-minutes: 20 |
| 128 | + |
| 129 | + steps: |
| 130 | + # No `fetch-depth: 0` here, unlike its neighbour: this gate's subject is a |
| 131 | + # single tree, not a delta, so it needs no merge base and no history. |
| 132 | + - name: Checkout code |
| 133 | + uses: actions/checkout@v7 |
| 134 | + |
| 135 | + - name: Setup Node.js |
| 136 | + uses: actions/setup-node@v7 |
| 137 | + with: |
| 138 | + node-version: '22.x' |
| 139 | + # No `cache: 'pnpm'` — that action's store probe shells out to pnpm |
| 140 | + # before the step below has put it on PATH (objectui#8099 documents |
| 141 | + # that exact ordering trap), and this job runs no `pnpm install`, so |
| 142 | + # there is no node_modules for a cache to pay for. |
| 143 | + |
| 144 | + - name: Enable Corepack and download the pinned pnpm |
| 145 | + run: bash scripts/ci-setup-pnpm.sh |
| 146 | + |
| 147 | + - name: Verify pnpm version |
| 148 | + run: pnpm --version |
| 149 | + |
| 150 | + # The checker's own cases, before the checker is trusted to judge anything. |
| 151 | + - name: Self-test the checker |
| 152 | + run: node scripts/check-lockfile-dedupe.mjs --self-test |
| 153 | + |
| 154 | + # No `pnpm install`: `pnpm dedupe --check` resolves and reports without |
| 155 | + # writing a lockfile or a node_modules tree (verified on objectui#8333 — |
| 156 | + # the lockfile's sha256 is unchanged across repeated runs). |
| 157 | + - name: Check the committed lockfile is deduped |
| 158 | + run: node scripts/check-lockfile-dedupe.mjs |
0 commit comments