Let's add a new field to the expectations we have for the product API. We're going to make the change on master, and it's going to break everything. This is an exercise in "what not to do, and why".
src/api.pact.spec.js, scroll down to the first test, and in the
expectedProductdefinition, add a new field e.g.
make test. These tests should be green - the consumer code is consistent with its own expectations.
Commit and push the changes.
👉 Note that in the
publish.pact.jsfile, the consumer version is tagged with the name of the git branch.
Open up the the consumer build in Github Actions. It will generate and publish the pact successfully, then fail on the
can-i-deploystep, as there is no successful verification from the provider.
Open up the provider build in Github Actions. The changed pact will have triggered a pact verification build of the provider project. This will have failed, as the new field does not exist in the API. This particular failed build is expected, and not a problem, as the pact verification build is generally separate from the provider's normal pipeline. For a more detailed explanation of this see https://github.com/pactflow/example-provider#pact-verifications.
The real problem is that the provider is now unable to deploy from their master branch 😧.
This is because the provider is configured to verify the latest
master pact, so publishing a pact with a new expectation and tagging its consumer version as
master causes the verification step to fail, breaking the provider's build through no fault of its own.
You can demonstrate this by running a provider build in Github (
Actions -> Under
Run workflow ->
Open up the pact in Pactflow. You'll see that there is a pact tagged
masterwith a failed verification result.
Click on "VIEW PACT" and you'll see that each interaction has a status next to it.
Expand the failing interaction, and you'll see the field level mismatches.
- A consumer build that is failing at the
can-i-deploystep in Github Actions.
- A provider build that is failing during verification in Github Actions.
masterpact in Pactflow that has a failed verification result.
Making changes to the pact for the on the master branch can break both consumer and provider builds, and may stop both projects from being able to deploy.