Learning center

The rerun passed: what did it run on?

A re-run in GitHub Actions uses the same commit and ref as the original event, so a pass on the second attempt shows that the result can differ on one commit. Record both attempts before you hand over a green check.

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-runCan differ
Commit and refTime 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 stepA pass on re-run meansNext
Checkout, install, image pullThe network or registry recoveredAccept, and count how often it happens
Runner lost, out of memoryThe machine differedAccept only if memory use did not change in this commit
A test, with an error from this change's areaThe result varies on this commitDo not accept the pass as an answer. Find what varied
A test, unrelated area, with a known recordIt matched a known patternLink that record
A test, unrelated area, no recordUnknownOpen 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.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading