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 globally
(npm install -g @currents/cmd). 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-pw-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.
| Name | Description |
|---|---|
extra-pw-flags |
Flags to append to the Playwright test 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.previous-ci-build-id(optional, default''). Override for the previous CI build ID when resolving the prior run (see custom CI build ID).
*In cache mode a record key (input or environment) is required for meaningful cache reads/writes.
- 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.