Skip to content

Add rerun-action-download-failures composite action - #15

Merged
oshadmi merged 4 commits into
mainfrom
oshadmi-rerun-action-download-failures
Nov 5, 2026
Merged

oshadmi merged 4 commits into
mainfrom
oshadmi-rerun-action-download-failures

Conversation

@oshadmi

@oshadmi oshadmi commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What

A new rerun-action-download-failures composite action. When a PR run fails, it re-runs the run's failed jobs at most once, and only if every one of them failed downloading an action in "Set up job".

Before any step runs, the runner downloads every action a job references. actions/runner treats a 404 from codeload.github.com as permanent and gives up after one attempt ("An action could not be found at the URI …" / "Failed to download archive … after 1 attempts"). So a transient codeload error fails the job and the PR's gate until someone clicks "Re-run failed jobs". No step-level retry can help, because no step has started.

This moves the logic out of RediSearch/RediSearch#12184 so RediSearchEnterprise, which has the same Pull Request workflow, pr-validation gate and concurrency group, can use it too. Each repo keeps a thin on: workflow_run caller, because a workflow_run trigger only fires for workflows in its own repository.

When it re-runs, and when it doesn't

It re-runs only when all of these hold:

  • The run is for a pull request from a branch of the calling repository, and it failed on its first attempt.
  • Every failed job, other than gate-job (default pr-validation), carries the runner's download-failure annotation. The gate is excluded because it fails whenever anything it needs fails, and it is re-run along with them.
  • Right before the re-run request, the run is still on attempt 1 and is still the latest run of its workflow for the PR.

Otherwise it exits successfully without re-running, for example when:

  • Any failed job failed for another reason, even if other jobs did fail on the download.
  • The run has already been re-run (attempt 2 or later), by hand or by this action.
  • A newer run exists for the PR. Re-running the old one would cancel the newer one through the PR's concurrency group.
  • The PR is from a fork, or the run was not triggered by pull_request.

It fails the step only when it is used outside a workflow_run job, or when the API keeps failing:

  • Read-only calls retry 5 times.
  • The re-run request retries up to 3 times. Before each retry it re-reads the run and stops once the run has left attempt 1, so a request that errored but still started the re-run is never repeated into an attempt 3.

Using it

on:
  workflow_run:
    workflows: ["Pull Request Flow"]
    types: [completed]
permissions: {}
jobs:
  rerun:
    if: github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt == 1
    runs-on: ubuntu-slim
    permissions:
      actions: write
      checks: read
    steps:
      - uses: redislabsdev/redisearch-ci-common/.github/actions/rerun-action-download-failures@v1

The job-level if: only avoids starting a runner. The action checks every condition itself. It reads the run from the caller's event, so it needs no inputs beyond an optional gate-job and github-token, and no checkout.

Other changes

  • README.md: a row for the action.
  • ci.yml: compileall now also covers .github/actions, so Python scripts kept next to a composite action are checked too.

Testing

  • Against real RediSearch runs, with the re-run request stubbed out. The event payloads were replayed as attempt-1 failures:
    • 41634084208 (PR #12177) and 41638204805 (PR #10269): both classified as download failures. They then stopped at the attempt check, because both had since been re-run.
    • 41506424152: skipped, because a coverage job failed for another reason.
    • The superseded-run lookup, which uses the event's workflow_id, returns the PR's runs.
  • Against a fake gh, for every skip condition and the API-error paths:
    • A re-run request that fails without starting the re-run is retried.
    • One that fails but did start it is not retried.
    • A request that fails every time stops after 3 attempts.
    • Five failed reads end the step.

After merge

This needs a v1.x.y release, with v1 moved to it, before RediSearch/RediSearch#12184 can switch from its temporary commit pin to @v1.

🤖 Generated with Claude Code


Note

Medium Risk
The action uses actions: write to trigger job re-runs and must avoid re-running superseded PR runs; misclassification could re-run the wrong workflow attempt, though guards and skip-on-any-other-failure limit blast radius.

Overview
Adds a reusable rerun-action-download-failures composite action (plus rerun.py) for thin workflow_run callers: when a first-attempt pull_request run fails and every non-gate failed job’s check annotations match transient codeload “Set up job” download errors, it calls rerun-failed-jobs once. It exits 0 without re-running for fork PRs, non-download failures, attempt ≥2, or runs that are no longer the PR’s latest (to avoid concurrency canceling a newer run), and re-checks “latest + attempt 1” immediately before POST and between rerun retries.

README documents the action; ci.yml extends compileall to .github/actions so action-local Python is syntax-checked like scripts/.

Reviewed by Cursor Bugbot for commit 2aa378b. Bugbot is set up for automated code reviews on this repo. Configure here.

The runner downloads every action a job uses in "Set up job" and gives up
after one attempt on a 404 from codeload.github.com, so a transient codeload
error fails a PR's jobs and its gate before any step runs. This action,
called from a thin workflow_run caller, re-runs the failed jobs once when
every one of them carries that download error. It skips fork PRs, runs
already re-run, superseded runs, and runs with any other failure.

Moved from RediSearch/RediSearch#12184 so RediSearchEnterprise, which has
the same PR flow and gate, can use it too. CI now also compiles the Python
scripts that live next to composite actions.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Its unquoted ': ' made YAML read it as a mapping.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@oshadmi
oshadmi requested review from GuyAv46 and kei-nan November 5, 2026 08:50
@oshadmi

oshadmi commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@lerman25 could you review this? It's the shared part of RediSearch/RediSearch#12184, which automatically re-runs PR jobs that failed downloading an action in "Set up job". RSE can use it next.

@GuyAv46 GuyAv46 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it’s only for PR flow? As it should not work for MQ

The superseded-run check only skipped when it found a newer run, so a
list that missed this run (not in the first page, pull_requests missing)
let the re-run through and could cancel a newer run. Skip unless this run
is the newest for the PR, sorting by run_number rather than relying on
the API's order. Also say in the description why merge-queue runs are
skipped, and where gh gets its token.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@oshadmi

oshadmi commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@GuyAv46 Right, PR runs only. It skips anything not triggered by pull_request. A failed merge-queue run has already removed the PR from the queue, so re-running its jobs wouldn't put it back. I added that to the action's description (e5b79a4).

🤖 Addressed by Claude Code

@oshadmi
oshadmi requested a review from GuyAv46 November 5, 2026 10:41

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e5b79a4. Configure here.

A failed rerun-failed-jobs request re-checked only the attempt before
retrying, so a newer PR run started during the backoff could still be
cancelled by re-running the old one. Check both the attempt and the
latest run before every request.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@oshadmi
oshadmi merged commit d406013 into main Nov 5, 2026
2 checks passed
@oshadmi
oshadmi deleted the oshadmi-rerun-action-download-failures branch November 5, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants