Skip to content

fix(ci): skip self-hosted jobs for pull requests from forks - #2645

Merged
inureyes merged 5 commits into
mainfrom
fix/issue-2638-fork-guards-self-hosted
Oct 26, 2026
Merged

inureyes merged 5 commits into
mainfrom
fix/issue-2638-fork-guards-self-hosted

Conversation

@inureyes

@inureyes inureyes commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

github.repository is the base repository on a pull_request event, so it is true for fork PRs: the eight self-hosted jobs ran fork-controlled build.rs, scripts/iree/setup-cuda.sh, scripts/webui/*.py and pnpm install on the shared runner as its uid. Each now also requires github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository, the same shape as pipeline-parallel-ci.yml, ANDed before the existing path and ci:full conditions, so the label cannot opt a fork PR in. A deleted head repository yields a null full_name, which compares unequal, so the jobs skip (fails closed).

Guarded jobs: clippy, cpu-link, webui-installed-artifact, xla-compile, xla-link, cuda-sm70-compile, cuda-blockfloat (all GB10) and rocm-build (self-hosted, rocm-gfx1151, still gated on vars.ROCM_CI_ENABLED). A YAML-parser sweep of ci.yml found no self-hosted jobs beyond the issue's list. Across the other PR-triggered workflows, the only self-hosted job is three-host-real-model in pipeline-parallel-ci.yml, which already carries the head-repo guard; python.yml runs on hosted runners only.

Needs analysis: every guarded job depends only on the hosted changes job, no job depends on a guarded job, and ci.yml has no if: always() aggregate job, so skipping the guarded jobs on fork PRs cascades nowhere. Hosted jobs stay unguarded and still run on fork PRs.

Other changes:

  • rocm-ci-status (hosted, advisory) now emits a warning and exits 0 on a fork PR instead of saying the ROCm job is the authority. The event name and head and base repository reach it through env:, never through ${{ }} inside the script.
  • self-hosted-gate-advisory now says ci:full applies to same-repository PRs only.
  • The clippy comment is rewritten to describe both guards, their limit, and the remaining exposure; cpu-link points to it.
  • CONTRIBUTING.md gains one sentence: self-hosted jobs never run for a fork PR, and ci:full does not change that.

Limits and remaining exposure

The guards bind a fork PR that leaves the workflow alone. They do not bind a hostile one: a pull_request run takes its workflow files from the PR's merge commit, so a fork PR that deletes these if: lines or adds its own runs-on: GB10 job is held back only by the repository's Actions fork-PR approval policy (first_time_contributors, which stops holding a contributor's PRs once one of their contributions has merged). Nothing inside ci.yml can close that. Recommendation for a repository admin: switch the policy to all_external_contributors, and read a fork PR's .github/workflows/** diff before approving its run. The clippy comment records this.

Acceptance item 3 is documented, not enforced: same-repository PRs (authors with write access) still run as the runner's uid, and the per-job $HOME/.cargo-target/mlxcel-*-ci directories are kept apart from the release build's mlxcel-cuda-* directories by naming convention only, with rustup and ~/.cargo/bin shared outright.

Guard truth table

Event github.event.pull_request head repo vs base Guard Result
pull_request, same repo set equal true runs (subject to the path and ci:full conditions)
pull_request, fork set differs false skipped
pull_request, deleted fork set, head repo null differs false skipped
push to main null n/a true runs
workflow_dispatch null n/a true runs (not a ci.yml trigger today)
schedule null n/a true runs (not a ci.yml trigger today)

Test plan

  • yaml.safe_load on ci.yml
  • Per-job check that every job whose runs-on names GB10 or self-hosted carries both event_name != 'pull_request' and the head-repo comparison: prints OK for all eight
  • actionlint 1.7.7 with .github/actionlint.yaml on ci.yml: no findings, same as main
  • No real fork PR was opened; correctness is by reading the expressions

Closes #2638

@inureyes inureyes added status:review Under review type:security Security vulnerability or fix priority:medium Medium priority labels Oct 26, 2026
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Skip every self-hosted job in ci.yml for pull requests opened from a fork, while hosted jobs still run on fork PRs.

Findings Addressed

  • Remaining-exposure sentence in the clippy comment was ambiguous about what is shared versus separated; rewritten (LOW, 947911b)
  • clippy comment listed only build.rs and scripts/iree/** as fork-author code; now also names scripts/webui/** and pnpm install (LOW, 947911b)
  • self-hosted-gate-advisory comment said every self-hosted job honours ci:full; now scoped to same-repository PRs (LOW, 947911b)

Remaining Items

  • The self-hosted-gate-advisory warning text still tells a fork PR to add ci:full, which no longer runs the self-hosted jobs there (LOW), left as is because the brief keeps hosted jobs unchanged apart from rocm-ci-status

Verification

  • All stated requirements implemented: all eight self-hosted jobs carry the guard, ANDed before the path and ci:full clause; a sweep of every PR-triggered workflow found no other self-hosted job without it
  • Guard logic: same-repo PR runs, fork PR skipped (also when the head repo is deleted, since a null full_name is unequal), push runs; no job needs a guarded job, so nothing cascades
  • rocm-ci-status reads event and repo names from env: only and stays advisory (exit 0)
  • No placeholder code; no unintended structural changes
  • yaml.safe_load, the per-job guard check and actionlint pass

@inureyes

Copy link
Copy Markdown
Member Author

Security and performance review

No CRITICAL findings. One HIGH finding, fixed in 4f5beac (comment-only). One LOW finding left open.

HIGH, fixed: the clippy comment overstated what the guards stop. It said fork-author code never runs on the shared runner "whatever the Actions approval policy says". This repository is public, and a pull_request run takes its workflow files from the PR's merge commit, so a fork PR can delete the if: or add its own runs-on: GB10 job. Only the fork-PR approval policy holds that back, and the REST API reports it as first_time_contributors, which stops holding a contributor's fork PRs once one of their contributions has merged. The comment now limits the guard's claim to fork PRs that leave the workflow alone, names the approval policy as the barrier against a hostile fork PR, and asks reviewers to read a fork PR's .github/workflows/** diff before approving its run. The PR body's "Remaining exposure" paragraph should say the same.

Recommendation (repository setting, not changed here): switch the fork-PR approval policy to all_external_contributors. It is the only control that holds a fork PR that edits the workflow.

LOW, open: self-hosted-gate-advisory tells every workflow-touching PR to add ci:full, which no longer runs anything on a fork PR.

Checked and clean:

  • The guard expression is ANDed ahead of the ci:full clause in all eight self-hosted jobs, and the label cannot bypass it.
  • A deleted fork has a null head repo, which compares unequal, so those jobs skip (fails closed).
  • ci.yml has only push and pull_request triggers, with no pull_request_target.
  • rocm-ci-status passes HEAD_REPO, BASE_REPO and EVENT_NAME through env: only, and its run: has no ${{ }}. The only other ${{ }} inside run: blocks is github.sha.
  • pipeline-parallel-ci.yml (guarded) and python.yml (hosted) are the only other PR-triggered workflows. nightly-verify.yml, release.yml and update_homebrew_formula.yml have no PR trigger.
  • No performance impact: the change only adds if: conditions and one shell branch.

YAML parse, the guard check script, and actionlint with the repository config all pass.

@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 26, 2026
inureyes added a commit that referenced this pull request Oct 26, 2026
Bilingual report on the head-repository fork guard for the eight self-hosted ci.yml jobs. It records the guard shape and its ordering before ci:full, the fail-closed case for a deleted fork, why skipping the jobs cascades nowhere, and the limit: a pull_request run takes workflow files from the PR merge commit, so a hostile fork PR that edits .github/workflows/** is held back only by the fork-PR approval policy (first_time_contributors today; all_external_contributors needs a repository admin). It also notes that same-repository PRs still share the runner uid with release inputs, and that a fork PR now merges without the self-hosted signal.

Refs #2638
@inureyes
inureyes marked this pull request as ready for review October 26, 2026 15:38
On a pull_request event `github.repository` is the base repository, so the existing repository guard is true for fork PRs and the eight self-hosted jobs executed fork-controlled build.rs, setup-cuda.sh and pnpm install on the shared runner as its uid.

Add `event_name != 'pull_request' || head.repo.full_name == github.repository` to clippy, cpu-link, webui-installed-artifact, xla-compile, xla-link, cuda-sm70-compile, cuda-blockfloat and rocm-build, mirroring pipeline-parallel-ci.yml. rocm-ci-status now warns instead of claiming the ROCm job is the authority on a fork PR. The clippy comment is rewritten to describe both guards and the remaining same-repo exposure.

Validated with yaml.safe_load, a per-job guard check and actionlint.

Refs #2638
The clippy comment's remaining-exposure sentence chained two clauses onto "by convention only" and read as if rustup and `~/.cargo/bin` were the separated pieces. It now states plainly that same-repository PRs still run as the runner's uid and that only directory naming keeps the per-job target directories apart from the release build's, while rustup and `~/.cargo/bin` are shared outright. The list of fork-author code the head-repo guard keeps off the runner now also names `scripts/webui/**` and `pnpm install`, which webui-installed-artifact runs.

The self-hosted-gate-advisory comment said every self-hosted job honours `ci:full`; it now says that holds on same-repository PRs only, since a fork PR skips them regardless.

Comment-only change. yaml.safe_load, the per-job guard check and actionlint pass.

Refs #2638
The rewritten `clippy` comment said fork-author code never runs on the shared runner whatever the Actions approval policy says. That is false for a public repository: a `pull_request` run takes its workflow files from the PR's merge commit, so a fork PR can delete the `if:` or add its own `runs-on: GB10` job, and only the fork-PR approval policy (currently `first_time_contributors`, verified via the REST API) holds it back. The previous comment named that policy as the real gate; the rewrite had dropped it.

The comment now limits the head-repo guard's claim to fork PRs that leave the workflow alone, names the approval policy as the barrier against a hostile one, notes that `all_external_contributors` would hold every fork PR, and asks reviewers to read a fork PR's workflow diff before approving its run. Comment-only; YAML parse, the guard check script and actionlint pass.

Refs #2638
…TRIBUTING

The self-hosted-gate-advisory warning told every workflow-touching PR to add the ci:full label to run the self-hosted jobs, but the head-repo guard is ANDed first, so on a fork PR the label runs nothing. The warning now states that the label applies to same-repository PRs only and that self-hosted jobs never run for fork PRs. CONTRIBUTING.md gets the same statement next to its ci:full description. Message text only, no job or step changes.

Validation: ci.yml parses as YAML, check_guards.py reports OK for all eight guarded jobs, actionlint prints nothing.

Refs #2638
Bilingual report on the head-repository fork guard for the eight self-hosted ci.yml jobs. It records the guard shape and its ordering before ci:full, the fail-closed case for a deleted fork, why skipping the jobs cascades nowhere, and the limit: a pull_request run takes workflow files from the PR merge commit, so a hostile fork PR that edits .github/workflows/** is held back only by the fork-PR approval policy (first_time_contributors today; all_external_contributors needs a repository admin). It also notes that same-repository PRs still share the runner uid with release inputs, and that a fork PR now merges without the self-hosted signal.

Refs #2638
@inureyes
inureyes force-pushed the fix/issue-2638-fork-guards-self-hosted branch from 2a85491 to bdd422d Compare October 26, 2026 15:38
@inureyes
inureyes merged commit edc2587 into main Oct 26, 2026
@inureyes
inureyes deleted the fix/issue-2638-fork-guards-self-hosted branch October 26, 2026 15:39
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority status:done Completed type:security Security vulnerability or fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ci): add fork guards to self-hosted GB10 jobs that execute fork PR code

1 participant