Skip to content

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:

  1. Syncs the test files in .maxoperf/tests/ to MaxoPerf, so git stays the source of truth.
  2. Starts one run per test and waits for it to finish.
  3. 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.

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).

Settings, API keys shows your account id next to the key list.

Commit a test file as .maxoperf/tests/checkout.yml:

version: 1
name: "Checkout soak" # stable identity: the sync key
projectId: "prj-0123456789"
engineKind: "k6"
entrypoint: "perf/checkout/script.js" # path relative to the repo root
loadProfile: { 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: perf
on: pull_request
permissions:
contents: read
pull-requests: write # only needed for pr-comment
jobs:
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: true

Open 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.

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

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.

When your host reports a successful deployment to GitHub, run the tests against the deployed URL:

on: deployment_status
jobs:
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.

InputRequiredDefaultDescription
api-keyyesMaxoPerf API key (mpak_...). Pass it from a secret.
account-idyesMaxoPerf account id, sent as X-Account-Id.
project-idnoDefault project for test files that have no projectId.
commandnorunrun syncs, then runs. push only syncs.
testsno.maxoperf/tests/*.{yml,yaml}Test file globs, one per line. A single path syncs or runs one test.
config-overridesnoPer-run config values, one KEY=VALUE per line.
waitnotrueWait for the runs to finish.
fail-onnocriteriacriteria fails the job when a run fails. never does not.
timeout-minutesno60Maximum minutes to wait for each run.
pr-commentnofalsePost or update one sticky comment on the pull request.
github-tokenno${{ github.token }}Token used for the pull request comment.
api-basenohttps://app.maxoperf.comMaxoPerf API origin.
OutputDescription
resultsJSON array with name, testId, runId, status, passed and reportUrl for every test.
test-idId of the first test.
run-idId of the first run.
statusTerminal status of the first run.
report-urlLink to the first run’s report.
passedtrue when every run passed.

Use results to act on every test, for example fromJSON(steps.perf.outputs.results)[0].reportUrl.

The step succeeds when every run passes its failure criteria. It fails in these cases:

CauseStep 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 APIFails with the file name and the server message.
The API or network failed, a run was blocked from starting, or timeout-minutes passedFails.

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.

  • 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_request events only, not pull_request_target. Without pull-requests: write the action logs a warning and the job continues.

More workflow examples are in the examples folder of the action repository. For Vercel, see Load test a Vercel app.