Hey there! Hopefully this is the right channel. I'...
# pact-broker
k
Hey there! Hopefully this is the right channel. I'm piecing together my consumer/provider workflow, and I'm at a tricky intersection with
create-version-tag
for my pacticipant version. For reference, we're using GitHub Actions. I'm using the commit short SHA for my versioning, and the environment name as the tag. Our general development flow is: 1. Commit PR and run tests 2. Squash and merge 3. Deploy (This is handled in a separate GitHub Action file) My question is: When we squash and merge the PR into the target branch, the only commit reference for that branch is then the merge commit SHA, which doesn't align with the commit SHA that the contract was verified for. So what is the appropriate way to then run the
create-version-tag
command and reference the correct version for that particular environment?
b
I don't have the actual answer you want, but a couple of other things . . . • The final PR commit and the squash-merge commit are definitely different, so you probably don't want to assume they're equivalent. • If the contract is the same for both commits, the newer one will be pre-verified, so that doesn't sound like a major sticking point. Is there a problem with creating lots of version tags? Sounds like you might want to only tag things on your main branch, if so.
m
Side not: I think you probably want to actually start using branches and environments, not tags
👌 1
If the contract is the same for both commits, the newer one will be pre-verified, so that doesn’t sound like a major sticking point.
exactly. But to expand on this, the underlying assumption is that you should run the consumer contract test + publish steps (thus producing a new consumer version) in every build (even post merge). The contract should be pre-verified, and so you can deploy. If the second GitHub action doesn’t run the publish step, the version will be different and won’t have any published contracts to reference, to then determine compatibility with providers in the target environment.
🙏 1
k
Thanks for the clarification! That is definitely helpful. A follow up question on the flow, then, and apologies if I'm being a bit obtuse lol. I'm hopeful to get this right from the jump. What it sounds like is we would likely want to do the following (but please correct me if this is incorrect): ON PR: 1. Run the consumer test and publish on PR 2. Run
pact-can-i-deploy
using the
--to-environment=<environment>
flag and forget the
--to=<tag>
flag, post-test, pre-merge 3. Merge ON POST-MERGE/DEPLOY 1. Run the consumer test and publish on post-merge, pre-deploy 2. Run
pact-can-i-deploy
on post-merge, pre-deploy 3. Deploy 4. Run the
record-deployment
script post deploy (and skip
create-version-tag
altogether) And do something similarly on the provider side?
b
yes
you’ll see the pattern to use in the workshop you’re using now
it’s exactly the same for a PR and for the main branch.
k
Excellent, thank you! I really appreciate it.