Restep2½

Tools · Keep it compatible · v0.2.1

restep-actionEvery pull request, checked

A 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

Why use it

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.

One comment, kept up to date

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.

Starts and stops your API

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.

No injection through inputs

Input values reach the scripts as environment variables, never pasted into shell code. A value with quotes or $() is just a value.

How it works

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.

  1. Start. If you give it 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.
  2. Check. It runs restep-check with --json (and --writes if you ask), and checks that the API announces every profile and extension in profiles.
  3. Compare. If you give it 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).
  4. Report. Always, even when an earlier step failed. It writes the job summary ($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.
  5. Stop. It stops the API it started, whatever happened before.

Install it

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.

Examples

The whole workflow

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.

The base branch is deployed

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/

What the comment says

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.

Inputs

InputDefaultWhat it does
urlrequiredThe API root, such as http://localhost:8080/
start-commandCommand 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-forurlURL that must answer, with any HTTP status, before going on. Only with start-command
wait-timeout60Maximum seconds to wait for it
profilesProfiles and extensions the API must announce, separated by commas or spaces: core,query,writes
writesfalsetrue passes --writes to restep-check: it creates, changes and deletes its own items
headersHeaders for every request, one per line. Empty lines and lines starting with # are ignored. Authorization does not show in the log
base-discoveryThe base branch’s discovery document: a file (relative to GITHUB_WORKSPACE) or a URL. Without it, there is no comparison
commentfalsetrue comments on the pull request (needs pull-requests: write). Outside a pull request it only writes the summary
fail-on-errortrueFails the job if a MUST fails, a profile is missing, there is a breaking change, or something could not be checked
restep-checknpx --yes restep-check@0.9Command 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-diffnpx --yes restep-diff@0.2Command that runs restep-diff. The action appends both files, --markdown and --fail-on breaking
github-tokengithub.tokenToken gh uses to read and write the comment

Outputs

OutputValue
resultpass or fail
check-failuresNumber of MUST checks that fail
breakingtrue if restep-diff finds breaking changes
summary-filePath 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).

Limits

  • It has not run on GitHub for real yet. Its tests simulate the runner: the GITHUB_* variables, each step’s if:, outputs, and doubles for gh.
  • Only bash: on Windows runners it needs Git Bash, which GitHub’s include.
  • The API started with 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.
  • The comment is found by a marker with the API URL: two runs with the same url in the same pull request share one comment.
  • It is not a client of the API: conformance is restep-check’s job and compatibility restep-diff’s. If the declared version is not Restep 1 the summary says so; the check that fails is restep-check’s discovery.version.
  • To use it as 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.
  • The specification does not say how to get a previous discovery document. The comparison needs the repository to keep it, or the base version deployed somewhere.

restep-diff

Compares two discovery documents and sorts every change into breaking, deprecation or compatible. Ready for a changelog or a pull request.

· restep-diff on npm

All the tools