Hiya folks :wave: I looking for some help with th...
# pactflow
m
Hiya folks šŸ‘‹ I looking for some help with the webhooks in PactFlow. The issue I am facing is that
contract_requiring_verification_published
is being fired even when there is no change in the contract from last ā€œlatestā€ published contract
This is what I am trying to do: 1. Consumer runs the contract tests 2. Consumer publishes the contract tests with
--consumer-app-version=${{git.sha}} --broker-token=${PACT_BROKER_TOKEN} --branch=${{ github.head_ref || github.ref_name }}
3. Provider runs the verification by pulling
latest: true contracts
4. Provider publishes the contract verification results with
providerBranch: ${PACT.mainBranch}
Till this point, everything works like a charm
Post the initial verification, 1. consumer creates another branch and does not change the contract (some README changes) 2. Consumer publishes the contract tests again with the same params. The
consumer-app-version
changes as per new Git commit and
--branch
also changes The following events are still fired:
Events detected: contract_published, contract_requiring_verification_published, contract_content_changed (pact content has changed since previous untagged version)
Webhook "Contract verification required " triggered for event contract_requiring_verification_published.
message has been deleted
I followed the documentation here . As per the documentation:
• If the relevant consumer version has any tags, then for each tag, check if the content is different from the previous latest version for that tag. It is ā€˜changed’ if any of the checks are true. One side effect of this is that brand new tags will trigger a pact changed event, even if the content is the same as a previous version.
• If the relevant consumer version has no tags, then check if the content has changed since the previous latest version.
I was expecting the
contract_content_changed
event to not fire because even though I have not supplied any ā€œtagsā€, the content is same as the previous latest (and verified) pact.
I intend to setup the webhook on
contract_requiring_verification_published
event to trigger the provider tests. However, since the event is fired even when the contract content is not changed, it defeats the purpose in my implementation.
I am hoping to get some help in debugging where I could be wrong or what part I could be missing
Another note: the
mainBranch
for provider and consumer has been set as
trunk
. using
pact-broker create-or-update-pacticipant
. The last verified pact was from
providerBranch = trunk
and the content of consumer contract did not change in the next publish
m
Thanks Mayank
I wonder if this statement needs to be expanded to include branches:
If the relevant consumer version has any tags, then for each tag, check if the content is different from the previous latest version for that tag. It is ā€˜changed’ if any of the checks are true. One side effect of this is that brand new tags will trigger a pact changed event, even if the content is the same as a previous version.
@Beth (pactflow.io/Pact Broker/pact-ruby) are you able to confirm if branches will behave like tags in this instance?
m
Hey folks! I missed something while debugging this. It turns out that in my test, the sample response was using faker library to create the
id
field in the response. It was an oversight on my part. My apologies sorry However, this makes me think that using fixture generators to create the sample response could be a popular use case. I am sure a lot of teams would like to use the same response as test data in their unit/functional and contract tests to reduce maintainability. I wonder how can Pact Broker be further improved to consider:
Copy code
Like({ id: integer(10) }) === Like({id: integer(11)})
and not trigger
contract_changed
event. Or, maybe trigger
contract_changed
but does not trigger
contract_requiring_verification_published
event
m
It’s something we have discussed before, I think. You could raise a request at pact.canny.io and see where it lands.
The issue is at the moment, the Pact Broker is not that aware of the contents of a pact file (it’s not entirely true, but mostly true). It certainly isn’t aware of matching rules, generators etc. It could be made to be aware, it’s just not at the moment
m
Thanks, Matt! I will raise a ticket here šŸ˜‰ I have another question but I feel that it is more suited for #C9VBGLUM9. šŸ™‚
šŸ‘ 1
b
@Beth (pactflow.io/Pact Broker/pact-ruby) are you able to confirm if branches will behave like tags in this instance?
Wow. This is greatly embarrassing. I think that logic needs updating for branches.
šŸ‘ 1
I’m amazed and appalled that I haven’t noticed this before. I’ve made an issue here https://github.com/pact-foundation/pact_broker/issues/602
šŸ‘ 1
Oh! I remember now. The branches work with the new event,
contract_requiring_verification_published
Not
contract_content_changed
I should update the docs.