Do I have to prevent a consumer `feature branch` t...
# pact-broker
s
Do I have to prevent a consumer
feature branch
to merge to
master
if pre-verification fails? Because
can-i-deploy
command is to check whether a code can be deployed to a specific env (
dev, test, prod and etc
..) or not. Which means a
non-verified contract
can be merged to
master
there is no check to enforce that. Should we check with
can-i-deploy
command before the code get merged to
master
?
s
You'd get most safety this way, yes. Consider reading CI/CD Integration guide about Step "Platinum" pact nirvana
s
That is great but
tags
are deprecated in that case do we have to create an
environment
to represent
master/any stable branch
.
can-i-deploy
requires an environment isn't it?
s
It's not bound to working with
environment
only, consider readme: https://docs.pact.io/pact_broker/client_cli/readme#can-i-deploy
Would anyhow recommend using
environment
and
branch
now, as its more readable and tends to confuse people less compared to `tag`s that get confused with the GIT concept.
s
No, I am trying to switch to
contract requiring verification published
web-hook event from
contract content changed
event. From their doc they recommend use
main branch
and
environment
. Thank you for your guidance I should have read the docs properly lol
s
it depends how much safety you want, you could also setup the
can-i-deploy
to check your other environments for sure, e.g.
prod
sounds reasonable
I could even imagine to chain more than 1
can-i-deploy
together
s
I already have
can-i-deploy
checks for
dev environments
and
prod
but I didn't have a check (
can-i-deploy
) for
feature branch
to
master
for consumers.
👍 1
b
if you run can-i-deploy for every branch, it acts as a can-i-merge by default.
it’s saying “could this feature branch be deployed to your test environment”
It depends if you want to hold off merging until your code can be deployed, or if you just want to merge as soon as your feature branch is compatible with the main branches of the integrated services.
s
Our pipeline defined such a away that every
PR branches
will be merged into
master branch
then we deploy the
master
to
dev environment
. I think I can validate a new contract
can-i-deploy
with
--branch PR BRANCH
before it gets merged with
master
@Beth (pactflow.io/Pact Broker/pact-ruby) Is
can-i-merge
command available? Looks like it is still in progress right? https://pact.canny.io/feature-requests/p/add-can-i-merge-functionality
Do we have to do a similar check for provider CI/CD (
can-i-deploy
--branch PR-PROVIDER
) ? I think we don't need that
b
I’ve made an endpoint for can-i-merge, but I still need to add the CLI for it.
you should still use the version number for can-i-deploy, not the branch name.
branch builds can run concurrently, so that makes using the branch name unreliable.
can you let me know if you want to merge 1. when your feature branch is compatible with the main branch of the provider OR 2. when the feature is supported in the dev environment
If you go with 1 (merge when consumer is compatible with provider’s main branch) but the provider has not deployed the main branch to dev, then your consumer main branch will be blocked from deployment until the provider has deployed.
This is why I suggest to use exactly the same can-i-deploy command, regardless of whether it’s the feature branch or main branch.
can-i-deploy --pacticipant $APP_NAME --version $GIT_SHA --to-environment dev
will tell you when it’s safe to deploy from main into dev when you’re on main, and will tell you when it’s safe to merge feature branch into main when it’s on a feature branch.
s
I would do the 1st option.
It makes all sense now. Thank you
d
Hi @Beth (pactflow.io/Pact Broker/pact-ruby). Your suggestion about using can-i-deploy looks logical. In my company we're just adopting contracting testing and haven't reached the point of using 'environments'. But do want to prevent Consumer PR from merging to 'main' without validation against Provider's 'main'. That's why I'm curious are you planning to roll out the update to CLI related to 'can-i-merge' in the nearest future? Thank you in advance
b
That makes sense. I’ll see if I can get it prioritised @David Hvilava
You can use can-i-deploy for this purpose now, but you’ll need to state all the dependencies explicitly.
And don’t specify a
--to TAG
or
--to-environment ENV