Skip to content

fix(ci): skip the benchmark PR comment on forks, so fork PRs stop going red (#986) - #990

Merged
thinkclay merged 1 commit into
mainfrom
fix/benchmark-comment-fork-guard
Oct 5, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/benchmark-comment-fork-guard

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #986.

One if: on one step.

      - name: Comment Benchmark Results on PR
        if: github.event.pull_request.head.repo.full_name == github.repository

Why

A pull request from a fork gets a read-only GITHUB_TOKEN regardless of the permissions: pull-requests: write at the top of the workflow. So github.rest.issues.createComment throws

RequestError [HttpError]: Resource not accessible by integration
##[error]Unhandled error: HttpError: Resource not accessible by integration

and, with no guard and no continue-on-error, takes the whole benchmark job — and therefore REST API Tests — down with it. Every fork PR has been showing red for a step that only posts a comment.

#972 is the case that surfaced it: a four-line SQL seed from an outside contributor, Run API Tests green, workflow red. Step-level outcomes for the same job, fork versus same-repo:

step #972 (fork) #973 (same repo)
Start Supabase success success
Run Benchmarks success success
Upload Benchmark Results success success
Comment Benchmark Results on PR failure success
Stop Supabase success success

Exactly one step differs.

Skipped, not tolerated

continue-on-error: true would also stop it failing the build, but silently, and a step that is expected to be impossible on forks should say so. The numbers are preserved either way by Upload Benchmark Results, which runs unguarded.

The rest of #986's acceptance

No other pull_request workflow writes to the PR without a same-repo guard.

Swept, and this was the only one:

  • api-tests.yml:370 — the step fixed here, the sole unguarded GITHUB_TOKEN write.
  • dependabot-automerge.yml — pull_request_target, which runs with the base repo's token and full permissions, so the fork restriction does not apply.
  • apple-secret-rotate.yml — workflow_dispatch only, never PR-triggered.
  • codecov/codecov-action@v7 in the same workflow — already fail_ci_if_error: false, and it posts through the Codecov app rather than GITHUB_TOKEN.
  • treosh/lighthouse-ci-action@v12 — pull_request: types: [labeled], uploadArtifacts: true, no githubToken passed, so it posts nothing.

Verification

The workflow parses and the step is intact:

yaml parses OK
benchmark steps: 10
guard: "github.event.pull_request.head.repo.full_name == github.repository"
still uses: actions/github-script@v9

And the expression evaluated against both context shapes GitHub will hand it:

RUNS   same-repo PR (#973)
SKIPS  fork PR (#972)

pnpm prepush green.

What this cannot prove from inside this repo is the fork case itself — this PR is a same-repo branch, so its own run exercises the RUNS path. The SKIPS path gets its real test on the next fork contribution, and the failing step is the one being skipped, so the downside of being wrong is the status quo.

Not fixed here

#987 — the benchmark this step tries to post has never produced any output. deno bench dies on apps/ui-storybook-native/tsconfig.json ("jsx": "react-native", unsupported by deno), continue-on-error: true swallows it, and the comment posted to #973 was an empty code block. Fixing the guard stops fork PRs going red; it does not make the benchmark real. Deliberately separate: this is a one-line CI correctness fix, that one needs a decision about whether the job should exist.

🤖 Generated with Claude Code

…ng red (#986)

A pull request from a fork gets a read-only GITHUB_TOKEN regardless of
the `permissions: pull-requests: write` at the top of the workflow, so
`github.rest.issues.createComment` throws "Resource not accessible by
integration". With no guard and no continue-on-error that took the whole
benchmark job down, and with it REST API Tests — every fork PR red for a
step that only posts a comment.

#972 surfaced it: a four-line SQL seed from an outside contributor, its
own Run API Tests green, workflow red. Step outcomes for the same job on
a fork (#972) and a same-repo branch (#973) differ in exactly one place,
the comment step.

Skipped rather than tolerated. continue-on-error would also stop it
failing the build, but silently, and a step that cannot work on forks
should say so. Upload Benchmark Results keeps the figures either way.

Swept the other workflows for the same shape and this was the only one:
dependabot-automerge is pull_request_target (base-repo token),
apple-secret-rotate is workflow_dispatch, codecov already carries
fail_ci_if_error: false and posts through its own app, and the
lighthouse action is label-triggered with no githubToken.

Verified the expression against both context shapes GitHub will supply:
runs for a same-repo PR, skips for a fork. This branch is same-repo, so
its own run exercises only the runs path; the skip path gets its real
test on the next fork contribution, and the step being skipped is the
one that was failing.

Does not touch #987 — the benchmark this posts has never produced any
output, which needs its own decision.

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

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit 69bc3bc into main Oct 5, 2026
15 checks passed
@thinkclay
thinkclay deleted the fix/benchmark-comment-fork-guard branch October 5, 2026 20:29
thinkclay added a commit that referenced this pull request Oct 6, 2026
… if it does not (#987) (#995)

The job has reported success while producing nothing since roughly the
Expo 55->56 upgrade. The comment it left on #990 was an empty code
block. Three things had to be wrong for that:

1. No --config, so deno's config discovery walked out of
   packages/supabase into apps/ui-storybook-native/tsconfig.json and
   refused its `"jsx": "react-native"`. continue-on-error swallowed the
   exit code, and the `>` redirect still created an empty
   benchmark-results.txt — so the artifact and the comment were empty
   rather than missing, which is why nobody noticed. Any deno
   invocation from this repo without --config hits it; reproduced with
   a throwaway file in /tmp.

2. functions/api/__tests__/setup.ts:305 read `url.searchParams` after
   #932 replaced `new URL()` with `new URLSearchParams()` named
   `params`. completeMagicLinkAuth's "missing token or type" branch
   would have thrown a ReferenceError instead of logging and returning
   null.

3. It could not finish in the time the job had. Measured: 389s at the
   file's defaults, 180s with fewer requests per iteration — barely
   better, because Deno.bench keeps sampling until it is confident and
   simply took more samples — and 83s once the sample count itself is
   bounded with `n`. All four knobs are env-overridable; CI takes the
   bounded set, local runs keep the larger defaults. timeout-minutes
   10 -> 15, since 83s is on an M4 Pro and the job also pays for
   checkout, install and `supabase start`.

continue-on-error stays on the measurement: a slow benchmark should not
block a PR. But "it ran and was slow" and "it never ran" are different
states and only the first deserves to be quiet, so a new step fails the
job when the results file is empty or missing.

Verified with CI's env against a real stack: exit 0, 83s, 54 lines, all
five summary rows carrying real figures.

Not fixed here, and worth seeing before trusting the output: there are
no tRPC benchmarks at all (all five are REST, so the rest-vs-trpc name
has no other half), the run logs 30 auth 500s from the magic-link
fixture, and the summary's "2.6 s" is one iteration of 20 requests
rather than a per-request time.

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.

Every fork PR fails REST API Tests on a cosmetic step: the benchmark comment needs a same-repo guard

1 participant