Run pull request code only inside a Modal Sandbox (#8170)
GitHub recently changed `actions/checkout` to reject fork pull request
checkouts by default in privileged `pull_request_target` workflows. This
protection was introduced in `actions/checkout` v7 and backported to
supported floating major versions, including `actions/checkout@v4`. As a
result, the current workflow's checkout of `${{
github.event.pull_request.head.sha }}` is now rejected for fork pull
requests.
Setting `allow-unsafe-pr-checkout: true` would restore the previous
behavior, but it would deliberately bypass this protection. A
`pull_request_target` workflow runs trusted default-branch code with
access to the base repository's token and secrets. Because this workflow
needs `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` to start GPU CI, the
code that handles those credentials must remain trusted code from
`master`; pull request code must not execute in the same GitHub runner
context.
Modal documents Sandboxes as secure containers for executing untrusted
code, including checking out a repository and running its test suite.
This change follows that model: GitHub runs only the trusted selector
and Modal controller, while the pull request is treated as data during
test selection. The controller passes only a validated public repository
name, exact commit SHA, and validated test selection to a Modal Sandbox.
The Sandbox receives no GitHub, Modal, or Hugging Face credentials, and
performs the candidate checkout, dependency installation, DeepSpeed
installation, and pytest execution itself.
---------
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>