Skip to content

CLI for any CI

@maxoperf/cli does what the GitHub Action does, from any shell. maxoperf push mirrors the test files in your repository to MaxoPerf. maxoperf run does the same, starts each test, waits and exits non-zero when a run fails. It needs Node 20 or later.

Terminal window
npx @maxoperf/cli push
npx @maxoperf/cli run --config TARGET_URL=https://staging.example.com
VariableRequiredMeaning
MAXOPERF_API_KEYyesAPI key. Keep it in your CI secret store.
MAXOPERF_ACCOUNT_IDyesAccount id, shown on Settings → API keys.
MAXOPERF_PROJECT_IDnoDefault project. --project and the file’s projectId take precedence.
MAXOPERF_API_BASEnoAPI origin. Defaults to https://app.maxoperf.com.
maxoperf push [--tests <glob>]... [--project prj-...] [--root .] [--json] [--api-base URL]
maxoperf run [push flags] [--config KEY=VALUE]... [--no-wait] [--fail-on criteria|never] [--timeout 60]
  • --tests defaults to .maxoperf/tests/*.{yml,yaml}. Point it at one file to sync or run one test.
  • --config KEY=VALUE overrides a config value for this run only.
  • Runs execute one after another.
  • --timeout is in minutes.
  • --json prints one JSON document on stdout and sends progress to stderr.

The file format and sync rules are in Keep tests in git. The CLI never prints the API key or the presigned upload URLs.

The CLI tab gives the command for any other CI system.
CodeMeaning
0Success. With run, every run passed.
1A run failed or was cancelled (with --fail-on criteria).
2Usage, test file or validation error.
3API or network error, a run was blocked from starting, or a timeout.

Most CI systems fail the job on any non-zero code. To treat exit 1 differently from 2 and 3, check $? yourself.

The CI chip on a run links back to the workflow run and the commit.

The CLI detects GitHub Actions, GitLab CI, Jenkins, CircleCI and Bitbucket Pipelines from their standard environment variables. It attaches the provider, repository, commit, branch, pull request and pipeline URL to each run. The run’s CI chip in the console shows them.

Add MAXOPERF_API_KEY and MAXOPERF_ACCOUNT_ID under Settings → CI/CD → Variables (mask and protect the key).

perf:
image: node:22
stage: test
variables:
MAXOPERF_PROJECT_ID: prj-0123456789
script:
- npx @maxoperf/cli run --config TARGET_URL=$STAGING_URL
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"

Store the key as a secret text credential and bind it for the step:

pipeline {
agent { docker { image 'node:22' } }
environment { MAXOPERF_ACCOUNT_ID = 'acc-0123456789' }
stages {
stage('Load test') {
steps {
withCredentials([string(credentialsId: 'maxoperf-api-key', variable: 'MAXOPERF_API_KEY')]) {
sh 'npx @maxoperf/cli run --config TARGET_URL=https://staging.example.com'
}
}
}
}
}

Add the variables in Project settings → Environment variables.

version: 2.1
jobs:
perf:
docker:
- image: cimg/node:22.11
steps:
- checkout
- run: npx @maxoperf/cli run --config TARGET_URL=https://staging.example.com
workflows:
perf:
jobs: [perf]

Add the variables under Repository settings → Pipelines → Repository variables and mark the key as secured.

pipelines:
pull-requests:
'**':
- step:
name: Load test
image: node:22
script:
- npx @maxoperf/cli run --config TARGET_URL=https://staging.example.com
Terminal window
export MAXOPERF_API_KEY=mpak_...
export MAXOPERF_ACCOUNT_ID=acc-0123456789
npx @maxoperf/cli run --tests .maxoperf/tests/checkout.yml

Outside a CI system the CLI attaches no CI context, so these runs show no CI chip.