Skip to content

fix(ci): unbreak the pipeline — lockfile, lint, coverage, permissions - #492

Merged
thinkclay merged 1 commit into
mainfrom
claude/tests-deps-upgrade-plan-f098b5
Jul 30, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/tests-deps-upgrade-plan-f098b5

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Main has been fully red since this morning and production has not shipped —
Deploy Web App was failing. Almost none of it was a real test failure; the unit
suites pass (787 green). Five distinct causes, fixed together because fixing any one
alone still leaves the run red, so there'd be no observable green to build on.

What was broken

Cause Root Blast radius
ERR_PNPM_ENOENT ... rename '…/bundle-require/node_modules/esbuild' Three esbuild versions (0.25.12 / 0.27.7 / 0.28.0). With node-linker=hoisted one hoists and [email protected]([email protected]) must nest — that nested rename is what failed Release, Monorepo Integrity, Lighthouse, E2E — every cold install
pnpm dedupe --check non-zero (#490) Lockfile never deduped Monorepo Integrity
biome noUnusedVariables notificationsData in DrawerLayout, left by 3237665 (#420). Plus one any in getUserIdByEmail whose deno-lint-ignore doesn't suppress Biome Code Quality and Run Tests
Unit tests red though every test passed apps/scaffald demanded 80% coverage against a measured 37/26/33/38 Scaffald Tests
Resource not accessible by integration Org-migration fallout: the default workflow token grants contents+packages only, not actions Deploy Web App + Dependabot automerge
EXPO_PUBLIC_SUPABASE_URL is not set during expo export lighthouse-ci.yml had no env: Lighthouse, ~20 min burned per PR, always died here

Notable choices

  • esbuild pinned to 0.28.0 rather than removing ignoredBuiltDependencies. The
    CVE-floor key esbuild@<=0.24.2 is a different key and stays.
  • getUserIdByEmail got a structural type, not a second suppression. The existing
    comment says "SupabaseClient generics vary per suite" — a structural type is precisely
    what that calls for, and every instantiation satisfies it.
  • Coverage locked ~3 points under the measured baseline, not lowered to a round
    number. 80-vs-37 detected nothing; 35/24/30/35 detects regression while leaving room
    for a new uncovered file. Comment records the date and the numbers.
  • permissions: blocks are the deploy unblock. No workflow in the repo had one. A
    workflow may request actions: read above the org default, so this needs no org change.
  • Also dropped the dead develop/dev branch triggers and three pnpm-workspace.yaml
    globs (insurance, compliance, tasks) pointing at directories that don't exist.

Lockfile review

The 6323-line lockfile diff is unreviewable by eye; the cold-install gate is the review.

before:  [email protected]  [email protected]  [email protected]
after:   [email protected]
nested node_modules/esbuild directories after install: none
pnpm dedupe --check: exit 0
net: -3711 lines

Verified locally, from cold

Gate Result
rm -rf node_modules && pnpm install --frozen-lockfile exit 0
pnpm dedupe --check exit 0
pnpm check lint 10/10, typecheck 12/12
pnpm exec nx run-many -t build 10/10
apps/scaffald && pnpm test:coverage exit 0
pnpm test:unit 787 passed

nx run-many -t build is in the gate deliberately: esbuild is in
ignoredBuiltDependencies, so its postinstall never runs and a passing install does
not prove a working build. It builds.

Still needs a human

Settings → General → Pull Requests → Allow auto-merge. allow_auto_merge is
false, so dependabot-automerge.yml 403s on every Dependabot PR regardless of this PR.

Not fixed here, deliberately

docs-site:build (in the packages/sdk submodule) is flaky under parallel run-many —
nx flags it itself; it passes in isolation and on retry. Pre-existing, untouched by this
change.

Two suites are hidden red and will not surface when CI goes green: #469 (packages/ui
vitest config points at a nonexistent path, ~460 tests never run) and #480 (14 Deno tRPC
files fail to load). Green here should not be read as "everything is tested".

🤖 Generated with Claude Code

Main has been fully red since this morning and production has not shipped.
Almost none of it was a real test failure; the unit suites pass. Five distinct
causes, fixed together because fixing any one alone still leaves the run red
and so gives no observable green to build on.

1. `pnpm install --frozen-lockfile` failed with ERR_PNPM_ENOENT renaming
   node_modules/bundle-require/node_modules/esbuild. The lockfile carried three
   esbuild versions (0.25.12, 0.27.7, 0.28.0); with node-linker=hoisted, one
   hoists and [email protected]([email protected]) has to nest, which is the
   rename that failed. Pinning esbuild to 0.28.0 collapses all three and leaves
   no nested copy. This killed Release, Monorepo Integrity, Lighthouse and E2E
   — every cold install.

2. `pnpm dedupe --check` was failing (#490). Same lever: dedupe after the pin
   drops the lockfile by 3711 net lines.

3. biome noUnusedVariables on scf-core: notificationsData in DrawerLayout was
   left behind by 3237665 (#420). Removed with its now-orphaned import.
   supabase:lint had one more error — an `any` in the getUserIdByEmail test
   helper whose deno-lint-ignore does not suppress Biome. Replaced with a
   structural type, which is what the comment's "generics vary per suite"
   actually calls for.

4. "Unit & Integration Tests" was red although every test passed:
   apps/scaffald demanded 80% coverage against a measured 37/26/33/38. A
   threshold that has never been met detects nothing. Locked to ~3 points under
   the real baseline so it detects regression instead.

5. nrwl/nx-set-shas and Dependabot automerge both 403'd with "Resource not
   accessible by integration" — org-migration fallout. The default workflow
   token grants contents+packages only, so workflows using nx-set-shas now
   request `actions: read` explicitly. This is what unblocks Deploy Web App.
   (allow_auto_merge is a repo setting and still needs flipping by hand.)

Lighthouse additionally died at "EXPO_PUBLIC_SUPABASE_URL is not set" during
expo export, before measuring anything, on every PR. Wired to the DEV_* secrets
and dropped the redundant `pnpm build` — web:build is the only build it audits.
Also removed the dead develop/dev branch triggers and the three workspace globs
(insurance, compliance, tasks) pointing at directories that do not exist.

Verified from cold: install --frozen-lockfile, dedupe --check, pnpm check
(lint 10/10, typecheck 12/12), nx run-many -t build (10/10), test:coverage, and
test:unit (787 passed).

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay force-pushed the claude/tests-deps-upgrade-plan-f098b5 branch from 0323125 to 435d832 Compare July 30, 2026 17:43
@thinkclay
thinkclay merged commit 34ce2c3 into main Jul 30, 2026
2 of 10 checks passed
@thinkclay
thinkclay deleted the claude/tests-deps-upgrade-plan-f098b5 branch July 30, 2026 18:02
thinkclay added a commit that referenced this pull request Jul 30, 2026
* fix(test): make the scf-core suites actually load and run

Six suites in scf-core were reporting zero tests or dying on the first render.
None of it was a bad assertion — four infrastructure faults, three of which had
nothing to do with the tests themselves.

1. expo ships raw TypeScript, not compiled JS: package.json points main/module
   at src/Expo.ts and build/ holds only .d.ts. So Expo.fx.tsx -> ./winter ->
   runtime.ts executes, and that file wires up Fast Refresh, HMR and the Metro
   message socket with bare CommonJS `require('./setupFastRefresh')` calls on
   .ts siblings. Vitest transforms the module to ESM but leaves the requires,
   and Node cannot resolve an extensionless .ts at runtime. Any test importing
   expo aborted before running.

   Stubbed at ./winter specifically. A require() left in transformed output is
   executed by Node and never reaches Vite's resolver — only the ESM import is
   interceptable, which is why aliasing the deeper modules silently did nothing.
   Nothing is lost: the winter polyfills (FormData, TextDecoder, URL, ...) are
   separate modules imported elsewhere; the index pulls in the runtime alone.

2. react-native-safe-area-context resolved to its raw src/ rather than its
   compiled build, so the TS-only `typeof` type query in SafeArea.types.ts
   reached Node as JS: "Unexpected token 'typeof'". Pinned to lib/module — the
   real module, not a mock, so behaviour is unchanged.

3. useBottomBarContext was missing from the @scaffald/ui mock. The real hook
   reads a context with a default and never throws, but vitest turns an absent
   export on a mocked module into a hard error, so every suite rendering a
   dashboard screen died.

4. profile-employment-left.test.tsx declared vi.mock("@scaffald/ui") three
   times. Only one registration survives per module path and the survivor
   exported useToast alone — hence `No "Stack" export`. The other two blocks
   (185 and 274 lines) were dead. Consolidated to one.

Plus: SafeAreaProvider needs seeded initialMetrics because jsdom never measures
a frame, and ApplicationWizard's nine renders had no QueryClientProvider.

  wizards (ipip/riasec/occupation)  0 tests ->  7 passed, 10 pre-existing skips
  ApplicationWizard                 9 failed -> 9 passed
  profile-employment-left          36 failed -> 40 passed
  ResultsRail                       0 tests ->  2 passed
  MapSearchInput, WorkerPreviewModal, ResumeImportWidget: green off the shared fixes

Four of the five files here are shared test infrastructure imported by every
suite in the repo, so the risk was regression elsewhere. Verified: pnpm test:unit
exit 0 across 6 projects, pnpm check exit 0 (lint 10/10, typecheck 12/12).

NOT un-excluding scf-core from affected:test/test:unit/prepush, which was the
original goal. A full run OOMs (SIGABRT) at both 4 GB and 8 GB — pool: "threads"
shares heap across 329 files and nothing is reclaimed between them. That is
pre-existing and structural; these fixes accelerate it only because three files
that used to abort for free now render real trees. Filed as #504. Un-excluding a
suite that cannot complete would trade an invisible problem for a permanently
red gate, which is the mistake #492 removed.

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(test): run scf-core on the forks pool so the suite can complete

The root config uses `pool: "threads"`, which shares one heap across every file.
Over this project's 333 test files nothing is reclaimed between them and the run
dies with a JS heap OOM (SIGABRT) at both 4 GB and 8 GB — no assertion fails,
the process simply runs out of memory. That is why scf-core is excluded from
every aggregate command: it could never finish.

Forks give each file its own process, so its heap is released on exit.

Verified by direct vitest invocation:

  vitest run --config packages/scf-core/vitest.config.ts --pool=forks --maxWorkers=2
  921 tests | 829 passed | 31 failed | 58 skipped
  333 files | 17 failed files

A real result instead of a crash, and the first time this suite has reported one.

Two caveats, both recorded in #504:

- The same run through the nx executor (`nx run scf-core:test`) had not finished
  after 11 minutes and was killed, so whether `@nx/vitest:test` honours the pool
  setting is NOT yet confirmed. This is safe to land regardless — scf-core is
  excluded from every CI path today — but it must be settled before the suite is
  un-excluded, since CI would invoke it through nx.

- 31 tests still fail for real. Biggest clusters are UserProfilePanel (18),
  MapSearchInput (7) and TeamForm (4). MapSearchInput passes when run in a small
  group and fails in the full run, which smells of cross-file state leakage
  rather than a broken assertion.

So scf-core stays in the exclusion lists for now. Runnable is the prerequisite;
green is what earns the gate.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant