pactflow / swagger-mock-validator

Other
13 stars 4 forks source link

feat: add option to publish verification result to pact broker #53

Open AndreKlang opened 2 months ago

AndreKlang commented 2 months ago

Sorry for not opening an issue with discussion first, the company I work for needed to know if this was a viable option so we decided to spend an afternoon on it before exploring other avenues.

This is basically the bare minimum to be able to publish the results to the pact broker according to: https://docs.pact.io/pact_broker/advanced_topics/api_docs/publish_verification_result

I'm open to implement any changes you see fit.

YOU54F commented 2 months ago

That's okay!

Very cool. How has it been going for you in your POC?

Would you be happy to expand on your use case a little bit? I'm always curious :)

mefellows commented 2 months ago

One thing I should also mention, is that the broker fetching options currently in this project are the old way (via tags) which we don't recommend. If you want to go this route, I'd also suggest updating the process to fetch by consumer version selectors. This would allow the richer selection options for things like branches and environments - the recommended way to publish pacts.

I'm open to this PR though and would love to get your feedback on how you use it also.

AndreKlang commented 2 months ago

Well the POC went quite well, we're currently using this in our pipelines.

The reasoning why we want this is quite simple, given a few things:

So the only thing we really need is to verify that the new version of provider satisfies all current versions of consumers. And using swagger-mock-validator satisfies this, and it's basically a one-liner in the pipeline, which removes the need to implement any provider tests manually.

Regarding the "old broker fetching", that's probably something we'll have to look into, I didn't personally set that up in our case so I'm not really sure about the implications there..

mefellows commented 2 months ago

Thanks for sharing! Moving away from tags has a number of benefits, as linked. Another benefit is that tags are not as performant.

Are you using can-i-deploy as well?

AndreKlang commented 2 months ago

I've looked into the version-selectors a little bit, it looks pretty simple to implement support for it if we find that we need to. So it is possible that there'll be a PR for that as well in the future (no promises though 😄)

We're not yet, but that is absolutely a goal. We're sort of pre-production still, and setting up piece by piece in our infrastructure.