Docs/Using the CLI in CI
#

Using the CLI in CI

Run Cofactor test suites in CI with an API key and cofactor test-suite run, understand the exit codes (0, 1, 2), pin a suite to a commit with --at, wait for triage, and see a GitHub Actions example.

cofactor test-suite run streams results to your CI log and sets the exit code from the outcome, so a pipeline can gate on it. For the full pull request gate, see Release gates. For suites, tags and schedules, see Suites and schedules.

Authenticate the runner

An organization admin creates an API key with only the scopes the job needs. The command prints the secret once:

bash
cofactor api-key create --name "CI test runs" --scope test-run:run --scope test-run:read

Store the secret as a CI secret named COFACTOR_API_TOKEN. The CLI reads it with no login step. See Authentication and API keys.

Run a suite

bash
cofactor test-suite run --suite "Smoke"

The command prints each test's result as it finishes and ends with a summary.

FlagWhat it does
--suite <name|id>Runs a named suite.
--tag <tag>Runs the tests that carry this tag. Does not apply with --suite.
--application <name|id>Runs one application's tests. With --suite, it only names the application for --environment.
--environment <name|id>Runs on one environment. Also pass --application when you have more than one application.
--at <sha|pushId|tag>Requires --suite. Pins the suite's sandbox targets to a commit SHA, a push id or a tag.
--verbose, -vPrints every event.

With no flags, the command runs your Regression suite. Run cofactor test-suite run --help for all flags. For suites of your own Playwright tests, see Bring your own suite.

Exit codes

CodeMeaning
0Every test that ran passed.
1A test failed, timed out or was canceled, or the result stream ended before the suite finished. Also 1 when the run cannot start: no tests match your filters, the named suite has no layered flows, or your plan's vCPU-hours are used up.
2No test failed, but some tests ended with no verdict.

Runs of your own Playwright suites exit only 0 or 1.

GitHub Actions example

yaml
name: e2e
on:
  pull_request:
  push:
    branches: [main]

jobs:
  suite:
    runs-on: ubuntu-latest
    env:
      COFACTOR_API_TOKEN: ${{ secrets.COFACTOR_API_TOKEN }}
    steps:
      - run: npm install -g @runcofactor/cli
      - run: cofactor test-suite run --suite "Smoke" --verbose

Add the job's check to your branch protection rules to make it required.

Read the results

List recent runs, then read one:

bash
cofactor test-suite executions
cofactor test-suite get <executionId> --failures-only

cofactor test-suite cancel <executionId> cancels a running execution.

Group the failures

Triage groups the failures of a run by cause. It is a beta feature. With an API key, these commands need a full-access key (*).

bash
cofactor triage wait <executionId> --timeout 600
cofactor triage failures <executionId> --new-only

triage wait waits for triage to finish (default timeout 1200 seconds). It exits 2 when triage itself failed, 1 when the timeout passes, and 0 otherwise. latest stands in for the most recent execution in your organization. Gate on the exit code of test-suite run, not of triage wait.

Next steps