Conformance and compatibility, together
restep-check says whether the API follows the specification. restep-diff says whether this pull request breaks what was already there. One step runs both.
Tools · Keep it compatible · v0.2.1
restep-actionEvery pull request, checkedA GitHub Action that starts your API, runs restep-check and restep-diff against the base branch, and keeps a single comment on the pull request up to date.
GitHub Actions · uses: restep-spec/restep-action@v0
restep-check says whether the API follows the specification. restep-diff says whether this pull request breaks what was already there. One step runs both.
It writes the result to the job summary and, if you want, to the pull request. Always the same comment, edited on every push, instead of a new one each time.
Give it the command and the URL to wait for. It stops the API at the end even when something failed, and shows the API’s log if it never came up.
Input values reach the scripts as environment variables, never pasted into shell code. A value with quotes or $() is just a value.
It is a composite action: five steps, each one node action.mjs <step>, with Node 18 or later and no dependencies. GitHub’s runners already have Node.
start-command, it runs it in the background from the workspace and waits until wait-for answers with any HTTP status. Otherwise it uses the API already running at url.--json (and --writes if you ask), and checks that the API announces every profile and extension in profiles.base-discovery, it fetches the current discovery document from url and compares it with the base one using restep-diff, failing on breaking changes (5.5).$GITHUB_STEP_SUMMARY), with the version the API declares in restep (1.1: a 1.0-draft.6 or a 1.0-rc.1 shows as a draft or a candidate, without the guarantees of a published version, and another major version, or one that does not follow the grammar, as “not Restep 1”), an annotation for each failing MUST (the first ten), and, with comment: true, the pull request comment.Nothing to install: it lives in restep-spec/restep-action. Reference it from a workflow step after actions/checkout, pinned to the major version (@v0) or to an exact release (@v0.2.0):
- uses: restep-spec/restep-action@v0
with:
url: http://localhost:3000/
start-command: npm start
It runs restep-check and restep-diff from npm with npx, each at the minor version that follows draft 6: npx --yes restep-check@0.9 and npx --yes restep-diff@0.2. Pass another command in the input to pin a different one.
A Node API that keeps its discovery document in api/discovery.json, starts with npm start on port 3000 and needs a token.
# .github/workflows/restep.yml
name: Restep
on: pull_request
permissions:
contents: read
pull-requests: write # only for comment: true
jobs:
restep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm ci
# The base branch's discovery document, if the repository keeps it in a file
- name: Base discovery
run: git show "origin/${{ github.base_ref }}:api/discovery.json" > "$RUNNER_TEMP/base.json"
- uses: restep-spec/restep-action@v0
with:
url: http://localhost:3000/
start-command: npm start
wait-for: http://localhost:3000/health
profiles: core,query,writes
writes: true
base-discovery: ${{ runner.temp }}/base.json
comment: true
headers: |
Authorization: Bearer ${{ secrets.RESTEP_TEST_TOKEN }}
writes: true lets restep-check create, change and delete its own items: fine for the test API the job starts, not for production. Authorization is masked in the log.
If the base branch runs somewhere, such as a staging environment, base-discovery can be its URL and the action fetches its discovery document. The headers only go there if it has the same origin as url (4.3). If a root is not a discovery document and points to one with Link: rel="service-desc", the action follows the first target that is one, but not one whose scheme is neither https nor the root’s (data:, file:, 3), and it sends no headers to another origin.
- uses: restep-spec/restep-action@v0
with:
url: http://localhost:3000/
start-command: npm start
base-discovery: https://staging.example.com/v1/
This is a run against the reference server, asking for the profiles and extensions it announces, with a base document that still had one more sort and a higher max_limit. Everything asked for is announced, but the job fails on the breaking changes, with an error annotation.
## Restep con problemas: http://localhost:8080/
| | |
|---|---|
| Conformidad | sin fallos de DEBE · 0 avisos · 311 correctas · 19 omitidas (restep-check 0.9.1, solo lectura) |
| Versión declarada | `1.0-draft.6`: borrador 6 de 1.0: sin las garantías de una versión publicada (§1.1) |
| Perfiles | core, query, writes, cache, relations, actions, inherit |
| Compatibilidad | **cambios incompatibles** con `base.json` |
### Compatibilidad (restep-diff)
## Cambios en la API
Comparación de `…/base.json` con `…/restep-action/new-discovery.json` según las reglas de evolución de [Restep 1](https://restep.wubytes.com/es/1/#versiones).
**2** incompatibles · **0** retiradas y avisos · **0** compatibles · **0** otros
### Incompatibles
- «books» deja de admitir ordenar por «author» sin aviso previo en deprecations (`/collections/books/sort`; [§5.5](https://restep.wubytes.com/es/1/#versiones), [§6.2](https://restep.wubytes.com/es/1/#orden))
- max\_limit de «books» pasa de 100 a 50 sin aviso previo en deprecations (`/collections/books/max_limit`; [§5.5](https://restep.wubytes.com/es/1/#versiones), [§6.4](https://restep.wubytes.com/es/1/#paginacion))
…
When restep-check finds failures, they come as a table (check, where, detail, level and section), with the warnings folded underneath. The report is in Spanish for now.
| Input | Default | What it does |
|---|---|---|
url | required | The API root, such as http://localhost:8080/ |
start-command | Command that starts the API in the background, from GITHUB_WORKSPACE. Its output goes to $RUNNER_TEMP/restep-action/server.log, shown if it does not come up. The action stops it at the end | |
wait-for | url | URL that must answer, with any HTTP status, before going on. Only with start-command |
wait-timeout | 60 | Maximum seconds to wait for it |
profiles | Profiles and extensions the API must announce, separated by commas or spaces: core,query,writes | |
writes | false | true passes --writes to restep-check: it creates, changes and deletes its own items |
headers | Headers for every request, one per line. Empty lines and lines starting with # are ignored. Authorization does not show in the log | |
base-discovery | The base branch’s discovery document: a file (relative to GITHUB_WORKSPACE) or a URL. Without it, there is no comparison | |
comment | false | true comments on the pull request (needs pull-requests: write). Outside a pull request it only writes the summary |
fail-on-error | true | Fails the job if a MUST fails, a profile is missing, there is a breaking change, or something could not be checked |
restep-check | npx --yes restep-check@0.9 | Command that runs restep-check (0.9 checks draft 6; until it is on npm, pass another command). The action appends the URL, --json, --writes and -H for each header |
restep-diff | npx --yes restep-diff@0.2 | Command that runs restep-diff. The action appends both files, --markdown and --fail-on breaking |
github-token | github.token | Token gh uses to read and write the comment |
| Output | Value |
|---|---|
result | pass or fail |
check-failures | Number of MUST checks that fail |
breaking | true if restep-diff finds breaking changes |
summary-file | Path of the Markdown report: the same as the summary and the comment |
With fail-on-error: false the job goes on, and you decide with these, for instance if: steps.restep.outputs.breaking == 'true' (give the step an id: restep).
GITHUB_* variables, each step’s if:, outputs, and doubles for gh.bash: on Windows runners it needs Git Bash, which GitHub’s include.start-command is stopped with SIGTERM to its process group. Children in another group are left for the runner to clean up at the end of the job.url in the same pull request share one comment.discovery.version.uses: restep-spec/restep-action@v0 it has to be published in its own repository. Until then, copy the folder into your repository and use uses: ./path/to/restep-action.Compares two discovery documents and sorts every change into breaking, deprecation or compatible. Ready for a changelog or a pull request.
A reverse proxy that checks real traffic against the contract: 64 rules, live log, JSON report, and a strict mode for CI.