fix(ci): guard fast-integ-tests to same-repo PRs - #6193
Conversation
The job failed at the checkout step on its first real run (it could never run on its own PR, since pull_request_target uses the base branch's workflow definition). actions/checkout refuses to place a fork's head commit on a runner in a pull_request_target job: Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. The refusal is correct. fast-integ-tests is the only job in this workflow that puts PR code on a runner, and that runner also assumes CI_AWS_ROLE_ARN, so a fork PR could edit conftest.py and read the credentials out. Every other job here either checks out the base ref only (detect-changes, for diffing) or has no checkout at all and hands PR code to CodeBuild via source-version-override (codestyle-doc-tests, unit-tests, integ-tests, and every job in pr-checks-master-v2.yml and fortress-scan.yml). Opting out with allow-unsafe-pr-checkout would make this repo the sole exception, so guard the job instead. Same-repo PRs stay covered: a branch here already requires push access, so checking it out grants its author nothing new. This is a stopgap, not the destination. Almost every PR to this repo is from a fork, so the suite is not currently a gate; moving it into CodeBuild alongside the others is the fix, and needs a project provisioned in the CDK that owns them. Recorded in the job comment and the suite README so the gap is not mistaken for coverage.
|
Claude finished @jam-jee's task in 1m 3s —— View job Review: guard
|
What this changes
Guards the
fast-integ-testsjob (added in #6176) to same-repo PRs. It is currentlyfailing at the checkout step on every fork PR, which is nearly every PR.
Why it fails
fast-integ-testscould never run on its own PR —pull_request_targetuses thebase branch's workflow definition — so #6176 merged without it having executed once.
Its first real run (PR #6192)
died at step 2 in 3 seconds, with steps 3–6 skipped:
The refusal is correct.
fast-integ-testswas the only job in this repo that putPR code on a runner, and that same runner assumes
CI_AWS_ROLE_ARNfor three hours.A fork PR could have edited
conftest.pyand read those credentials out.Every other job here already avoids this, in one of two ways:
detect-changes,ai-code-review.ymlcodestyle-doc-tests,unit-tests,integ-testssource-version-overridepr-checks-master-v2.yml,fortress-scan.ymlallow-unsafe-pr-checkout: trueis the one-line fix the error suggests. This PRdeliberately does not use it: on a public repo with an AWS role on the same runner
that is a live credential-exfiltration path, and the flag appears nowhere in this repo
today. Guarding the job keeps it from being the sole exception.
The change
Same-repo PRs stay covered — a branch in this repo already requires push access, so
checking it out grants its author nothing new. Verified against the real event
payloads: #6192 and #6176 (forks) skip; #6119 (same-repo) runs. If a fork has been
deleted,
head.repois null and the job skips, which fails in the safe direction.Nothing was being blocked by the failure, and nothing is blocked by the skip: required
checks on
masterare onlycollab-check,wait-for-approvalandCodeQL.This is a stopgap, and the README says so
59 of the last 60 merged PRs came from forks, so after this change the suite runs on
roughly 2% of PRs — a local signal, not a gate. That is recorded in both the job
comment and the suite README rather than left to read as coverage, because a skipped
job shows green.
The actual fix is to run the suite where the other three test jobs run PR code —
inside CodeBuild via
source-version-override, which never exposes the runner's tokenor secrets to it. That needs a
sagemaker-python-sdk-ci-sagemaker-train-fast-integ-testsproject provisioned in the CDK that owns the existing ones; there are no in-repo
buildspecs, so it cannot land from this repo alone.
Worth a second opinion from whoever owns the buildspecs
47 deep tests across 20 files carry
gpu_intensive, but the only in-repo-m "not gpu_intensive"is insidefast-integ-testsitself;tox.inipasses pytestthrough unfiltered. Whether the deep CodeBuild gate actually deselects those tests
depends on its external buildspec. If it does, the gate has lost that coverage while
the shallow replacement is not running on fork PRs — the combination is what to check.
Testing
if:resolves to a single valid expression