Skip to main content

Publish verification results

When a provider build verifies a pact, its Pact verifier can publish the outcome to Apiome: did this provider version honour this pact? Apiome keeps every result, and can-i-deploy answers from them. The Pact verifiers publish to Apiome unchanged.

A successful result takes the pact out of the pending state for that provider branch (see Pending and work-in-progress pacts). To read the results in the app, with each mismatch's expected and actual values, open the provider's Verification page.

Before you start​

Publish from CI​

Turn publishing on in the verifier and give it the provider version and branch. With pact-js:

await new Verifier({
provider: 'Ledger API',
providerBaseUrl: 'http://localhost:8080',
pactBrokerUrl: 'https://api.apiome.dev/v1/tenants/acme/pact-broker',
pactBrokerToken: process.env.APIOME_API_KEY,
consumerVersionSelectors: [{ mainBranch: true }, { matchingBranch: true }],
publishVerificationResult: true,
providerVersion: process.env.GIT_COMMIT,
providerVersionBranch: process.env.GIT_BRANCH,
buildUrl: process.env.CI_BUILD_URL,
}).verifyProvider();

Publish only from CI. A result says "this provider version honours this pact", so publish it from the build that produced the version, not from a laptop. Use the commit SHA as the provider version.

For each pact it verified, the verifier then:

  1. Records the provider's branch on the provider version, through the provider's pb:branch-version link (PUT …/pacticipants/ledger-api/branches/main/versions/4f1e2d0). Provider tags, if you give any, go through pb:version-tag the same way.
  2. Posts the result to the pact's pb:publish-verification-results link.

Apiome registers the provider version if it does not have it yet.

What a result holds​

FieldWhat it is
successtrue when every interaction passed. Required.
providerApplicationVersionThe provider version that verified. Required.
buildUrlThe CI build that ran the verification.
testResultsOne entry per interaction, as the verifier sent it. A failed result keeps every mismatch. The Ruby verifier in the pact-cli image sends an object instead ({"tests": [...], "summary": ...}); Apiome keeps its tests list.
verifiedByThe verifier and the library around it (Pact-Rust 1.2.0 in pact-js 13).
providerVersionBranchShown in the answer: the branch the provider version was recorded on last — the one the verifier recorded just before publishing.
kindShown in the answer: native for a result a verifier published, bidirectional for one Apiome wrote by comparing the pact with a provider contract. A verifier cannot set it.

Apiome also records how each result came to be: published for a result a verifier posted, hosted, manual (a re-run) or stale-recheck for one its hosted verifier ran, with the run's duration and evidence run, and bidirectional for a comparison. The Pact Broker answer does not change; the Verification page and its REST endpoints show them.

  • A result never changes. Publishing again adds a new result; it does not replace one.
  • Bi-directional results are numbered with yours. When the provider also publishes a provider contract, Apiome's comparisons take numbers in the same sequence, and the latest result of either kind decides can-i-deploy.
  • Results are numbered per pact version: 1, 2, 3 … The answer is 201 with the result's URL in Location.
  • The pending state is kept. When the pact was fetched with selectors, the result records whether the pact was pending at that moment, and whether it was a work-in-progress pact (always pending).

If the provider was also checked by Apiome's own provider verification (a conformance report), link the report instead of copying it. Add its id to the body:

{
"success": true,
"providerApplicationVersion": "4f1e2d0",
"providerVerificationReportId": "6a0f…"
}

The answer then carries a pb:provider-verification-report link to the report. The report must belong to the same workspace; otherwise the result is refused with 422 pact-verification-report-not-found. Deleting the report later keeps the result and removes the link. Pact verifiers do not send this field.

Publish with curl​

curl -X POST \
"https://api.apiome.dev/v1/tenants/acme/pact-broker/pacts/provider/ledger-api/consumer/billing-service/pact-version/<sha>/verification-results" \
-H "Authorization: Bearer $APIOME_API_KEY" \
-H "Content-Type: application/json" \
-d '{"success": true, "providerApplicationVersion": "4f1e2d0", "buildUrl": "https://ci.example.com/builds/77"}'

<sha> is the pact version: the name of the pact's pb:pact-version link.

Upload a report in the app​

To attach a report by hand — a verifier you ran on your machine, or a CI job that could not reach Apiome — use Upload results.

  1. In the rail, under Ship, click Contracts, then the Verification tab.
  2. Choose the Provider under test.
  3. In the header, click Upload results.
  4. Choose the Consumer. The Pact version is set to that consumer's newest pact; choose Another pact version… to paste a SHA.
  5. Check the Provider version the verifier ran against (it is filled in from the page).
  6. Leave Report format on Detect, or choose Pact verifier JSON, JUnit XML, Schemathesis, Newman or Dredd.
  7. Drop the report on Drop the report here, or click Browse. The dialog says what Detect will read it as, such as Looks like a Dredd report (xunit XML). A file that is neither JSON nor XML is refused there, before anything is sent.
  8. Optionally open More options for the Branch, Build URL, Tags, Verifier and Verifier version.
  9. Click Upload results.
The Upload verification results dialog: Ran a verifier yourself? Attach its report to the pact it verified. Consumer Orders UI, Pact version 8d2f1c · consumer 3.4.0, Provider version 2.7.0+9f31c20, Report format Detect; the report dredd.xml with the line Looks like a Dredd report (xunit XML); More options; and The same, from anywhere with the apiome pact publish-verification-results command.The Upload verification results dialog: Ran a verifier yourself? Attach its report to the pact it verified. Consumer Orders UI, Pact version 8d2f1c · consumer 3.4.0, Provider version 2.7.0+9f31c20, Report format Detect; the report dredd.xml with the line Looks like a Dredd report (xunit XML); More options; and The same, from anywhere with the apiome pact publish-verification-results command.
Route/ade/dashboard/pacts/verification/new

