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.

10.1 Basic CI/CD setup for the consumer and provider

10.1.1 Setting up GitHub Actions

10.1.2 Example configuration for other CI/CD platforms

10.2 Advanced features to improve the CI/CD setup

10.2.1 Configuring consumer and provider versions

10.2.2 Configuring branches

10.2.3 Creating environments

10.2.4 Recording deployments and/or releases

10.2.5 Using the can-i-deploy tool

10.3 Chapter exercises

10.4 Webhooks

10.4.1 Creating the Pact webhook

10.4.2 Creating a different GitHub workflow for provider verification

10.4.3 Updating provider options

10.4.4 Retries for can-i-deploy

10.4.5 Testing the webhook

Summary