Using the CLI in CI
Two commands belong in your pipelines:
zyonix testin CI: replays recorded cases against the commit and fails the build on a regression.zyonix deployin CD: tells Zyonix what shipped, so monitoring can start.
What the CI job needs
- The packages:
pip install zyonix-cli(plus your application's own dependencies, becausezyonix testcalls your code). - A
clikey as a secret inZYONIX_API_KEY. Create it withzyonix auth keys --create cli. Aclikey reads, runs tests and replays and records deploys; it makes no decisions. - The address:
ZYONIX_ENDPOINT,ZYONIX_EGRESS_ALLOW(your Zyonix host) and, for a private certificate authority,ZYONIX_CA_FILE. - A
zyonix.yamlin the folder the job runs in (or--config), withcapture: fulland areplay:section that tells Zyonix how to start your application (Set up). Setreplay.config_providerso the cases test the configuration in this commit, not the one recorded when they failed. - Whatever your step needs to run: for example your LLM provider's key. Your step runs for real on the CI machine; Zyonix never sees those keys.
The test suites
| Suite | Cases | When |
|---|---|---|
canary (the default) | a small, fast set | every commit or pull request |
full | every regression and golden case | nightly, and before a release |
zyonix test --suite canary --junit zyonix-results.xml
zyonix test --suite full --trigger nightly --junit zyonix-results.xml
--trigger is ci automatically when the CI variable is set (most CI systems set it). Use
--trigger nightly for the scheduled full run: zyonix status and zyonix regression report its
state and say when it is failing or stale. The commit is taken from GITHUB_SHA or GIT_SHA
(override with --git-sha); --release stores a release label.
Useful variants:
| Option | Use it for |
|---|---|
--no-record | the server judges the outputs and classifies regressions, and stores nothing (for example on pull requests) |
--no-upload | run the cases and send nothing; nothing is judged. Only checks that your step runs |
--k 3 | run each case 3 times; a case passes at 2 of 3. For models that are not deterministic |
--use-recorded-config | run without a config_provider, with each case's recorded configuration (fixed cases then keep failing) |
All options: zyonix test.
Exit codes
| Code | Means | What CI should do |
|---|---|---|
0 | no regression (known-failing cases of unfixed issues do not count) | pass |
1 | at least one regression | fail the build |
2 | could not run: configuration, key, connection, import or setup error; or every case failed to run for the same reason; or cases need a config_provider that is not set. Nothing was recorded | fail the job, fix the environment |
An unexpected error inside the CLI is also 2, never 1, so a crash is never reported as a
regression.
JUnit output
--junit FILE writes JUnit XML that GitHub Actions, GitLab and Jenkins can show. The test suite is
named zyonix-canary or zyonix-full; each case is a test case under zyonix.issue-N or
zyonix.golden.
| Case result | In JUnit |
|---|---|
| passed | a passing test case |
| regression | failure (turns the build red) |
| could not run | error |
| known failing (an unfixed issue) | skipped with a "known failing" message: visible, not red |
not judged (--no-upload) | skipped with a "not judged" message |
JSON output
zyonix test --json prints one JSON document (zyonix.test/1) on stdout and nothing else; the
exit code is the same as without it.
{
"schema": "zyonix.test/1",
"suite": "canary",
"k": 1,
"passed": true,
"uploaded": true,
"recorded": true,
"regression_run_id": 41,
"counts": {"cases": 3, "passed": 2, "regressions": 0, "known_failing": 1, "errors": 0},
"junit": null,
"cases": [
{"kind": "regression", "id": 15, "doc_id": "INV-1077", "issue_id": 5, "status": "fail",
"result": "known-failing", "regression": false, "failed_checks": ["required:tax_amount"], "detail": null}
]
}
GitHub Actions example
name: zyonix
on:
pull_request:
push:
branches: [main]
schedule:
- cron: "0 2 * * *"
jobs:
zyonix-test:
runs-on: ubuntu-latest
env:
ZYONIX_ENDPOINT: https://zyonix.example.com
ZYONIX_EGRESS_ALLOW: zyonix.example.com
ZYONIX_API_KEY: ${{ secrets.ZYONIX_CLI_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # whatever your step needs
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt zyonix-cli
- name: Regression suite
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
zyonix test --suite full --trigger nightly --junit zyonix-results.xml
else
zyonix test --suite canary --junit zyonix-results.xml
fi
- uses: actions/upload-artifact@v4
if: always()
with:
name: zyonix-results
path: zyonix-results.xml
GitLab CI example
zyonix-test:
image: python:3.12
variables:
ZYONIX_ENDPOINT: https://zyonix.example.com
ZYONIX_EGRESS_ALLOW: zyonix.example.com
script:
- pip install -r requirements.txt zyonix-cli
- zyonix test --suite canary --junit zyonix-results.xml
artifacts:
when: always
reports:
junit: zyonix-results.xml
Set ZYONIX_API_KEY (the cli key) as a masked CI/CD variable.
Recording deploys from CD
After your deployment step:
zyonix deploy --release "$GIT_SHA"
zyonix deploy --release "$GIT_SHA" --fix 4 # when this release ships approved fix #4
With --fix, the issue moves to MONITORING. Zyonix also detects releases from your application
(zyonix.init(release=...) or ZYONIX_RELEASE) and from prompt or configuration changes, so the
plain form is optional. See zyonix deploy.
Checking the setup in CI
zyonix doctor --json
prints one JSON document and exits 1 when a check failed. It also sends a small test trace (a run
with origin doctor).
Use a cli key, never an admin key: CI should not be able to approve fixes or change checks.
Rotate it with zyonix auth keys --rotate ID; the old key keeps working for 24 hours (by default)
so you can update the secret without a failed build.