k6 part 3: run k6 in a pipeline, fail the build and keep the results
Run the k6 script in GitHub Actions, let a broken threshold fail the build through its exit code, and save a summary file for the team.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a railway signal. The signal turns red when the track ahead is not within the agreed limit. The driver does not argue with the signal. A note of the reading stays at the station even if the train stops.
The signal is the . The track is the pipeline step. The note is the summary file.
Leo, a developer at Daily List, a to-do list app, wires the signal. Mei owns the limits in the script. Tom explains the numbers when a goes red.
What it is: k6 is a free load tool from Grafana that calls your site and checks pass or fail limits. A is 0 when every limit holds, and non-zero when one breaks. A installs k6 and runs the script, and a k6 summary file saves the end numbers. A functional test is the neighbour, and it checks one user's path. k6 checks speed and error rate under load.
Why it matters: A slow Daily List (application programming interface) can still pass click tests. In (CI), the exit code turns a broken threshold into a red pull request. The summary file lets Tom show the p95 time. That is the time by which 95 percent of calls had finished. He does not have to run the load again on a laptop.
PLAIN WORDS · 1 in this section
- grafana
- a company that makes tools for watching and testing software
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A railway signal that stops the train.
- Signal
- Track
- Note
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The red signal | The non-zero exit code |
| The stretch of track | The pipeline step |
| The note at the station | The summary file |
| A driver who obeys | The build that fails |
WHERE THIS PICTURE STOPS
- A signal is set by hand, but
k6sets its own from the limits. - A note is one page, but a summary file can be big.
- A train waits, but a failed build can be run again.
HOOK
Signal, track, note.
TELL A FRIEND
A signal, a track and a note.
OFTEN MIXED UP WITH k6 part 2: checks, thresholds and stages, with p(95) read the right way. That topic sets limits and stages. This one runs them in a pipeline and keeps the results.
PRACTISE AND KEEP
Sources for this topic — 2 sources
- Market practice
Add k6 as a continuous integration and delivery pipeline step (Grafana k6 learning path) ↗ — Grafana Labs · Grafana learning path: setup-k6-action installs k6, run-k6-action runs a script from a path, and a non-zero k6 exit code such as a threshold breach fails the job; a learning hub page names exit code 99 and the main docs do not give the number
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
End of test and Custom summary (Grafana k6 documentation) ↗ — Grafana Labs · Grafana k6 docs: handleSummary receives the metrics and returns text or files, --summary-export writes a JSON file, and the docs now discourage that flag
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.