Repository navigation
ci(api): gate the build on HTTP api tests, via a list that may only grow (#914) - #920
Conversation
…row (#914) `packages/supabase/tests/routers/` holds the HTTP tests against the running `api` edge function — the only kind that catches "this endpoint answers 403 to everyone" (#900) or "this endpoint 500s on every request" (#901). Nothing ran them. No npm script named the directory; `prepush` load-probed it with `--filter '__prepush_load_probe__'`, which matches no test, so it checked the files parse and ran zero assertions; and `api-tests.yml` runs a different tree. The obvious fix — point CI at the directory — does not work. Measured against origin/main @ e675422 on a fresh local stack: functions/api/__tests__/{lib,routes} 344 passed, 72 failed tests/routers/ 122 passed, 177 failed Turning either on wholesale leaves the build permanently red, which is the state #412 already taught us gives no signal at all. That is why the two existing steps carry `continue-on-error` — a deliberate, documented decision I misread as carelessness when filing this. So: a ratchet. `tests/routers/GATED.txt` lists the files CI gates on. Eight files, 58 tests, verified passing both individually and together. The step that runs them has no `continue-on-error` — that is the point. The list may only grow; a file earns its way in by passing, and `GATED.txt` records what is excluded and why, including the two REST files blocked behind the cached auth fixture (#478) rather than by anything wrong with them. `prepush` runs the same list, but only when a local Supabase answers on :54321 — it stays infra-free for anyone without a stack, and says so rather than failing silently. Three smaller things in the same area: - The workflow's `paths` filter did not include `packages/supabase/tests/**`, so a PR touching only these tests would not have triggered the workflow that runs them. - The two muted steps still described the suite as mid-repair under #411, which is closed. Their comments now carry the current numbers and say what the remaining failures actually are. - `tests/README.md` gains a table saying which of the three test directories a new api test belongs in, since that split was documented nowhere. Verified: the gate fails the build when a listed file fails (exit 1), and when a listed file is missing (exit 1, with the path named). Both were run, not assumed — a gate that cannot go red is the thing this issue is about. Co-Authored-By: Claude Opus 5 <[email protected]>
The gate worked — it ran, it failed the build, which is what it is for. But it
failed for the wrong reason: 47 of 58 died on `supabaseKey is required`.
Two causes, both now fixed, and the second is the one worth keeping:
1. The three test steps passed `SUPABASE_ANON_KEY: ${{ secrets.X }}` with no
fallback. This repo has no such secret, so they received an EMPTY STRING.
The "Wait for API" and benchmark steps in the same file already fall back to
the well-known local demo keys; the test steps now do too.
2. `tests/shared/setup.ts` read them with `??`, which falls back on `undefined`
but not on `''`. So the empty string beat the committed default and every
suite died on a message that reads like a broken test rather than an unset
secret. It takes the first env var that is set to something non-blank now.
Reproduced CI's exact condition locally — `SUPABASE_ANON_KEY=""
SUPABASE_SERVICE_ROLE_KEY="" EXPO_PUBLIC_SUPABASE_ANON_KEY=""` — and ran the
gate's own `run:` block against it: fails without the fix, `58 passed, 0
failed` with it.
Worth noting what this says about the two report-only steps: they have been
running with empty keys too, so a share of their 72 failures is this, not
drift. Their numbers will move once this lands.
|
CI went red, and it is worth being precise about what that proved. The gate worked. It ran the 8 listed files, they failed, and it failed the build — no It failed for the wrong reason, though: 47 of 58 died on
I reproduced CI's exact condition locally rather than inferring it — One consequence worth flagging for review. The two report-only steps have been running with empty keys this whole time. So an unknown share of their "72 failures" is this, not assertion drift — the numbers I quoted in the PR description and in If the report-only suites come back substantially greener, that is a good argument for a follow-up that re-measures and moves more files into |
📊 Performance Benchmark Results |
|
Green, and the open question from my last comment is answered — I was wrong about it. I suggested a share of the report-only suites' 72 failures might be the empty-key bug rather than assertion drift. It was not. With the keys resolving:
One test. So those 71 are genuine drift, and there is no follow-up re-measurement to do — the numbers recorded in There is a useful side effect: CI's 345/71 now matches what I measured locally (344/72, one test apart), which means the two environments agree and the local measurement in Merging. |
Closes #914.
The problem, and why the obvious fix doesn't work
packages/supabase/tests/routers/holds the HTTP tests against the runningapiedge function — the only kind that catches "this endpoint answers 403 to everyone" (#900) or "this endpoint 500s on every request" (#901). Nothing ran them. No npm script named the directory;prepushload-probed it with--filter '__prepush_load_probe__', which matches no test, so it checked the files parse and ran zero assertions;api-tests.ymlruns a different tree entirely.Pointing CI at the directory does not work. Measured against
origin/main@e675422deon a fresh local stack:functions/api/__tests__/{lib,routes}tests/routers/Turning either on wholesale leaves the build permanently red — the state #412 already taught us gives no signal at all. I also had the
continue-on-errorwrong in the issue: it is a deliberate, documented decision, explained in the workflow with its history. I'd filed this without reading far enough down the file, and corrected that on the issue.A ratchet instead
tests/routers/GATED.txtlists the files CI gates on — 8 files, 58 tests, verified passing individually and together. The step that runs them has nocontinue-on-error. That is the point.The list may only grow. A file earns its way in by passing;
GATED.txtrecords what is excluded and why, including the two REST files (office-jobs-rest,office-settings-rest) that fail only withAuth setup is incomplete— blocked behind the cached token fixture thatauth.test.tscannot currently produce (magic-link auth fails locally), which is #478 territory rather than anything wrong with those tests.prepushruns the same list, but only when a local Supabase answers on:54321. It stays infra-free for anyone without a stack and says so:Three smaller things in the same area
pathsfilter did not includepackages/supabase/tests/**— so a PR touching only these tests would not have triggered the workflow that runs them.tests/README.mdgains a table saying which of the three test directories a new api test belongs in. That split was documented nowhere, which is part of howtests/routers/drifted into being unrun.Verification — the gate can actually go red
A gate that cannot fail is the thing this issue is about, so both paths were run, not assumed:
ok │ 58 passed │ 0 failed, exit 0::error file=…GATED.txt::Listed file not found: …prepush, stack upprepush, no stackThe step's
run:block was extracted from the YAML and executed verbatim underbashrather than eyeballed. That caught a real bug: the first version usedmapfile, which needs bash 4 — the bash on a contributor's macOS is 3.2, so it would have worked in CI and been unrunnable by hand. It is a portablewhile readloop now.What this deliberately does not do
It does not attempt the broad repair of either tree. ~250 tests fail across the two for assertion and fixture drift that predates this change; the auth fixture is the first blocker under a good slice of it. That is its own piece of work, and
GATED.txtis the mechanism for landing it incrementally rather than in one heroic PR.🤖 Generated with Claude Code