Hi , quick questions here, if we are using consume...
# pactflow
n
Hi , quick questions here, if we are using consumer driven contract testing, how can we publish the provider in github workflows, can we still use:
uses: pactflow/actions/publish-provider-contract@v0.0.2
Or is there some other way? As in the github workflows in this workshop I could not find any place where the provider contract was being published except in the test itself where it shows the code in the image i've attached.
👋 1
y
Hey, in CDCT, you don’t publish a provider contract, verification results are published by a provider build or trigger from a changed pact see here in the CI/CD workflow https://docs.pact.io/pact_nirvana/step_4#verifying-pacts Example workflow here for the new changed contract_requiring_verification_published webhook event https://github.com/pactflow/example-provider/pull/29
☝️ 1
🙌 1
m
BDCT - there are two contracts (consumer and provider contract) CDCT - just the consumer contract
1
f
more in depth: In BDCT, consumer publish a contract, it's expectations on how to use the API, and the Provider publish it's service contract (for example the OpenAPI spec of the service) plus (highly recommended) the API test verification results (that is if the service itself conforms to the spec). Pactflow then will see if both contracts are compatible (like if the consumer enum that it uses in the request is one of the enum valid values) In CDCT, consumer publish again the contract with it's expectation. The difference now comes in the Provider side. The provider will download a version of the contract, have a way to setup some provider state ( for example if the test requires it, add some data to the database) and run the request against the live service, and then it checks if the given response matches the consumer expectation (did we get a 204 instead of a 200, did all expected headers are passed)
🙏 1
n
I see, this makes sense but then what if on the consumer side we change the contract, now in the github actions how do we run that new contract against the provider automatically? I see that we can use webhooks but how would webhooks allows us to run the new contract against the provider in the consumer CI
y
you would use webhooks which trigger when a contract content changes on the consumer side, to trigger a build on the provider side. see https://docs.pact.io/pact_nirvana/step_6 If you cannot do that, but have access to the provider codebase, to be able to check it out in your SCM, you can use a webhookless workflow https://github.com/pactflow/example-consumer-webhookless
This workflow ensures changed pacts are verified immediately by checking out the provider codebase in the consumer's pipeline, and running the verification as part of the consumer's own tests.
n
This is great @Yousaf Nabi (pactflow.io) thank you very much. Is there any preference between using the webhooks approach verses the non webhooks approach of checking out the provider branch and running the tests there?
y
Webhooks, specifically https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event Are the recommendation, along with the WIP pacts and pending pacts features.