What stays the same and what does not#
GitHub's documentation says that a re-run uses the same GITHUB_SHA and GITHUB_REF as the event that first triggered the workflow, and that a run can be re-run up to 30 days after its initial run. Re-running workflows and jobs
| Same on a re-run | Can differ |
|---|---|
| Commit and ref | Time of day, and anything that depends on it |
| The machine, and its load | |
| Images and packages named by a moving tag or range | |
| Caches written in between | |
| External services and their data | |
| Test order, if the seed comes from the clock | |
| Which jobs ran, when only failed jobs were re-run |
For a pull request, the same commit means the same merge commit. If the base branch has since gained a fix, a re-run still tests the old combination. A new push, or a merge of the base, tests the new one. The merge commit guide shows how to read it.
Read the attempts#
github.run_attempt starts at 1 and increments with each re-run. Put it in artifact names and in the log, or the second attempt replaces the first:
- run: echo "run ${{ github.run_id }} attempt ${{ github.run_attempt }}"
The contexts reference defines both. Afterwards, the API returns an earlier attempt:
gh api repos/OWNER/REPO/actions/runs/RUN_ID --jq '.run_attempt, .conclusion'
gh api repos/OWNER/REPO/actions/runs/RUN_ID/attempts/1 --jq '.conclusion, .head_sha'
A conclusion of success with run_attempt 3 means that somebody re-ran it twice. It does not say that the first two failed in the tests, since a cancelled runner also leads to a re-run. Read each attempt's failing step.
Decide from the first failure#
| First attempt's failing step | A pass on re-run means | Next |
|---|---|---|
| Checkout, install, image pull | The network or registry recovered | Accept, and count how often it happens |
| Runner lost, out of memory | The machine differed | Accept only if memory use did not change in this commit |
| A test, with an error from this change's area | The result varies on this commit | Do not accept the pass as an answer. Find what varied |
| A test, unrelated area, with a known record | It matched a known pattern | Link that record |
| A test, unrelated area, no record | Unknown | Open the record with both attempts, then decide |
"Unrelated area" is the judgment that hides defects. A change can break a distant test through shared state, so state why you believe it is unrelated.
Worked example#
This example is fictional. A pull request is green on attempt 3. Attempts 1 and 2 failed one checkout test with a zero total, and the change touches the cart's cache. The author's note says "flaky, re-ran". Ben puts the two errors and the pass side by side and asks for a failure count on this commit and on its base: 9 of 60 against 0 of 60. The check was green, and the change was the cause.
Return to handing over evidence.