GitHub Actions
Run Parity on every pull request — the action's inputs and outputs, a complete workflow that starts base and head, the job summary, artifacts, exit codes and branch protection.
The Parity action runs parity compare in a workflow job, writes the result to the job summary, uploads the reports as an artifact and fails the job according to your policy.
#Status
Parity is pre-release, and that affects how you use the action today:
- The action lives in the
action/directory of the Parity repository. It is not published to the GitHub Marketplace, and the short namex1991labs/parity-action@v1used below is the intended interface, not something you can reference yet. - By default the action downloads a release binary and verifies its checksum. No release has been published yet, so for now you build the CLI in the job and pass it with
parity-path. A workflow you can run today shows how.
#The step
This is the interface the action is designed around:
- name: Check API behaviour
uses: x1991labs/parity-action@v1
with:
baseline: http://localhost:8080
candidate: http://localhost:8081
config: parity.yamlThe action does not start your API. Earlier steps in the job start the two versions; the action compares them.
#Inputs
| Input | Default | Meaning |
|---|---|---|
baseline | from the configuration | URL of the baseline environment (the version you trust). |
candidate | from the configuration | URL of the candidate environment (the version under review). |
config | parity.yaml | Path to the configuration file. |
working-directory | . | Directory to run in. Paths in the configuration resolve relative to the configuration file. |
baseline-revision | pull request base SHA, or the previous commit on push | Revision recorded for the baseline. |
candidate-revision | pull request head SHA, or the pushed commit | Revision recorded for the candidate. |
args | empty | Extra arguments for parity compare, e.g. --filter "workflow:*" --policy inconclusive=fail. |
version | latest | Release to install, e.g. v0.1.0. Ignored when parity-path is set. |
parity-path | — | Path to an existing parity binary. Skips the download. |
upload-artifact | true | Upload the JSON, HTML and JUnit reports as a workflow artifact. |
artifact-name | parity-report | Name of the artifact. |
artifact-retention-days | 14 | How long GitHub keeps the artifact. |
token | — | Project token for a hosted workspace. Optional; when empty the upload is skipped and the check still runs. |
api-url | https://parity.x1991labs.com | Hosted workspace URL, when token is set. |
#Outputs
| Output | Value |
|---|---|
verdict | pass or fail. |
exit-code | 0 pass · 1 behavioural changes · 2 environment errors · 3 configuration · 4 inconclusive. |
changed | Number of scenarios with behavioural changes. |
errors | Number of scenarios that could not be executed. |
inconclusive | Number of inconclusive scenarios. |
report | Path to the JSON report on the runner. |
#A workflow you can run today
This job checks out the pull request's base and head, starts both, builds Parity from source and compares them. Adapt the two "start" steps to however your service starts.
name: API behaviour
on:
pull_request:
permissions:
contents: read
jobs:
parity:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out the base commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- name: Check out the pull request
uses: actions/checkout@v4
with:
path: head
- name: Check out Parity
uses: actions/checkout@v4
with:
repository: x1991labs/parity
ref: main # pin to a commit SHA
path: parity
- name: Build the Parity CLI
run: cargo build --release --manifest-path parity/Cargo.toml -p parity-cli
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Start the baseline
working-directory: base
run: |
npm ci
PORT=8080 npm start &
- name: Start the candidate
working-directory: head
run: |
npm ci
PORT=8081 npm start &
- name: Wait for both
run: |
for port in 8080 8081; do
curl --silent --fail --retry 30 --retry-delay 1 --retry-connrefused "http://localhost:$port/health" > /dev/null
done
- name: Check API behaviour
uses: ./parity/action
with:
working-directory: head
baseline: http://localhost:8080
candidate: http://localhost:8081
config: parity.yaml
parity-path: ${{ github.workspace }}/parity/target/release/parityNotes:
- The configuration and the scenarios are taken from the pull request (
head), so a pull request can add scenarios for the behaviour it changes. If scenarios must not be editable by the pull request, setworking-directory: base. localhostis a local address, so mutating scenarios are allowed without further configuration. See the mutation guard.- Once releases exist, the three Parity steps collapse into the single step shown at the top.
#What the action does
- Install. Uses
parity-path, or downloads the release archive for the runner's platform (Linux and macOS, x86-64 and arm64) and refuses to continue unless its SHA-256 matches the publishedchecksums.txt. - Compare. Runs
parity compare --ciwith--output,--html,--junit,--summary "$GITHUB_STEP_SUMMARY"and--outputs "$GITHUB_OUTPUT", plus yourargs. - Upload reports.
report.json,report.htmlandjunit.xmlare uploaded as one artifact — also when the comparison failed. - Apply the policy. The job fails last, so the summary and the artifact exist even when the check does not pass.
Inputs reach the scripts through environment variables and are never interpolated into shell source, so a branch name or pull request title cannot inject commands. args is split into words but never evaluated.
#The job summary
The Markdown summary is appended to the job's summary page: a headline, the counts, the two environments with their revisions, and one collapsible table per changed scenario listing the step, the location and what changed.
## ✗ Parity — Behaviour changed in 14 of 89 scenarios
| Unchanged | Changed | Errors | Inconclusive | Skipped | Requests | Duration |
|---:|---:|---:|---:|---:|---:|---:|
| 73 | 14 | 0 | 2 | 0 | 209 | 0.0s |With --ci on GitHub Actions the CLI also emits workflow annotations for the results.
#Exit codes and branch protection
The job's conclusion follows the CLI's exit code:
| Exit code | Job | Message |
|---|---|---|
0 | passes | Parity: no policy violation. |
1 | fails | Behaviour changed. Review the differences in the job summary. |
2 | fails | An environment could not be reached. This is an execution failure, not a behavioural result. |
3 | fails | Parity could not run. Check the configuration. |
4 | fails | The comparison was inconclusive or compared nothing. |
To stop a pull request from merging while its behaviour differs, make the job a required status check: in the repository settings, add a branch protection rule (or ruleset) for your default branch, require status checks to pass, and select the job (parity in the example above).
What should and should not block is a policy decision. For example, to block on inconclusive results too:
- name: Check API behaviour
uses: x1991labs/parity-action@v1
with:
baseline: http://localhost:8080
candidate: http://localhost:8081
args: --policy inconclusive=failWhen a difference is intended, the check will keep failing until the baseline includes it, the scenario or an ignore rule is updated in the same pull request, or the policy for that job is relaxed. Parity has no notion of "approved" in the CLI; approvals are a hosted workspace feature and do not change the exit code.
#Recording revisions
Reports carry the revision deployed in each environment. The action fills them in from the event: base and head SHA on pull_request, previous and pushed commit on push. Set baseline-revision and candidate-revision when that is not what you deployed — for example when the baseline is the latest release tag.
The pull request number, repository, ref and a link to the workflow run are recorded as well.
#Pull requests from forks
Workflows triggered by pull_request from a fork run without secrets and with a read-only token. That is the safe default, and Parity is designed to work within it:
- The comparison itself needs no secret when both versions run on the runner.
tokenwill be empty. The action skips the upload and the check still runs and reports normally.- Do not switch to
pull_request_targetto get secrets into this job. It would run code from the fork — your API, its build scripts, the scenarios — with access to them.
If your API needs credentials to start, prefer throwaway values that exist only in the job. See untrusted pull requests.
#Pinning
Pin third-party actions to a full commit SHA rather than a branch or a moving tag, Parity included:
- uses: actions/checkout@v4
with:
repository: x1991labs/parity
ref: 0123456789abcdef0123456789abcdef01234567
path: parityWhen release binaries exist, also pin version (for example v0.1.0) instead of latest, so a new release cannot change the result of an unrelated pull request.