Skip to main content

Using the CLI in CI

Two commands belong in your pipelines:

  • zyonix test in CI: replays recorded cases against the commit and fails the build on a regression.
  • zyonix deploy in CD: tells Zyonix what shipped, so monitoring can start.

What the CI job needs​

  1. The packages: pip install zyonix-cli (plus your application's own dependencies, because zyonix test calls your code).
  2. A cli key as a secret in ZYONIX_API_KEY. Create it with zyonix auth keys --create cli. A cli key reads, runs tests and replays and records deploys; it makes no decisions.
  3. The address: ZYONIX_ENDPOINT, ZYONIX_EGRESS_ALLOW (your Zyonix host) and, for a private certificate authority, ZYONIX_CA_FILE.
  4. A zyonix.yaml in the folder the job runs in (or --config), with capture: full and a replay: section that tells Zyonix how to start your application (Set up). Set replay.config_provider so the cases test the configuration in this commit, not the one recorded when they failed.
  5. 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​

SuiteCasesWhen
canary (the default)a small, fast setevery commit or pull request
fullevery regression and golden casenightly, 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:

OptionUse it for
--no-recordthe server judges the outputs and classifies regressions, and stores nothing (for example on pull requests)
--no-uploadrun the cases and send nothing; nothing is judged. Only checks that your step runs
--k 3run each case 3 times; a case passes at 2 of 3. For models that are not deterministic
--use-recorded-configrun without a config_provider, with each case's recorded configuration (fixed cases then keep failing)

All options: zyonix test.

Exit codes​

CodeMeansWhat CI should do
0no regression (known-failing cases of unfixed issues do not count)pass
1at least one regressionfail the build
2could 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 recordedfail 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 resultIn JUnit
passeda passing test case
regressionfailure (turns the build red)
could not runerror
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).

Keys in CI

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.