Skip to content

ci: run the edge-function type ratchet on every function, not just api - #929

Merged
thinkclay merged 1 commit into
mainfrom
fix/edge-fn-ratchet-trigger
Sep 27, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/edge-fn-ratchet-trigger

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

#924 added a ratchet that type-checks all 26 edge functions and claimed 12 of them were "held at zero". That was only true for PRs that also happened to touch functions/api/**.

The step lived in api-tests.yml, which is path-filtered:

paths:
  - 'packages/supabase/functions/api/**'
  - 'packages/supabase/migrations/**'
  …

So a new type error in notify-publish, trpc, or any of the other 24 never ran the check meant to catch it.

#927 demonstrated it

That PR changed functions/stripe-webhook/ specifically to make it type-check for the first time, went green, and the ratchet never fired. I verified it by hand instead — which is exactly the manual step a gate exists to remove.

This is the same class of defect the ratchet was built to fix: a check that cannot fail on the thing it guards. It just moved from continue-on-error: true to a path filter.

The fix

Moved to ci.yml, hung off the existing gate job with a new edge_fn filter:

edge_fn:
  - 'packages/supabase/functions/**'
  - 'packages/supabase/package.json'
  - 'scripts/check-edge-fn-types.mjs'
  - '.github/workflows/ci.yml'

ci.yml runs on every PR, so the filter decides rather than the workflow's trigger — which is the property the old placement lacked.

Kept as its own job rather than folded into an existing one: it needs deno, which nothing else in ci.yml does, and it should skip cleanly when no function changed. No pnpm install — the script imports only node: builtins.

Removed from api-tests.yml along with the Node setup that existed solely for it. That job goes back to what its name says: linting and formatting the REST API code.

Why not just widen api-tests.yml's paths

Because that workflow's test job boots a full Supabase stack, and widening the filter would run it for every edge-function change. Actions minutes are capped org-wide at 2,000/month here, and the ratchet is a 15-second check that needs none of that.

Verification

  • Both workflow files parse as valid YAML.
  • node scripts/check-edge-fn-types.mjs → within baseline, 380 total, stripe-webhook 0.
  • pnpm prepush green.
  • The real proof is this PR itself: it touches .github/workflows/ci.yml, which the new edge_fn filter includes, so Edge function types should appear in its own checks. If it doesn't, the fix is wrong and I'll say so.

🤖 Generated with Claude Code

#924 added a ratchet that type-checks all 26 edge functions and claimed 12 of
them were "held at zero". That was only true for PRs that also happened to
touch `functions/api/**`.

The step lived in api-tests.yml, which is path-filtered:

    paths:
      - 'packages/supabase/functions/api/**'
      - 'packages/supabase/migrations/**'
      - ...

So a new type error in notify-publish, trpc or any of the other 24 never ran
the check that was supposed to catch it. #927 demonstrated it: that PR changed
`functions/stripe-webhook/` specifically to make it type-check for the first
time, went green, and the ratchet never fired. I verified it by hand instead,
which is exactly the manual step a gate exists to remove.

Moved to ci.yml, hung off the existing `gate` job with a new `edge_fn` filter
covering `packages/supabase/functions/**`, `packages/supabase/package.json` and
the script itself. ci.yml runs on every PR, so the filter — not the workflow's
trigger — decides.

Kept as its own job rather than folded into an existing one: it needs deno,
which nothing else in ci.yml does, and it should be skippable when no function
changed. No pnpm install — the script imports only node: builtins.

Removed from api-tests.yml along with the Node setup that existed solely for
it. That job goes back to what its name says: linting and formatting the REST
API code.

This is the same class of defect the ratchet was built to fix — a check that
cannot fail on the thing it is meant to guard. It just moved from
`continue-on-error: true` to a path filter.

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

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit afd1744 into main Sep 27, 2026
15 checks passed
@thinkclay
thinkclay deleted the fix/edge-fn-ratchet-trigger branch September 27, 2026 00:25
thinkclay added a commit that referenced this pull request Oct 2, 2026
)

#935 and #936 sat three days showing "no checks reported on the branch" — the
symptom of a run held at `action_required`, which reads as "CI never ran"
rather than "CI is blocked". Clearing them by hand is the last manual step in
the Dependabot queue.

## It is not a Dependabot policy, which is what I assumed

