GitHub Action

Contract Validation and Spec Conformance in GitHub Actions

The Clear Signal Action downloads clrsig, checks the download against the release's checksum, runs one command and fails the step when the check fails. Use it for Spec Conformance of a running API, for your own scenarios, and to catch breaking changes in a spec.

Written for v0.21.0; inputs checked on 2026-11-30. It runs on x64 Linux and Windows runners, and on Intel and Apple silicon macOS runners. The release has no ARM download for Linux or Windows.

Quick start

Save this as .github/workflows/clrsig.yml. It checks the API on every pull request, sends only GET and HEAD requests, and keeps the reports as a build artifact.

.github/workflows/clrsig.yml
name: API conformance

on:
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  conform:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - uses: fuvito/api-workbench@v0.21.0
        with:
          version: v0.21.0
          command: conform
          spec: openapi.yaml
          base-url: ${{ vars.API_BASE_URL }}
          env: environments/ci.yaml
          read-only: 'true'
          report: |
            junit=reports/conform.xml
            html=reports/conform.html
        env:
          API_BASE_URL: ${{ vars.API_BASE_URL }}
          API_TOKEN: ${{ secrets.API_TOKEN }}

      - uses: actions/upload-artifact@v7
        if: always()
        with:
          name: conformance-report
          path: reports/

You need:

environments/ci.yaml
schemaVersion: "1"
name: CI
variables:
  - name: baseUrl
    value: "${API_BASE_URL}"   # read from the step's env:
  - name: token
    value: "${API_TOKEN}"   # read from the step's env:
    secret: true

Set both versions. @v0.21.0 chooses the version of the Action. The version input chooses the clrsig it downloads, and its default is the latest release. Without it, a new release can change your results although your workflow did not change. There is no v1 tag.

clrsig init github-actions --write writes a starting workflow like this one. Add version to it. Before the first run, clrsig conform openapi.yaml --list --env environments/ci.yaml shows which values each request needs, without calling the API. An operation with a missing value is not sent, and the step fails.

Upgrading from an earlier release

Security: up to v0.17.0, a checked server could be sent your secrets through conform --setup

What the setup scenario extracted was read as a template, so a server could answer with a reference to one of your environment variables and be sent its value. This affects clrsig 0.9.1 to 0.17.0, in the command line and the app. The Action's setup input is affected too: it runs clrsig conform --setup. Upgrade to 0.18.0 or later. The version input chooses which clrsig runs (by default the latest), so check it if you set it. If you ran it against a server you do not fully trust, replace the secrets that run could read.

From v0.19.0, a command: validate step fails a scenario whose specFile is a file that does not exist. A command: run without a spec says so in its output, and its JUnit report has a spec property; the result does not change.

From v0.18.0, a request that uses a ${NAME} that is not set is not sent and the step fails, so a run that passed can fail. Check the names of your secrets.

From v0.17.0, a command: run in which no step was sent is nothing checked, not passed. The step still exits 0, but a JUnit report holds a case nothing checked with an error, and the JSON report has outcome: "nothing-checked" and passed: false. The notes below are for 0.16.0 or earlier.

Up to v0.16.0, command: run ignored the spec input

The Action did not pass it on, and said nothing. Unless the scenario named a spec itself, responses were not compared with any spec, so a step could pass although the response broke your API's contract. From v0.16.1 it is passed on and replaces the specFile of each scenario, so a step that passed can fail. Remove spec to keep each scenario's own spec.

From v0.16.1, a spec that run cannot load, from spec or from specFile, also stops the step with exit code 2 before anything is sent. Earlier versions printed a warning, ran without the check and could pass.

scenario
# scenarios/smoke.yaml
schemaVersion: "1"
title: smoke
specFile: ../openapi.yaml   # relative to this file
steps:
  - label: list users
    request:
      method: GET
      url: "{{baseUrl}}/users"
      headers: [{ name: Authorization, value: "Bearer {{token}}" }]
    assertions:
      - { type: status, operator: eq, expected: 200 }
workflow step
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: run
    scenario: scenarios/smoke.yaml
    env: environments/ci.yaml
    format: github
  env:
    API_BASE_URL: ${{ vars.API_BASE_URL }}
    API_TOKEN: ${{ secrets.API_TOKEN }}

Up to v0.16.0, max-response-time-for did not work

With conform the limits were silently not applied, and with run the step failed with unknown flag. From v0.16.1 it applies to conform, so a slow operation can fail. With run it does nothing: use a duration assertion in the scenario.

workflow step
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: conform
    spec: openapi.yaml
    base-url: ${{ vars.API_BASE_URL }}
    read-only: 'true'
    max-response-time: '500'
    max-response-time-for: |
      /reports=2000

When a check fails

With format: github, each finding becomes an annotation on the pull request, on the line of the operation in your spec when the spec is a file in the repository. This step runs one failing case of the practice server:

workflow step
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: conform
    spec: specs/contract-fail.yaml
    base-url: http://localhost:8080/contract-fail
    env: clrsig/environments/contract-fail.yaml
    paths: /cases/resp-005-missing-required-field
    format: github

The Action's script, run with clrsig v0.21.0, printed these two lines. GitHub turns them into annotations:

