How not to break everything
When we made first made the change to the pact on the master branch of the consumer, we ended up with broken consumer and provider builds, stopping them both from releasing. In the previous step, we learned how to configure the provider so that it could still continue to be released, even if it was not able to successfully verify the new pact.
The consumer is still unable to make a release from its master however, as the can-i-deploy step correctly identifies that the verification for the master pact has failed. This is a reflection of the reality of the state of this integration - the API does not yet implement the features we require to deploy.
Let's make our changes on a branch this time.
Revert the change to master and push to make the build go green again.
git revert HEADgit pushCreate a new branch
git checkout -b feat/new-fieldAdd the new field to the
expectedProductagain (e.g.color: "red").Make sure the tests pass locally by running
make test.Push your changes by running
git push --set-upstream origin feat/new-field.- The consumer tests will pass, and then the CI build will fail as
can-i-deploycorrectly identifies that this branch is not yet compatible with the API. - The webhook-triggered pact verification build will still fail - that's ok, as it doesn't stop the provider from deploying.
- The consumer tests will pass, and then the CI build will fail as
๐ The can-i-deploy step acts as a "can I merge?" check when run from a branch. We'll know we're safe to merge this branch into master if/when can-i-deploy passes. ๐
Expected state by the end of this step
- In Travis CI:
- A
masterconsumer build that passes and deploys. - A
feat/new-fieldconsumer build that fails atcan-i-deploy.
- A
- In Pactflow:
- A
masterpact with a successful verification result. - A
feat/new-fieldpact with no verification results.
- A
Conclusion
By making changes on a branch of the consumer, and publishing a 'feature pact', we keep our main release branch green, and make sure we're not blocked from deploying. The can-i-deploy call acts as a "can I merge?" check when we're on a branch.