Question about best practices for picking up chang...
# general
p
Question about best practices for picking up changes to pactfile. Context: 2 microservices, called
PotatoConsumer
and
PotatoProducer
ireland 🥔 with separate everything - pipelines, repos, deployable artifacts. Owned by a full-stack team that communicates well.
PotatoConsumer
updates the Pactfile (for
$reasons
). The update would cause a failure in
PotatoProducer
because it no longer upholds this contract. HOWEVER, because the pipelines etc are all separate, the failure in
PotatoProducer
doesn't get picked up until the next time someone touches it, six weeks after `PotatoConsumer`'s deployment to production (let's assume it fails in a subtle and unnoticed way). What's the best way to avoid this without ending up with pipelines doing super weird things to each other?
🥔 1
j
Hi @Paula Muldoon 👋🏻 We currently have a setup, where this contract change would trigger a new build that would run the provider pact verification tests in the provider side (via a webhook configured in the pact broker) We’ve set it up in a way that if this build fails, it notifies the producer team via slack.
👌 1
Our setup is quite close to the platinum level. https://docs.pact.io/pact_nirvana/step_6
🙌 2
Hope that helps. Please let me know if I’ve misinterpreted your question. Happy to chat more if needed 👍
p
thanks @Jaswanth M! If the build fails, does it block anything on the consumer side?
👍 1
y
The consumer when they post their pact, if it has never been verified by the provider, will trigger a contact content changed and contract requiring verification published event. A provider build ( seperate from their usual build ) will be triggered to check out the code for all deployed/released versions of the provider and the head of the main branch to check comparability. Consumer would fail can I deploy, or can poll for a specified time to wait for the providers build to run. If the provider doesn’t have a sep build that it triggered by the contract changing, they can pick up the changes during their regular CI run by using Include WIP pacts Enable pending pacts. Wip pacts would allow the contracts published but not verified to be picked up by the providers ru. Enable pending on provider side would stop the consumers change a) failing the providers build so they can still deploy b ) block consumer until the provider has deployed a compatible change. I would expect consumer to back out change from main and then co ordinate on the change as a feature, that would allow consumers builds to continue for changes unrelated to that feature
Our ci/cd workshop covers these techniques and application of them Lesson 3 on here https://docs.pact.io/university It uses pactflow as the broker but you can switch out for an open source broker, the webhook commands will be slightly different https://github.com/YOU54F/path-to-pact-nirvana/blob/9831d9d18bc52b61f1608721601669493f86394e/Step_12_AddWebhookForProviderCIWhenConsumerChanges/Makefile#L24 As you can store secrets in Pactflow, so you create a token first that is parameterised in the webhook
Hey @Jaswanth M great answer. Curious has your team moved from tags for representing branches and environments, to branches/environments https://docs.pact.io/blog/2021/07/04/why-we-are-getting-rid-of-tags And are you using the new webhook event https://docs.pact.io/blog/2021/10/11/contract-requiring-verification-published-webhook-event
Loving the spud scenario 🙌
p
ooh thanks @Yousaf Nabi (pactflow.io) that's really interesting!
j
Hi @Yousaf Nabi (pactflow.io) 👋🏻 thanks for that ultra clear explanation 🙌🏻 1. Yup we’ve moved away from tags and use the branches instead 👍🏻 2. We are still perfecting our webhook setup. Since we don’t have dev or staging branches. We only have feature and main (Trunk based branching). We’ve been running through different scenarios to see how best we can set it up. Have you seen any approaches for trunk based branching before ? Would love to hear from you and the community.
t
HOWEVER, because the pipelines etc are all separate, the failure in PotatoProducer doesn’t get picked up until the next time someone touches it, six weeks after PotatoConsumer’s deployment to production (let’s assume it fails in a subtle and unnoticed way).
This shouldn’t be possible.
The
can-i-deploy
check for
PotatoConsumer
will fail because the contract has never been verified
so it shouldn’t be possible to deploy something that’s broken
(at least, broken in this way)
p
Happy new year! We are doing team programming tomorrow and trying out this demo. This all makes sense - thanks (didn't know the contract has to be verified) and
can-i-deploy
looks just the ticket.
y
Happy new year! Awesome sounds like fun, have a good day tomorrow 🚀 Feel free to reach out on here or send your teammates here is they have any other questions 🙂