Hello Guys, I'm facing an issue with can-i-deploy...
# pact-js
n
Hello Guys, I'm facing an issue with can-i-deploy in pact and I'm getting this message: > There is no verified pact between version a85efd3be850cc56a9b of Foo and the latest version of Bar with tag nonprod (2fnrc0bf5a2dafa6e1252e) pact-consumer results: • Consumer -> passing & version is published • Provider -> Failing with ??? And above error is published that no verified version. The pact-broker version was upgraded from 2.79.1.2 to 2.106.0.0 and this where the error started. We're executing below commands in the pipeline: 1.
npx 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
Copy code
// 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);
});
 });
});
Copy code
package.json
"devDependencies": {
"@pact-foundation/pact": "^9.18.1",
"@pact-foundation/pact-node": "^10.17.4"
}
Environment: Mac & Windows Any help is appreciated :)
y
you are publishing and verifying with branches but using tags in can i deploy with the to parameter. you probably want to-environment=env_name the can i deploy output it telling you there isn’t a verification against that tag. is there in your matrix?
n
Thanks, trying build with to-environment. Yes, the matrix shows blank in case of the provider.
After adding to-environment, I am getting the following error:
There 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.
i
@Yousaf Nabi (pactflow.io), @Beth (pactflow.io/Pact Broker/pact-ruby) Could you please help us with this issue?
m
Please don't directly address maintainers, especially on weekends (probably why you aren't getting nee updates) The thread of conversation is already active. If you want to help, perhaps a view of the matrix to help us understand why can I deploy is failing but why you think it shouldn't. It's highly unlikely it's a bug, so it's likely the data points aren't lining up somehow
n
Hello guys, can you please share any approach I can try?
y
you’ve said in your first post you don’t have any provider verification
• 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
perhaps a view of the matrix to help us understand why can I deploy is failing but why you think it shouldn’t.
this
I’d recommend https://docs.pactflow.io/docs/workshops/ci-cd/ & https://docs.pact.io/pact_nirvana as exercises to understand how it all fits together
m
The problem is some data is not lining up. When you call
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