Repository navigation
ci/deflake: Allow testing a pull request, ref or fork branch - #49129
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Fork-controlled checkouts retain trusted-job credentials, enabling Docker Hub token exfiltration, while combined PR and repository overrides fetch merge refs from the wrong repository.
2 open issues
What changed in this PR
Extends Envoy’s deflake workflow to reproduce flaky tests on pull requests, explicit refs, and fork branches before changes land, with a configurable timeout for long runs.
Changes:
- Adds
pr,ref, andrepositoryinputs to select the source under test. - Adds an override checkout step to the reusable CI runner.
- Exposes a job timeout input with a 360-minute default.
| File | Description |
|---|---|
.github/workflows/envoy-deflake.yml |
Adds source-selection and timeout inputs and forwards them to the CI runner. |
.github/workflows/_run.yml |
Adds checkout override inputs and fetches the requested source after the initial checkout. |
Review effort: Balanced
| git fetch --no-tags "$REPOSITORY" "$REF" | ||
| git checkout --force FETCH_HEAD |
There was a problem hiding this comment.
Addressed in 5445054: an override checkout now makes the job untrusted (trusted: ${{ !(inputs.pr || inputs.ref) }}), so no app token or deploy key, as in PR CI. The read-only DOCKERHUB_TOKEN is kept, as every untrusted PR job already receives it (envoy-prechecks.yml, _check.yml). (bot assisted)
There was a problem hiding this comment.
2bd658a also withholds DOCKERHUB_TOKEN for untrusted runs, so an override run now carries no secrets. (bot assisted)
There was a problem hiding this comment.
🟡 Changes recommended
PR/fork overrides retain main-scoped cache access, allowing untrusted code to poison caches consumed by trusted workflows that restore Docker state with sudo.
2 open issues
1 resolved since last review
Review effort: Balanced
The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Code fetched this way is not on the dispatching branch, so the job runs untrusted, as PR CI does: no app token, deploy key or Docker Hub token. A pull request's merge ref only exists in the base repository, so it is always fetched from origin, whatever repository is given for a ref. Unlike PR CI the run keeps the dispatching branch's Actions cache scope, which is documented on the input. Signed-off-by: Ryan Northey <[email protected]>
2bd658a to
71a3fd8
Compare
Review follow-ups: _run.yml itself now refuses checkout-ref/checkout-pr with trusted: true, rather than relying on each caller's trusted expression, and fails when checkout-repository is given without a ref instead of silently testing this branch. The DOCKERHUB_TOKEN is passed as before (PR CI gets it too, and the image is no longer cached since Signed-off-by: Ryan Northey <[email protected]> envoyproxy#49133), and checkout-ref documents that a sha must be the full one.
| if [[ "${{ inputs.trusted }}" == "true" ]]; then | ||
| echo "checkout-ref/checkout-pr can only be used with trusted: false" >&2 | ||
| exit 1 | ||
| fi | ||
| if [[ -z "$REF" ]]; then | ||
| echo "checkout-repository needs checkout-ref or checkout-pr" >&2 | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
nit: From deflake, setting only repository leaves trusted: true, because trusted only looks at pr and ref. The step then fails on the first check with "checkout-ref/checkout-pr can only be used with trusted: false", so the clearer message can never be reached from there. Swapping the two checks would fix that:
| if [[ "${{ inputs.trusted }}" == "true" ]]; then | |
| echo "checkout-ref/checkout-pr can only be used with trusted: false" >&2 | |
| exit 1 | |
| fi | |
| if [[ -z "$REF" ]]; then | |
| echo "checkout-repository needs checkout-ref or checkout-pr" >&2 | |
| exit 1 | |
| fi | |
| if [[ -z "$REF" ]]; then | |
| echo "checkout-repository needs checkout-ref or checkout-pr" >&2 | |
| exit 1 | |
| fi | |
| if [[ "${{ inputs.trusted }}" == "true" ]]; then | |
| echo "checkout-ref/checkout-pr can only be used with trusted: false" >&2 | |
| exit 1 | |
| fi |
| type: string | ||
| default: '' | ||
| ref: | ||
| description: 'Ref to test: sha, branch, tag or refs/pull/N/head (default: this branch)' |
There was a problem hiding this comment.
nit: Same "full sha" clarification as in _run.yml:
| description: 'Ref to test: sha, branch, tag or refs/pull/N/head (default: this branch)' | |
| description: 'Ref to test: full sha, branch, tag or refs/pull/N/head (default: this branch)' |
…eflake input Review: from deflake, repository alone leaves trusted: true, so the trusted check fired first and hid the message that explains the actual mistake. Signed-off-by: Ryan Northey <[email protected]>
…oxy#49129) The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>
…oxy#49129) The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>
…oxy#49129) The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>
…oxy#49129) The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>
…oxy#49129) The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>
The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add `pr`, `ref` and `repository` inputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and a `timeout-minutes` input for long runs. Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys. `_run.yml` enforces this itself rather than leaving it to each caller — the checkout step refuses `checkout-ref`/`checkout-pr` with `trusted: true`, and fails when `checkout-repository` is given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository. Signed-off-by: Ryan Northey <[email protected]> --------- Signed-off-by: Ryan Northey <[email protected]>


The deflake workflow could only test commits already on main: the checkout asserts the ref is an ancestor of the current branch. Add
pr,refandrepositoryinputs, fetched after the trusted checkout, so a flake can be reproduced from a pull request's merge ref or a branch on a fork before a fix lands, and atimeout-minutesinput for long runs.Testing a pull request, ref or fork branch runs code that is not on this branch, so the job runs untrusted, as in PR CI: no app token, no deploy key, no signing keys.
_run.ymlenforces this itself rather than leaving it to each caller — the checkout step refusescheckout-ref/checkout-prwithtrusted: true, and fails whencheckout-repositoryis given without a ref rather than silently testing this branch. The run keeps this branch's Actions cache scope, so only dispatch code you would push to this repository.Signed-off-by: Ryan Northey [email protected]