This action supports re-running only the Playwright tests that failed when
GitHub Actions runs “re-run failed jobs” (or similar retries). It works together
with Currents and the
@currents/cmd CLI.
Full setup, sharding, orchestration, and CI build ID details: Re-run only failed tests (GitHub Actions) on docs.currents.dev. For background on why re-runs need extra configuration, see the guide Re-run only failed tests.
- Before the Playwright test step: restores last run metadata (via Currents cache or the Currents API) and exposes extra Playwright CLI flags as a step output.
- After the job (cache mode only): saves updated last run metadata so the next retry can target failures again.
The step output is passed into the Playwright command—for example
npx playwright test … ${{ steps.<id>.outputs.extra-pw-flags }}—so only failed
tests run on retry.
The action runs on Node 24 and installs @currents/cmd@^3.3.0 globally
(npm install -g @currents/cmd@^3.3.0). It then behaves in one of two ways:
Suited to workflows that report runs to Currents with a record key (typical Playwright reporter + sharding flow).
- Main step: runs
npx currents cache getwith thelast-runpreset. On success, it reads a generated preset file and sets the outputextra-pw-flags. - Post step: runs
npx currents cache setwith the same preset so the next workflow attempt can read an updated snapshot.
Authentication and targeting use the Currents record key (input key or
CURRENTS_RECORD_KEY). Optional id, path, matrix inputs, and
pw-output-dir tune what is cached.
Suited to workflows that rely on Currents Orchestration (or otherwise need the CLI to resolve failures via the API). In this mode the post-cache step is skipped.
On re-run attempts (GITHUB_RUN_ATTEMPT > 1), the main step runs
npx currents api get-run to fetch the previous run and, when successful, sets
extra-discovery-flags to --last-failed. The workflow should define
CURRENTS_API_KEY, CURRENTS_PROJECT_ID (and related environment
variables as in the docs), and set or8n: true (or use-api: true) as
shown in the orchestration section of the documentation. The
api-key and project-id inputs are passed to the CLI as CURRENTS_API_KEY
and CURRENTS_PROJECT_ID.
The previous run's failed tests are the whole run's. If you also pass your own
--shard, each shard reruns the failed tests in its share, which covers every
failed test with "Re-run all jobs". With "Re-run failed jobs" it does only when
the re-run is linked to the attempt before it, so every shard gets the same
tests again: keep the default CI build ID, or set previous-ci-build-id.
| Name | Description |
|---|---|
extra-pw-flags |
Flags to append to the Playwright test command. |
extra-discovery-flags |
Flags to append to the pwc-p discover command. |
If restoration fails, the output may be empty; the workflow can still run tests normally.
key(optional, default''). Currents record key, or setCURRENTS_RECORD_KEY. Used in cache mode.debug(optional, defaultfalse). Enables debug logging for CLI commands.id(optional, default''). Cache ID namespace forcache get/cache set.path(optional, default''). Comma-separated paths to include when writing cache (post step).output-dir(optional, default''). Directory for preset output duringcache get.pw-output-dir(optional, defaulttest-results). Playwright output directory; used for API mode.last-run.jsonpath and for--pw-output-diron cache set.matrix-index(optional, default1). Shard index for parallel runs (cache get/cache set).matrix-total(optional, default1). Total shards.use-api(optional, defaultfalse). API-based last-failed resolution (same code path asor8n).or8n(optional, defaultfalse). Orchestration-oriented behavior (API path; no post-cache step).api-key(optional, default''). API key, or setCURRENTS_API_KEYin the environment.project-id(optional, default''). Currents project ID, or setCURRENTS_PROJECT_ID. Selects the project for API calls.previous-ci-build-id(optional, default''). Override for the previous CI build ID when resolving the prior run (see custom CI build ID). On a re-run the action also exports it asCURRENTS_PREVIOUS_CI_BUILD_ID, in both modes, so the reporter links the run to the attempt before it. Set it when you use a custom CI build ID: a re-run that is not linked can split the tests across shards differently from the first attempt.
*In cache mode a record key (input or environment) is required for cache reads/writes.
The action takes no OIDC inputs. To use GitHub Actions OIDC instead of a stored
record key, get a record key with @currents/cmd in a step before this action
and export it as CURRENTS_RECORD_KEY. The job needs
permissions: id-token: write. Get an API key for API mode the same way with
currents ci auth get-api-token, exported as CURRENTS_API_KEY.
permissions:
id-token: write
contents: read
steps:
- name: Get a Currents record key
env:
CURRENTS_OIDC_POLICY_ID: ${{ vars.CURRENTS_OIDC_POLICY_ID }}
run: |
key=$(npx --yes --ignore-scripts --package @currents/cmd@3.4.0 \
currents ci auth get-record-key --oidc-provider github-actions)
echo "::add-mask::$key"
echo "CURRENTS_RECORD_KEY=$key" >> "$GITHUB_ENV"
- name: Playwright Last Failed
id: last-failed
uses: currents-dev/playwright-last-failed@v1
with:
matrix-index: ${{ matrix.shard }}
matrix-total: ${{ strategy.job-total }}The key stays valid until it expires or currents ci auth revoke revokes it.
- Add
@currents/cmdto the repository as a dev dependency and install with a frozen lockfile in CI (npm ci, etc.). The action installs a global CLI for convenience; pinning@currents/cmdin the repository keeps CI reproducible. See the note in the official docs. - Configure Currents (record key, and for API mode, API key and project ID)
using secrets and
envas described in the documentation. - Add this action before the Playwright step and pass
extra-pw-flagsinto the test command. - Sharding: set
matrix-indexandmatrix-totalfrom the job matrix (for example${{ matrix.shard }}and${{ strategy.job-total }}).
- name: Playwright Last Failed
id: last-failed
uses: currents-dev/playwright-last-failed@v1
env:
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
with:
pw-output-dir: test-results
matrix-index: ${{ matrix.shard }}
matrix-total: ${{ strategy.job-total }}
- name: Run Playwright
run: npx playwright test ${{ steps.last-failed.outputs.extra-pw-flags }}For orchestration (or8n: true), environment variables, custom
CURRENTS_CI_BUILD_ID, and copypaste workflows, see Re-run only failed tests
(GitHub Actions).
Input/output definitions are in action.yml.
This action is implemented in TypeScript (src/index.ts, src/post.ts). After
changing sources, run npm run all to format, lint, test, and rebuild dist/
before committing.
The action is consumed by tag, and releases move the major tag (v2), so @v2
picks up fixes. See action versioning.
Bump version in package.json, merge that to main, then cut the release:
script/releaseThe script reads the version from package.json — it refuses to run on a dirty
tree, off main, behind the remote, or with a version that is not above the
last release — then tags vX.Y.Z, moves the major tag to it, and publishes the
release notes with gh.
Both tags go up in one atomic push, so a rejected major tag cannot leave a
published vX.Y.Z behind. If a release does fail part way, fix the cause and
run script/release again on the same commit: it picks up where it stopped. A
new major leaves the previous one on a releases/v# branch so it stays
patchable.