Dependabot's own push runs CI fine. Measured on #935:

    f89aab3  dependabot's push          -> CI success
    d0c2f52  chore(deps): pnpm dedupe   -> CI action_required

Only the run for OUR dedupe commit is held. dependabot-dedupe.yml pushing a
second commit raises a `synchronize` run attributed to a bot actor, and GitHub
holds that for approval. So the thing to automate is narrow and well
understood, rather than a blanket "approve Dependabot".

The held run is wanted — a merge takes the dedupe commit's SHA, so CI has to
pass on THAT commit and not just the one beneath it. Only the approving should
stop being manual.

## Why workflow_run and not a schedule

Actions minutes are capped at 2,000/month org-wide for private repos (#375). A
sweeper polling every 20 minutes is ~2,160 billed minutes a month on its own —
more than the CI it exists to unblock, since GitHub bills a minimum of one
minute per job. Hanging off the dedupe workflow means this runs only when
Dependabot actually opens PRs: a handful of times a week, seconds each.

It polls for up to ~2 minutes because dedupe pushes near the end of its own
run, so the held run may not exist yet when this fires. If dedupe found nothing
to push there is no held run and it exits quietly on the first pass.

## Scope, deliberately narrow

`if: startsWith(github.event.workflow_run.head_branch, 'dependabot/')`. This
cannot approve a held run on a human branch. That is the property that makes
removing a manual gate defensible: what gets approved is a lockfile dedupe of a
bot's own branch, on which CI has already passed one commit earlier.

## What is NOT verified

Whether GITHUB_TOKEN has authority to approve a run here. The endpoint works —
I approved four by hand with my own token — but that proves the call, not the
token. There are no held runs to test against now that #935 and #936 are
merged.

So a refusal fails the job loudly and names the fix (a PAT with `actions:
write`) rather than passing with nothing approved. A silent no-op approver
would be the same defect class as the `continue-on-error: true` in #921 and the
path filter in #929: a gate that cannot do its job and does not say so.

Monday's Dependabot wave is the real test.

Co-authored-by: Claude Opus 5 <[email protected]>
thinkclay added a commit that referenced this pull request Oct 2, 2026
…gger the job it breaks (#950)

#936 bumped the Supabase CLI 2.117.0 -> 2.118.0. 2.118.0 includes
"rewrite managed local stack runtime" (supabase/cli#6440), and after it the
api-tests step that runs `supabase gen types typescript --local` fails:

    no owned schemas found in /tmp/types-fresh.ts — the format changed,
    or the file is empty

scripts/types-owned-schemas.mjs matches top-level schema blocks with
`/^ {2}(\w+): \{$/`, so a change in the generated file's shape breaks it.

## How this was established

It surfaced on #949, an unrelated id-verification change, and read as that
PR's fault. Two runs failed identically at the same step. A control re-run of
main's own api-tests at 21b4dd3 — which predates the bump — passed, which
first looked like it convicted #949.

It did not: that control commit is nine commits behind, and the gap contains
#936. Nothing schema-related changed in between, and a TypeScript route file
cannot affect a generator that introspects the database.

## Why nobody saw it on main

api-tests is path-filtered to `functions/api/**`, migrations, `types.ts` and a
couple of scripts. A CLI bump touches none of those, so the job has not run on
main since 2026-10-01 — before the bump. main has been broken and silent.

So the filter is widened: `pnpm-workspace.yaml`, `pnpm-lock.yaml` and
`scripts/types-owned-schemas.mjs` now trigger it. The job shells out to the
Supabase CLI; a change to the pin that selects that CLI is a change to the job.

This is the same shape as #929 — a gate that could not run on the thing it
guards — and the third time this session a path filter has hidden a broken
check from itself. The cost is CI minutes on dependency PRs, which is the
trade I declined in #929 for a cheap ratchet and accept here for a job that
boots a full stack and is the only HTTP coverage the api has.

## Pin, not adapt

Reverting is the conservative move and restores green now. Whether 2.118's
`gen types` output is a deliberate format change or a side effect of the stack
rewrite wants its own look, with the job actually run against it — the comment
at the pin says so.

Not independently reproduced locally: no stack was running and this checkout
has 2.116.0, so the mechanism is inferred from the release contents, the error
text and the control. If this PR goes green, that is the proof — it touches
`pnpm-workspace.yaml`, which the widened filter now makes run api-tests.

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