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
--getsAPIOME_MOCK_URL,APIOME_MOCK_CAPTURE_HEADERandAPIOME_MOCK_CAPTUREin its environment: point the tests at the mock and send the header.recordthen waits for the mock to store the calls. An earlier capture of the same consumer version is cleared first (--appendkeeps it), and--capture-urladds 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 withapiome pact publish. - The tests' exit code. When the tests fail,
recordexits 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 exits1with 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-actiontakescommand: recordwithmock,pacticipantandrun(npm test,pytest,go test ./...), plusmatching,publish,providerandtags. 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.
