Nikesh Nagpal
10/13/2023, 11:01 AMnpx pact-broker create-or-update-pacticipant --broker-base-url=$PACT_BROKER_URL --broker-username=$PACT_BROKER_USER --broker-password=$PACT_BROKER_PSWD --name=Foo --main-branch=$CURRENT_BRANCH_NAME
2. npx pact-broker publish "./pacts/" --broker-base-url=$PACT_BROKER_URL --broker-username=$PACT_BROKER_USER --broker-password=$PACT_BROKER_PSWD --consumer-app-version=$GIT_COMMIT_SHA --branch=$CURRENT_BRANCH_NAME
3. npx pact-broker can-i-deploy --broker-base-url=$PACT_BROKER_URL --broker-username=$PACT_BROKER_USER --broker-password=$PACT_BROKER_PSWD --retry-while-unknown=5 --retry-interval=60 --pacticipant=Foo --version=$GIT_COMMIT_SHA --to=nonprod --main-branch --verbose
// this is the code for verifying pact provider
describe('Foo Provider', () => {
test('validates the expectations of API consumers', async () => {
const opts = {
"providerBaseUrl":"<http://localhost:3001/envname>",
"pactBrokerUrl":"<https://my-pact-broker>",
"pactBrokerUsername":"userName",
"pactBrokerPassword":"password",
"provider":"Foo",
"providerVersion": GIT_COMMIT_SHA,
"providerVersionBranch":"pact-testing-branch",
"consumerVersionSelectors":[
{
"mainBranch":true
},
{
"matchingBranch":true
}
],
"publishVerificationResult":true,
}
await new Verifier(opts).verifyProvider().then((output) => {
console.log(output);
});
});
});
package.json
"devDependencies": {
"@pact-foundation/pact": "^9.18.1",
"@pact-foundation/pact-node": "^10.17.4"
}
Environment: Mac & Windows
Any help is appreciated :)Yousaf Nabi (pactflow.io)
Nikesh Nagpal
10/13/2023, 11:49 AMNikesh Nagpal
10/13/2023, 1:39 PMThere is no verified pact between version 197831453a22289ffa89fc7adf of Foo and a version of Bar currently in nonprod (no version is currently recorded as deployed/released in this environment)Tried adding
npx pact-broker record-deployment --pacticipant=Foo --version=$GIT_COMMIT_SHA --environment=nonprod
and still the issue persists.Imthiyas Mohamed
10/15/2023, 3:05 AMMatt (pactflow.io / pact-js / pact-go)
Nikesh Nagpal
10/17/2023, 1:22 PMYousaf Nabi (pactflow.io)
• Provider -> Failing with ???
And above error is published that no verified version.
Yes, the matrix shows blank in case of the provider.With no verifications from your provider, can-i-deploy will never return true
Yousaf Nabi (pactflow.io)
perhaps a view of the matrix to help us understand why can I deploy is failing but why you think it shouldn’t.this
Yousaf Nabi (pactflow.io)
Matt (pactflow.io / pact-js / pact-go)
can-i-deploy
it looks into the target deploy location (e.g. environment), finds dependencies (e.g. providers), looks at the version of that provider, and then checks if that version of the provider satisfies the needs of the consumer you’re trying to deploy.
If the version of the provider in the target is not compatible with the consumer, you’ll get a failure.
So, the version of the provider that is deployed is not compatible with the version of the consumer you’re trying to deploy
How can that be?
1. There is a genuine problem
2. You haven’t deployed a version of the provider that has verified the contract
3. You are using non deterministic versions (version abc1
of the provider is what verified the contract, it was then merged and deployed which created a new version abc2
which has no verification status). This is another reason why each build should verify