Running in CI
The requests you build in the app are plain files in your repository, and the same postino binary runs them in a terminal with postino run. No window opens and no display is needed, so a CI pipeline can check an API on every push, with the tests you already wrote.
What a run does
postino run takes requests, folders or the whole workspace and sends each request as Send does in the app: the OAuth 2.0 token, the pre script, the variables, the request, the post script and its test() calls. It prints one line per request and exits with a code the pipeline understands: 0 when everything passed, 1 when a test failed. Every option is in the command line reference.
✓ auth/login POST 200 84 ms 2/2 tests
✗ auth/me GET 401 12 ms 0/1 tests
✗ status is 200: expected 401 to be 200
✓ crud/create-user POST 201 40 ms 3/3 tests
3 requests, 1 failed · 5/6 tests passed · 136 msStep by step
A repository with the workspace in api-requests/, as in Working with git, and a staging environment whose token lives in the ignored staging.local.env:
- Run it locally first, from the workspace folder:
postino run --env staging. Fix any red test before moving on. - Add
postino checkto catch files that do not parse. It sends nothing, so it can run on every push, even without the API. - Store the secret of
staging.local.envin your CI's secret store, such asSTAGING_TOKEN, since that file is not in the repository. - In the pipeline, install Postino, then run
postino run --env staging --var token=$STAGING_TOKEN --output junit -o report.xml. - Publish
report.xmlas a test report, so the pipeline shows which test failed.
Installing on the runner
On Linux, use the install script, which needs no root, or the APT or DNF repository. The binary links a few X11 libraries even when it opens no window (libxcb and libxkbcommon with its X11 part). The packages bring them; a minimal container installed with the script may need them first, for example apt-get install -y libxkbcommon-x11-0 on Debian and Ubuntu.
GitHub Actions
name: API tests
on: [push]
jobs:
api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Postino
run: |
curl -fsSL https://postino.tanis.codes/install.sh | bash
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Check the request files
run: postino check --workspace api-requests
- name: Run the requests
run: >
postino run --workspace api-requests --env staging
--var token=${{ secrets.STAGING_TOKEN }}
--output junit -o report.xml
- name: Keep the report
if: always()
uses: actions/upload-artifact@v4
with:
name: api-report
path: report.xmlGitLab CI
api-tests:
image: ubuntu:24.04
script:
- apt-get update && apt-get install -y curl ca-certificates libxkbcommon-x11-0
- curl -fsSL https://postino.tanis.codes/install.sh | bash
- export PATH="$HOME/.local/bin:$PATH"
- postino run --workspace api-requests --env staging --var "token=$STAGING_TOKEN" --output junit -o report.xml
artifacts:
when: always
reports:
junit: report.xmlSecrets and variables
Values that change between runs, or that must not be in the repository, come from the command line, from the lowest priority to the highest:
--env <name>: the environment file and its.local.env, when the runner has one.--env-file <file>: a.envfile written by the pipeline, for example from a secret.--var key=value: one variable, repeatable.
Postino prints no variable values. The URLs in the reports leave out the query string, and -v masks sensitive headers. A secret can still show in a response body printed with --show-body, or in a console.log of a script, which is printed under a request that fails.
OAuth 2.0 in a pipeline
Profiles with the client credentials or password grant work as in the app, and every run gets a new token. The authorization code grant needs a person to sign in in a browser, so it does not work on a CI runner: the request fails and says so. Give the pipeline a profile with the client credentials grant instead.
Reports
--output junit -o report.xml: one test suite per request and one test case pertest(), which GitHub, GitLab, Jenkins and most CI tools display.--output json: one JSON line per request and a last line with the totals, for your own scripts.
With -o, the readable lines are still printed in the job log. Add --bail to stop at the first failure, and --filter to run only part of the workspace, such as --filter 'smoke/*'.
Load tests in a pipeline
postino load prints progress lines instead of the dashboard when it runs in CI, and fails the job when a --fail-if condition holds at the end. Keep the report as an artifact of the job:
$ postino load --workspace api-requests crud/ --env staging --vus 20 --duration 2m \
--fail-if 'p95>500ms' --fail-if 'errors>1%' --report load-report.pdf --no-save--no-save keeps the history of the CI checkout clean; leave it out to keep the run in .postino/runs/, for example to compare it with --compare last on a machine that keeps its workspace. Run load tests against an environment you own, see Load testing.
Windows
On Windows, postino.exe works like any other command line tool: cmd.exe, PowerShell and a WSL terminal wait for each command to finish and read its exit code, and the output can be redirected to a file or piped to another command.
> postino.exe run --env staging --output junit > results.xml > exit $LASTEXITCODE
Run without a command, postino.exe opens the window and gives the prompt back at once. Closing the terminal does not close the window.