When a provider verifies contracts in CI/CD, it may need the consumer’s main contract, the contract from a matching feature branch, or both. A consumer version selector chooses those contracts using version metadata such as branches, deployments, or releases. section 10.2.2 section 10.3
Common selector properties include:
- mainBranch: verify the consumer contract published from its main branch. section 10.2.2
- matchingBranch: verify a consumer contract from the branch matching the provider branch. section 10.2.2
- deployedOrReleased: select consumer versions associated with deployment or release status. section 10.3
Provider verification configuration
A provider can publish its version and branch, then ask Pact to verify both the consumer’s main branch and the matching branch: providerVersion: process.env.GITHUB_SHA, providerVersionBranch: process.env.GITHUB_BRANCH, consumerVersionSelectors: [{ mainBranch: true }, { matchingBranch: true }]. If both teams work on a feature, they use the same branch name, such as test-pact-features. section 10.2.2
const options = {
…
providerVersion: process.env.GITHUB_SHA,
providerVersionBranch: process.env.GITHUB_BRANCH,
consumerVersionSelectors: [
{ mainBranch: true },
{ matchingBranch: true },
]
…
}
Inspect the complete provider options snippet showing automated versioning, branch identification, and selector configuration. section 10.2.2
