ITV / scala-pact

A Scala implementation of CDC using the Pact standard
Other
107 stars 54 forks source link

Is it possible to publish pacts to broker with tag(s)? #107

Closed jnatten closed 5 years ago

jnatten commented 5 years ago

Here comes another question from me. Couldn't find it in the documentation but i was wondering if is there was a way to publish pacts with tags? I want to tag my published pacts with my branch name. (Also recommended by pact-foundation wiki: https://github.com/pact-foundation/pact_broker/wiki/Set-up-checklist#consumer-team)

Is there a way to do this with scala-pact or would i need to create some script?

jnatten commented 5 years ago

Doesn't seem like this is possible right now, would you like me to submit a pull request?

I could see it being implemented like this:

Publishing:

Publishing could be done doing a PUT /pacticipants/<consumer>/versions/<pact_version>/tags/<tagname> for every tag before publishing the pact itself here (This is how pact-broker cli does it). https://github.com/ITV/scala-pact/blob/602aeb08d76468503d109ab9ad56d636c2d8105d/sbt-scalapact-shared/src/main/scala/com/itv/scalapact/plugin/shared/Publisher.scala#L35

Verification:

Adding a pactBrokerWithTags class which is simply a copy of pactBroker with pactTags: List[String]: https://github.com/ITV/scala-pact/blob/0ac71482ede252929baafcf10493b15a83a33039/scalapact-scalatest/src/main/scala/com/itv/scalapact/ScalaPactVerify.scala#L224 and also add a similar field to PactVerifySettings: https://github.com/ITV/scala-pact/blob/0ac71482ede252929baafcf10493b15a83a33039/scalapact-shared/src/main/scala/com/itv/scalapact/shared/PactVerifySettings.scala#L5 This would be handled in Verifier around here, by making a copy of each unversioned consumer with version /latest/<tag> for each tag. (If tags is not empty) https://github.com/ITV/scala-pact/blob/0ac71482ede252929baafcf10493b15a83a33039/scalapact-core/src/main/scala/com/itv/scalapactcore/verifier/Verifier.scala#L32

Feedback is appreciated. I'm no expert so i might be doing something stupid :)

jnatten commented 5 years ago

@davesmith00000 I figured this was so small I just went ahead and did it. The PR is here: https://github.com/ITV/scala-pact/pull/111, feedback is appreciated :)