pact-foundation / pact_broker

Enables your consumer driven contracts workflow
http://pactflow.io
MIT License
705 stars 173 forks source link

WebHook Trigger Events Regardless Of Whether Contract Changed #248

Closed sthomas1978 closed 5 years ago

sthomas1978 commented 6 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Docker Pact Broker Version : 2.27.2

I currently have the following setup

1 x Consumer 2 x Providers

The consumer has pacts for both providers.

I have a build process setup whereby

We run the consumer to generate all the pact files and upload them to pact-broker regardless of whether these have changed or not.

If the pact between the consumer and providers change then the pact-broker will trigger the contract_content_changed webhook to run the pact tests between the consumer and the specific provider and publish the results back to the pactbroker on the CI build server.

I then have the pact-broker use the provider_verification_published webhook to publish a commit status to git saying whether test worked.

The issue I have is that I want to make these github commit status's mandatory BUT if one of the contracts does not change, the web hook for contract_content_changed will not trigger, this will not trigger a CI Provider to run the tests and publish the results back to the pact broker, which in turn will not trigger the provider_verification_published to send a github status in repo so say it passed or failed.

Is there a way to trigger a webhook regardless of whether the contract changed or not?

If the way I have configured the build process is incorrect then let me know

Thanks

Simon

sthomas1978 commented 5 years ago

I dont think I need this now based on the way I have configured the integration process on Team City.

kuangp commented 5 years ago

I have this same issue described here for where the git status is not updated/reported when a PR is made but the contracts have not changed. Is there a workaround for this to trigger a webhook whenever contracts are published regardless of whether they have changed or not? perhaps a new web hook event for contract_published that can be used to trigger off of?

bethesque commented 5 years ago

This would be quite easy to do. It's just a matter of having the free time to do it, which I don't have a lot of right now. If you're keen enough to do a PR, I can show you where the code would need to change.

https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/pacts/service.rb#L138 lib/pact_broker/pacts/service.rb:138

I remember I deliberately made the event "CONTRACT_CONTENT_CHANGED" instead of PUBLISHED so that we could add one for PUBLISHED later.

Adding the event to this list should allow the API to accept the new value: https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/webhooks/webhook_event.rb#L14

kuangp commented 5 years ago

Hi @bethesque,

I'm not very familiar with developing in ruby but I attempted to make the change here: https://github.com/pact-foundation/pact_broker/pull/258

Please let me know what you think. Thanks!