GitHub Actions
The MaxoPerf Load Test action (MaxoPerf/github-action@v1) keeps performance tests in your repository and runs them from your workflows. On each run it:
- Syncs the test files in
.maxoperf/tests/to MaxoPerf, so git stays the source of truth. - Starts one run per test and waits for it to finish.
- Writes a job summary, optionally posts one sticky pull request comment, and fails the job when a run fails.
It works for three common triggers: a pull request, a push to your main branch, and a successful deploy. The runs are ordinary MaxoPerf runs, so every chart, criterion and report in the console works on them. Each run also carries the repository, branch or pull request number, commit and workflow URL, so you can find it again later.
Before you start
Section titled “Before you start”You need three things:
- An API key. Create one in the console under Settings → API keys. See Get an API key. Use a dedicated CI member with a short expiry rather than your own key.
- Your account id. The API keys page shows it with a copy button. The action sends it as
X-Account-Id. - A test file in your repository. See Keep tests in git.
Add the key as a repository secret named MAXOPERF_API_KEY and the account id as a repository variable named MAXOPERF_ACCOUNT_ID (Settings → Secrets and variables → Actions).
Quick start: gate pull requests
Section titled “Quick start: gate pull requests”Commit a test file as .maxoperf/tests/checkout.yml:
version: 1name: "Checkout soak" # stable identity: the sync keyprojectId: "prj-0123456789"engineKind: "k6"entrypoint: "perf/checkout/script.js" # path relative to the repo rootloadProfile: { virtualUsers: 50, agentCount: 1, rampUpSeconds: 30, durationSeconds: 300 }locationPlan: { managedRegions: ["us-east-1"] }failureCriteria: - { subject: "p95", condition: ">", threshold: 800, unit: "ms" }Then add .github/workflows/perf.yml:
name: perfon: pull_requestpermissions: contents: read pull-requests: write # only needed for pr-commentjobs: load-test: if: github.event.pull_request.head.repo.fork != true runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: MaxoPerf/github-action@v1 with: api-key: ${{ secrets.MAXOPERF_API_KEY }} account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }} pr-comment: trueOpen a pull request. The job syncs the test, runs it, and fails if p95 goes above 800 ms. The result shows in the job summary and in a pull request comment. See Gate pull requests for the details.
Run on push to main
Section titled “Run on push to main”To keep the tests in sync and record a baseline run after every merge, trigger on push:
on: push: branches: [main]jobs: load-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: MaxoPerf/github-action@v1 with: api-key: ${{ secrets.MAXOPERF_API_KEY }} account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }}To sync the files without running anything, set command: push.
Run after a deploy
Section titled “Run after a deploy”When your host reports a successful deployment to GitHub, run the tests against the deployed URL:
on: deployment_statusjobs: load-test: if: github.event.deployment_status.state == 'success' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: MaxoPerf/github-action@v1 with: api-key: ${{ secrets.MAXOPERF_API_KEY }} account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }} config-overrides: TARGET_URL=${{ github.event.deployment_status.environment_url }}Hosts that send a repository_dispatch event instead use TARGET_URL=${{ github.event.client_payload.url }}. The test must read TARGET_URL from its environment. See Run after a deploy.
Inputs
Section titled “Inputs”| Input | Required | Default | Description |
|---|---|---|---|
api-key | yes | MaxoPerf API key (mpak_...). Pass it from a secret. | |
account-id | yes | MaxoPerf account id, sent as X-Account-Id. | |
project-id | no | Default project for test files that have no projectId. | |
command | no | run | run syncs, then runs. push only syncs. |
tests | no | .maxoperf/tests/*.{yml,yaml} | Test file globs, one per line. A single path syncs or runs one test. |
config-overrides | no | Per-run config values, one KEY=VALUE per line. | |
wait | no | true | Wait for the runs to finish. |
fail-on | no | criteria | criteria fails the job when a run fails. never does not. |
timeout-minutes | no | 60 | Maximum minutes to wait for each run. |
pr-comment | no | false | Post or update one sticky comment on the pull request. |
github-token | no | ${{ github.token }} | Token used for the pull request comment. |
api-base | no | https://app.maxoperf.com | MaxoPerf API origin. |
Outputs
Section titled “Outputs”| Output | Description |
|---|---|
results | JSON array with name, testId, runId, status, passed and reportUrl for every test. |
test-id | Id of the first test. |
run-id | Id of the first run. |
status | Terminal status of the first run. |
report-url | Link to the first run’s report. |
passed | true when every run passed. |
Use results to act on every test, for example fromJSON(steps.perf.outputs.results)[0].reportUrl.
Results and exit behavior
Section titled “Results and exit behavior”The step succeeds when every run passes its failure criteria. It fails in these cases:
| Cause | Step result |
|---|---|
| A run failed or was cancelled (a criterion was breached) | Fails. With fail-on: never it succeeds. |
| A test file is invalid or a sync was rejected by the API | Fails with the file name and the server message. |
The API or network failed, a run was blocked from starting, or timeout-minutes passed | Fails. |
The same rules apply to the CLI, where they map to exit codes 0, 1, 2 and 3.
With wait: false the action starts the runs and returns without a verdict, so it cannot gate the job.
Security notes
Section titled “Security notes”- The action masks the API key in logs. Store it as a secret.
- Override values are stored on the run and returned by the API. The console shows only their keys. Do not pass tokens as overrides. Bind workspace secrets in the test file instead.
- The pull request comment works on
pull_requestevents only, notpull_request_target. Withoutpull-requests: writethe action logs a warning and the job continues.
Where to go next
Section titled “Where to go next”More workflow examples are in the examples folder of the action repository. For Vercel, see Load test a Vercel app.