log
::error file=specs/contract-fail.yaml,line=141,title=CS-RESP-005 GET /cases/resp-005-missing-required-field::"id" is missing from the response. Where: response body, field id. Why: The spec marks "id" as required, but the server's response did not include it. Fix: Return "id" from the server, or make it optional in the spec if it is not always present.
::notice title=Clear Signal conform::37 operations: 0 passed, 1 failed, 36 skipped. Limited by --paths /cases/resp-005-missing-required-field.

The annotation says what is wrong, where, why and how to fix it, with the check ID in its title. What the check means, with a fuller example, is in AC-005 A required field is missing.

GitHub shows only the first ten annotations of each kind per step in the pull request view; the log has all of them. This format prints annotations and a summary only, so keep a readable report with the report input.

Common setups

Check only what a pull request changed

Only operations that are new or changed in the spec are checked. A server fault with no spec change is not seen, so keep a full check on your main branch or on a schedule. A pull request that does not touch the API passes with NOTHING CHECKED.

workflow steps
- uses: actions/checkout@v7
  with:
    fetch-depth: 0   # the comparison needs the target branch's history
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: conform
    spec: openapi.yaml
    base-url: ${{ vars.API_BASE_URL }}
    changed-against: origin/main
    read-only: 'true'

Start on an API that already has problems

Record today's violations once in a baseline file, commit it, and fail only on new ones. Record it on your own machine, with API_BASE_URL and API_TOKEN set, so the file is there to commit. Use the same read-only setting as the workflow. A baseline cannot be recorded from a run limited by paths, tags or changed-against.

bash, once
clrsig conform openapi.yaml --base-url "$API_BASE_URL" \
  --env environments/ci.yaml --read-only \
  --write-baseline conform-baseline.yaml
workflow step
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: conform
    spec: openapi.yaml
    base-url: ${{ vars.API_BASE_URL }}
    env: environments/ci.yaml
    read-only: 'true'
    baseline: conform-baseline.yaml
  env:
    API_BASE_URL: ${{ vars.API_BASE_URL }}
    API_TOKEN: ${{ secrets.API_TOKEN }}

Review changes to the file in pull requests: a new entry means someone accepted a new problem. More in AC-026 The server drifts away from its spec.

Catch breaking changes in the spec

Compare the spec with its version on the target branch. Nothing is sent to your API. By default only breaking changes fail the step; fail-on can be warning or info. See AC-054 A spec change breaks existing clients.

workflow steps
- uses: actions/checkout@v7
  with:
    fetch-depth: 0
- uses: fuvito/api-workbench@v0.21.0
  with:
    version: v0.21.0
    command: diff
    base-spec: openapi.yaml
    against: origin/main
    format: github

Exit codes and results

The step fails when clrsig exits with a code other than 0.

CodeMeaning
0Nothing at the failing level was found in what was checked.
1A finding: a response breaks the spec, an assertion fails, a request could not be sent, a wrong request was accepted, or a change is serious enough to fail.
2The spec or the setup is broken, for example a file that cannot be read, or a filter that matches no operation.

The exit code is also in the step's result output. Steps that publish reports need if: always(), or they are skipped after a failure. A green run means nothing is wrong in what was checked; skipped operations do not fail it.

Safety

All inputs

"Used with" lists the commands the Action actually passes each input to. With any other command the input is ignored without a message. If your repository has a clrsig.yaml file, clrsig takes options a step does not set from it.

InputUsed withMeaning
command all run, conform, diff, validate or request.
version all The clrsig release to download. The default is the latest release.
spec conform, run, validate OpenAPI spec, a path or a URL. With run, responses are checked against it, in place of each scenario’s specFile.
scenario run, validate, request A scenario file; run also takes a folder.
env run, conform, validate, request Environment file. validate reads it only with strict.
base-url conform The server to call, instead of the spec’s servers list.
format run, conform, diff, validate, request text (default), json, junit, html, markdown or github. validate and request take only text and json.
output run, conform, diff, validate Write the report to this file.
report run, conform, diff Extra reports from the same run, one format=file per line.
var run, conform Variable overrides, one name=value per line. Not for secrets.
read-only conform Send only GET and HEAD. Other operations are skipped and never sent.
negative conform Also send deliberately wrong requests that the server should refuse.
setup conform A scenario to run first, usually a login. What it extracts is available to the requests.
tags conform Only operations with these comma-separated tags.
paths conform Only operations under these comma-separated path prefixes.
changed-against conform Only operations that are new or changed compared with the spec at this git ref. Needs fetch-depth: 0.
baseline conform Accept the violations in this file. Only new ones fail the step.
write-baseline conform Record the current violations in this file and succeed.
conform-fail-on conform failure (default) or warning. With warning, warnings also fail the step.
fail-fast conform Stop after the first failure.
explain conform Explain each failure in the text report.
coverage conform Add a summary of which operations were exercised.
request-timeout conform Time limit for each request, in milliseconds.
max-response-time conform Fail an operation that takes longer than this many milliseconds.
max-response-time-for conform Other response-time limits, one rule per line, for example /reports=2000.
base-spec diff The older spec.
revision-spec diff The newer spec.
against diff Compare base-spec with its version at this git ref. Needs fetch-depth: 0.
breaking-only diff Report only breaking changes.
fail-on diff breaking, warning or info: how serious a change must be to fail the step.
strict validate Also fail on weak scenarios, such as a step that checks nothing.