Skip to content
Latchkey

How to Run k6 Cloud Tests From CI

k6 cloud run streams the test to Grafana Cloud k6, which supplies the load generators and returns a pass/fail exit code to CI.

Authenticate with K6_CLOUD_TOKEN, then run k6 cloud run script.js. The cloud service executes the test at scale and CI still gates on the thresholds in your script.

Steps

  • Store the Grafana Cloud k6 token as a repo secret.
  • Expose it as K6_CLOUD_TOKEN (and the project id if needed).
  • Run k6 cloud run k6-script.js; the exit code reflects your thresholds.

Workflow

.github/workflows/ci.yml
jobs:
  cloud-load-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: grafana/setup-k6-action@v1
      - name: Run in Grafana Cloud k6
        env:
          K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN }}
        run: k6 cloud run k6-script.js

Gotchas

  • Cloud runs are metered by virtual user hours; a runaway matrix can burn the plan quickly.
  • The runner only orchestrates; the load originates from cloud generators, so the runner size barely matters.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →