How to Run Artillery Load Tests in GitHub Actions
Artillery exits non-zero when an ensure condition fails, so SLO checks on latency or errors become a CI gate.
Write a scenario file with an ensure block, install Artillery, and run artillery run. A breached ensure threshold fails the command and the job.
Steps
- Define
config.phasesand ascenariosflow. - Add a
config.ensureblock with latency and error thresholds. - Run
artillery run scenario.yml; a failed ensure exits non-zero.
scenario.yml
scenario.yml
config:
target: https://staging.example.com
phases:
- duration: 60
arrivalRate: 10
ensure:
thresholds:
- http.response_time.p95: 500
- http.codes.500: 0
scenarios:
- flow:
- get:
url: /api/healthWorkflow
.github/workflows/ci.yml
jobs:
artillery:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm install -g artillery@latest
- run: artillery run scenario.ymlGotchas
- Without an
ensureblock, the run reports metrics but never fails the build. - arrivalRate is new virtual users per second, not a fixed concurrent count.
Related guides
How to Gate a PR on k6 Load Test Thresholds in GitHub ActionsFail a GitHub Actions run when a k6 load test breaches a threshold, since k6 exits non-zero when a thresholds…
How to Run a Performance Smoke Test After Deploy in GitHub ActionsRun a quick performance smoke test against a freshly deployed URL in GitHub Actions, failing the deploy job w…