fix(ci): restore fork-safe token fallback on the CI timing-report job - #66659
fix(ci): restore fork-safe token fallback on the CI timing-report job#66659Drexuxux wants to merge 1 commit into
Conversation
NousResearch#66373 swapped `GITHUB_TOKEN` → `AUTOFIX_BOT_PAT` across the workflows; that PAT is empty on fork PRs (forks get no repo secrets). 1e01a4b restored the `|| github.token` fallback for detect-changes / lint / supply-chain, but the `ci-timings` job was missed — its "Collect timings" step still passed a bare `GITHUB_TOKEN: ${{ secrets.AUTOFIX_BOT_PAT }}`. So on every fork PR the timing-report step received an empty `GITHUB_TOKEN` and `timings_report.py` crashed at `expect_env("GITHUB_TOKEN")` with `ValueError: missing environment variable GITHUB_TOKEN`, reddening the PR — even though the job's own contract is "a missing report must never redden the PR" (it already exits 0 on `TimingsUnavailable`). Two-layer fix: - ci.yml: add the `|| github.token` fallback so the observability job gets the run's read-only token on fork PRs (mirrors the detect-changes fallback), so timings are actually collected. - timings_report.py: treat an absent/empty `GITHUB_TOKEN` as `TimingsUnavailable` and route it through the existing graceful degraded path (placeholder report + summary, exit 0) instead of a hard crash — keeping the "never reddens the PR" invariant true regardless of how the token is wired. Tests: `tests/ci/test_timings_report.py` — an unset and an empty `GITHUB_TOKEN` both exit 0 with a placeholder report and no cached JSON; before the fix the run raised `ValueError`.
Related to merged #66577: that fork-token repair covered change classification and review gates; this PR independently covers the CI timings job and its missing-token degradation path. |
|
Independent confirmation from an affected fork contributor: I hit this on every PR I opened this week (#66646, #66653, #66656 all show the red "CI timing report" job with |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Fixes CI timing-report job for fork PRs with two-layer defense:
- Adds
|| github.tokenfallback inci.ymlso the job gets a read-only token on fork PRs - Makes
scripts/ci/timings_report.pytreat absent/emptyGITHUB_TOKENasTimingsUnavailable(graceful degraded path, exits 0) — keeps the "never reddens the PR" invariant - 2 new tests covering both unset and empty
GITHUB_TOKEN
Clean fix. LGTM.
Reviewed by Hermes Agent
|
Thanks for the focused fork-CI repair. Automated hermes-sweeper review found the requested behavior already on current
Closing as implemented on main. |
What
#66373 swapped
GITHUB_TOKEN→AUTOFIX_BOT_PATacross the workflows. That PAT is empty on fork PRs (forks get no repo secrets). 1e01a4b restored the|| github.tokenfallback for detect-changes / lint / supply-chain — but theci-timingsjob was missed: its Collect timings and generate report step still passed a bareGITHUB_TOKEN: ${{ secrets.AUTOFIX_BOT_PAT }}.So on every fork PR the step received an empty
GITHUB_TOKEN, andscripts/ci/timings_report.pycrashed atexpect_env("GITHUB_TOKEN"):reddening the PR — even though this job's own contract is "a missing report must never redden the PR" (it already exits 0 on
TimingsUnavailable).Fix
Two layers:
.github/workflows/ci.yml— add the|| github.tokenfallback so the observability job gets the run's read-only token on fork PRs (mirrors the detect-changes fallback), so timings are actually collected.scripts/ci/timings_report.py— treat an absent/emptyGITHUB_TOKENasTimingsUnavailableand route it through the existing graceful degraded path (placeholder report + summary,exit 0) instead of a hard crash — keeping the "never reddens the PR" invariant true regardless of how the token is wired.Tests
tests/ci/test_timings_report.py— an unset and an emptyGITHUB_TOKENboth exit 0 with a placeholder report and no cached JSON. Before the fix the run raisedValueError.