10 Setting up contract testing in a CI/CD pipeline
This chapter covers
- Basic continuous integration/continuous delivery setup
- Advanced features to improve the continuous integration/continuous delivery setup
- Webhooks configuration and setup
In previous chapters, we showed you how to get started with consumer-driven contract testing (CDCT) using different types of consumers and providers. The examples we shared run from your local machines, and contract version numbers were changed manually.
To get the full benefit of contract testing, the consumer and provider tests need to be integrated into a continuous integration/continuous deployment (CI/CD) pipeline and triggered automatically when different teams push changes, especially if the changes concern the contract itself, to get a continuous feedback loop. In this chapter, we guide you on how to add your contract tests to a CI/CD pipeline step-by-step. We break it down so you know which steps concern the consumer and which steps concern the provider. We use GitHub Actions to demonstrate the integration of contract tests. However, the workflow should be similar if using other CI/CD platforms such as CircleCI, Jenkins, or GitLab. We also discuss advanced features such as versioning, branches, environments, deployments or releases, can-i-deploy tool, and webhooks to ensure you and your teams have a seamless workflow once contract tests are added to respective pipelines.