Repository navigation
fix(ci): skip self-hosted jobs for pull requests from forks - #2645
Conversation
Implementation Review SummaryIntent
Findings Addressed
Remaining Items
Verification
|
Security and performance reviewNo CRITICAL findings. One HIGH finding, fixed in 4f5beac (comment-only). One LOW finding left open. HIGH, fixed: the Recommendation (repository setting, not changed here): switch the fork-PR approval policy to LOW, open: Checked and clean:
YAML parse, the guard check script, and actionlint with the repository config all pass. |
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
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
2a85491 to
bdd422d
Compare
Summary
github.repositoryis the base repository on apull_requestevent, so it is true for fork PRs: the eight self-hosted jobs ran fork-controlledbuild.rs,scripts/iree/setup-cuda.sh,scripts/webui/*.pyandpnpm installon the shared runner as its uid. Each now also requiresgithub.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository, the same shape aspipeline-parallel-ci.yml, ANDed before the existing path andci:fullconditions, so the label cannot opt a fork PR in. A deleted head repository yields a nullfull_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(allGB10) androcm-build(self-hosted, rocm-gfx1151, still gated onvars.ROCM_CI_ENABLED). A YAML-parser sweep ofci.ymlfound no self-hosted jobs beyond the issue's list. Across the other PR-triggered workflows, the only self-hosted job isthree-host-real-modelinpipeline-parallel-ci.yml, which already carries the head-repo guard;python.ymlruns on hosted runners only.Needs analysis: every guarded job depends only on the hosted
changesjob, no job depends on a guarded job, andci.ymlhas noif: 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 throughenv:, never through${{ }}inside the script.self-hosted-gate-advisorynow saysci:fullapplies to same-repository PRs only.clippycomment is rewritten to describe both guards, their limit, and the remaining exposure;cpu-linkpoints to it.CONTRIBUTING.mdgains one sentence: self-hosted jobs never run for a fork PR, andci:fulldoes 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_requestrun takes its workflow files from the PR's merge commit, so a fork PR that deletes theseif:lines or adds its ownruns-on: GB10job 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 insideci.ymlcan close that. Recommendation for a repository admin: switch the policy toall_external_contributors, and read a fork PR's.github/workflows/**diff before approving its run. Theclippycomment 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-*-cidirectories are kept apart from the release build'smlxcel-cuda-*directories by naming convention only, with rustup and~/.cargo/binshared outright.Guard truth table
github.event.pull_requestci:fullconditions)ci.ymltrigger today)ci.ymltrigger today)Test plan
yaml.safe_loadonci.ymlruns-onnamesGB10orself-hostedcarries bothevent_name != 'pull_request'and the head-repo comparison: prints OK for all eightactionlint1.7.7 with.github/actionlint.yamlonci.yml: no findings, same asmainCloses #2638