ci: split PR workflow so build runs from PR head#2396
Draft
doodlum wants to merge 1 commit into
Draft
Conversation
Previously pr-checks.yaml used pull_request_target, which always resolves workflow and action files from the base branch. Changes to .github/workflows/ or .github/actions/ could never be exercised by their own PR's CI — they only took effect after merge. Split into two workflows: pr-checks.yaml (pull_request trigger): - Resolves all files from the PR head — workflow/action changes are now actually tested in CI - Adds .github/workflows/** and .github/actions/** to the paths filter and build_ci changed-files group - Removes prerelease and comment jobs (moved to pr-privileged.yaml) - Adds save-pr-context job: uploads PR metadata + build outputs as artifacts for the downstream privileged workflow to consume pr-privileged.yaml (workflow_run trigger): - Runs from the base branch after PR: Checks completes — trusted code with write access, never executes fork code - Downloads pr-context artifact to get PR number, version, SHAs - Posts prerelease build and audit comment as before Security model is preserved: fork code compiles under pull_request with permissions: contents: read and no secrets; write operations (release posting, PR comments) happen in workflow_run from base.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pr-checks.yamlusedpull_request_target, which resolves workflow and action files from the base branch regardless of what the PR changes. This meant changes to.github/workflows/or.github/actions/could never be exercised by their own PR's CI — they silently passed all checks because nothing tested the new code.Solution
Split into two workflows following the GitHub recommended pattern for separating untrusted builds from privileged operations.
pr-checks.yaml→pull_requesttrigger.github/workflows/**and.github/actions/**are now actually exercised in PR CIpathsfilter and thebuild_cichanged-files group so they trigger a full rebuildprereleaseandfeature-audit-pr-commentjobs (moved below)save-pr-contextjob: uploads PR number, SHAs, version, and cpp-built flag as a short-lived artifact for the privileged workflow to consumepr-privileged.yaml→workflow_runtriggerPR: Checkscompletes, running from the base branch (trusted code)pr-contextanddist-artifactsartifacts via cross-run artifact downloadpull_request-triggered runs (github.event.workflow_run.event == 'pull_request')Security model
pull_request_targetjob (base branch workflow, fork code in WORKSPACE)pull_requestjob (PR head workflow, fork code in WORKSPACE)secrets:block)pull_request)pull_request_targetworkflow, elevated tokenworkflow_runfrom base branch, elevated tokenThe security properties are preserved. Fork PRs under
pull_requestreceive a read-onlyGITHUB_TOKENand zero repository secrets — GitHub enforces this unconditionally, regardless of what the fork's workflow file declares inpermissions:.Effect on existing PRs #2394 and #2395
Once this merges to
dev, the pending optimization PRs can have their CI actually test the workflow/action changes they introduce, rather than silently passing against the base branch's versions.Testing
This PR is self-referential: once it's non-draft, its own CI will run under the new
pull_requesttrigger and exercise the changes it introduces. Thepr-privileged.yamlwon't exist ondevyet until merge, so theworkflow_runportion will not fire — that's expected. Theprereleaseand audit comment behaviour can be verified on the first regular PR after merge.Generated by Claude Code