Hey all :wave: I have some questions about migrat...
# general
s
Hey all 👋 I have some questions about migrating from tags to native environments/branches with pact-broker, since the diamond step still prefers to use tags: On a PR branch, the environments docs recommend running
can-i-deploy
against all environments on the main branch, which makes sense to me, but: 1. From that PR branch CI pipeline, do we also need to run
can-i-deploy
against a main branch to catch any merged-but-not-deployed changes? 2. Is it still recommended to setup a webhook to trigger a provider verifications with native environments/branches? Since that doesn't sound like it recommends actually deploying those services changes from that
b
1. I think that's a good idea, but not necessary for "can I deploy" reasons.
2. I'm not quite sure what that means, maybe someone else will know the answer 😅
m
for 2, yes - the ‘contract requiring verification published’ event will consider branches/environments automagically for you. See https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event and https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event.
thankyou 1
also, sorry that the Nirvana guide hasn’t been updated with environments/branches. We had an excellent PR last year from a community member, and now we need to do something at least as good with environments/branches
s
Ah thank you! And yeah the nirvana guide is still pretty excellent
👍 1
For #1 is that just using
can-i-deploy --branch <main|master> ...
without any
--to
or
--to-environment
? Or should I continue using tags to tag the main branch and use
can-i-deploy --to myMainBranchTag
?
y
The CI/CD workshop has been updated https://docs.pactflow.io/docs/workshops/ci-cd/ to use our current best practise with branches / recording-deployments so might be useful
👀 1
For #1 is that just using
can-i-deploy --branch <main|master> ...
without any
--to
or
--to-environment
?
Believe so
Copy code
Usage:
  pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL

Options: 
     [--branch=BRANCH]
              # The branch of the version for which you want to check the
                verification results
Or should I continue using tags to tag the main branch and use
can-i-deploy --to myMainBranchTag
?
You could use tags, but ideally you have that main/master branch, set as a
mainBranch
in the pact broker (this is configurable per application) You want environments here
Copy code
Usage:
  pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL

Options: 
      [--to-environment=ENVIRONMENT]
              # The environment into which the pacticipant(s) are to be
                deployed
some background for a can-i-merge https://pact.canny.io/feature-requests/p/add-can-i-merge-functionality
We've actually got that as an open PR to add into the tool https://github.com/pact-foundation/pact_broker-client/pull/117
👀 1
s
Ahhh thank you! That's super helpful. So if I'm reading that right, it sounds like if my PR just checks a real
can-i-deploy
to all deployed environments, I don't really need the mainBranch check?
🙌 1
y
I believe that is the
TL;DR
of my ramblings 😅
s
Not ramblings at all 😅 Ok cool I think we can just go all in on that approach here
y
If you use the new webhook checks, when a consumer published a contract that requires verification, it checks against deployed, released and the head of your main branch, so those results all exist in the broker to be queried. If you provider wasn't compatible with deployed or released of consumers, it would fail verification and wouldn't get to can i deploy consumer side, they would still be valid to deploy if they were compatible with deployed or released, but not with provider HEAD of their main branch (and provider would have been stopped from deploying this anyway)
s
Ok thank you! And yeah I was looking at that too, I think the part I was missing was just documention for the whole "big picture" workflow of the new stuff -- I think your updated Nirvana guide will help with that a lot