Skip to main content

apiome pact record and the GitHub Action record command

A consumer's pipeline can now publish a pact from its ordinary tests, with no Pact library. apiome pact record runs the tests against the hosted mock, turns the calls they made into a pact and publishes it when they pass. The GitHub Action does the same with command: record. See Record from a pipeline.

apiome pact record --mock billing-api/2.7.0 --consumer "Orders UI" --publish -- npm test
  • Start, run, stop. The command after -- gets APIOME_MOCK_URL, APIOME_MOCK_CAPTURE_HEADER and APIOME_MOCK_CAPTURE in its environment: point the tests at the mock and send the header. record then waits for the mock to store the calls. An earlier capture of the same consumer version is cleared first (--append keeps it), and --capture-url adds a private capture URL for clients that cannot add a header.
  • Generate and publish. The pact is written to pacts/<consumer>-<provider>.json (--matching exact|type|spec). With --publish, and only when the tests passed, it is published with the branch, tags and build URL. The version defaults to the commit and the branch to the CI's or git's, as with apiome pact publish.
  • The tests' exit code. When the tests fail, record exits with their code, so the job fails as it did before. When they pass but nothing was recorded, nothing could go in a pact, or the publish was refused, it exits 1 with the reason. Every call that does not reach the pact is reported: refused by the mock, left out by the generator, or a field left out of an interaction.
  • The GitHub Action. apiome/pact-action takes command: record with mock, pacticipant and run (npm test, pytest, go test ./...), plus matching, publish, provider and tags. The tests' output streams to the log; the job summary and the pull-request comment show the report.

Generate a pact from a mock now shows its choices as an apiome pact record command and a GitHub Action step in The same, from anywhere.