The dialog then says what Apiome recorded, such as Recorded a failed result from a Dredd report: 1 interaction, and lists every note about what it could not use. A report Apiome cannot read is refused with the reason — for example format is dredd but the report is JSON — and nothing is recorded. The same, from anywhere shows the apiome pact publish-verification-results command and the REST call for the same upload.

You need Pacts → Create to upload.

Send a report from your own CI​

If your pipeline already runs pact_verifier_cli, Schemathesis, Newman, Dredd, or a test runner that writes JUnit, you do not need a Pact library to publish the result. Send the report and Apiome reads it into a verification result: the matrix, can-i-deploy, pending pacts and webhooks see it like any other.

# your usual pact_verifier_cli run, plus --json to write the report
pact_verifier_cli --file pacts/billing-service-ledger-api.json … --json report.json

apiome pact publish-verification-results report.json \
--provider "Ledger API" --consumer "Billing Service" \
--pact-version <sha> --provider-app-version "$GIT_SHA" \
--branch main --build-url "$CI_BUILD_URL"

The same request with curl. The version, build, branch and tags are query parameters because neither report format carries them:

curl -X POST \
"https://api.apiome.dev/v1/tenants/acme/pact-broker/pacts/provider/ledger-api/consumer/billing-service/pact-version/<sha>/external-verification-results?providerApplicationVersion=4f1e2d0&branch=main" \
-H "Authorization: Bearer $APIOME_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @report.json
ReportSend it asHow it is read
pact_verifier_cli --jsonapplication/jsonThe verifier's result is the verdict. Each entry of errors is a failed interaction with its mismatches; each entry of pendingErrors is kept and marked pending. A pacts[].interactions[] listing is read interaction by interaction.
JUnit XMLapplication/xmlEach <testcase> is an interaction. A <failure> or <error> fails it and its message is the mismatch. A <skipped> case was not replayed, so it makes the result unsuccessful.
Schemathesis --report ndjsonapplication/x-ndjsonOne interaction per operation (GET /invoices/{id}). It fails when any scenario of it failed or errored, and each failed check is a mismatch. Skipped scenarios tested nothing: they are noted, not counted. A stream without EngineFinished did not finish and is recorded as failed.
Schemathesis --report junitapplication/xmlRead as JUnit, recorded as Schemathesis.
Newman -r jsonapplication/jsonOne interaction per execution (request). Each failed assertion is a mismatch; a skipped assertion makes the result unsuccessful.
Newman -r junitapplication/xmlRead as JUnit. Choose format=newman to record it as Newman.
Dredd --reporter xunitapplication/xmlRead as JUnit, recorded as Dredd.

The format comes from the format query parameter (auto, pact-verifier-json, junit, schemathesis, newman or dredd), then the content type, then the body. With auto, JUnit whose suite is named schemathesis or Dredd Tests is that tool's, JSON with run.executions and collection is Newman's, and NDJSON with a Schemathesis Initialize event is Schemathesis'. A format the report does not match is refused with the report it expects. The other query parameters are providerApplicationVersion (required), buildUrl, branch, tag (repeatable), verifier, verifierVersion and providerVerificationReportId.

The answer is 201 with the stored result, plus an ingestion object:

{
"success": false,
"ingestion": {
"format": "pact-verifier-json",
"syntax": "json",
"interactions": 1,
"notices": [
{"pointer": "/output", "reason": "12 line(s) of verifier log output are not stored"}
]
}
}

Nothing is dropped silently. Every field the reader could not use, and every judgement it made (a result flag contradicted by the failures listed beside it, an interaction with no name, a skipped case) is a notice with a JSON Pointer or a //testcase[n] location. The CLI prints them. A report with no interactions and no result flag, an empty body and XML that declares a DTD or entities are refused with 422 pact-verification-invalid instead of being published as a pass.

note

Apiome records what the report says. It does not check that the report covers every interaction of the pact version, so keep the verifier's --file and the <sha> you publish for in step.

Read results​

To readRequest
The latest result for a pact versionGET …/pact-version/<sha>/verification-results/latest
One result, by its numberGET …/pact-version/<sha>/verification-results/1

Every pact links to its latest result with pb:latest-verification-results. A result links back to its pact with pb:pact-version.

When a result is refused​

StatusCodeWhat to do
422pact-verification-invalidThe body is malformed. pointer names the field — /success missing, /testResults not an array.
422pact-verification-invalidAn ingested report is empty, is neither JSON nor XML, proves nothing, names an unknown format, or is not what format names (pointer is /format).
422pact-verification-report-not-foundproviderVerificationReportId is not a report of this workspace.
400pacticipant-invalid-version, pacticipant-invalid-urlThe provider version has a leading or trailing space, or buildUrl is not an http(s) URL.
404pact-not-found, pacticipant-not-foundNo such pact version between the two applications.
404pact-verification-not-foundNo result with that number, or none yet.
401 / 403—The token is not a valid API key for this workspace, or its member lacks Pacts permission.

Who can do what​

ActionNeedsViewerEditorAdminOwner
Read resultspacts:view✓✓✓✓
Publish results, record a provider branch or tagpacts:create—✓✓✓