Giter Site home page Giter Site logo

Comments (15)

davesmith00000 avatar davesmith00000 commented on May 21, 2024 1

There's a good chance that the documentation is missing. However I've had a look around (it's been a while!) and essentially all you do this add a flag to your SBT config:

scalaPactEnv := ScalaPactEnv.defaults
  .withPort(8080)
  .enablePublishResults("<provider version>", Option("<url to ci build>"))

Hope that helps!

from scala-pact.

davesmith00000 avatar davesmith00000 commented on May 21, 2024 1

Hi @sallareznov,

Sorry for the delay, I've been rather hectic lately.

400 is a bad request so it doesn't like something. I'm a bit suspicious of your use of the git commit id - not a bad idea but I don't know if pact broker will accept that. At one point it used to try and order by the version number for example.

Perhaps @jbwheatley or @dantb could have a dig though?

from scala-pact.

bethesque avatar bethesque commented on May 21, 2024 1

If it's a 400, the most likely reason is that the provider version number has not been provided.

Can someone update the scala code to print out out the body of the response whenever there is an error? The response body has the error description in it.

from scala-pact.

bethesque avatar bethesque commented on May 21, 2024 1

Btw, using the Git SHA is actually the recommended approach (earlier versions of the documentation often had a semantic version in the examples, but now we recommend the SHA). Docs here: https://docs.pact.io/getting_started/versioning_in_the_pact_broker#guidelines

from scala-pact.

davesmith00000 avatar davesmith00000 commented on May 21, 2024

Thank you for the question, I'm not sure when they added that feature to Pact Broker (available since 2.0 it seems) but I wasn't aware of it! How embarrassing... :-)

So put simply: Scala-Pact doesn't know how to do that right now, but I'll look into it.

The way we do this at ITV is simply that a failed verification causes the CI build to fail. CI builds are monitored as normal so the provider team will investigate and send a message to the consumer team. This works just fine for us, but I can see the use case. Truthfully I'd never even considered the need for such a thing, but thank you for making me aware of it.

As I said, I shall investigate.

from scala-pact.

rohith-vallabhaneni avatar rohith-vallabhaneni commented on May 21, 2024

Okay, thank you. Can I hope this feature in near future for Scala also?

from scala-pact.

davesmith00000 avatar davesmith00000 commented on May 21, 2024

No promises, but I have followed this up with the lovely people that make Pact Broker. If it's not too must work I'll try and squeeze it in. In the meantime, you may have to communicate with your colleagues the old fashioned way for a while. :-)

from scala-pact.

rohith-vallabhaneni avatar rohith-vallabhaneni commented on May 21, 2024

Sure, please let me know if you find any workaround :)

from scala-pact.

rohith-vallabhaneni avatar rohith-vallabhaneni commented on May 21, 2024

Hi @davesmith00000 , is there any update on the above issue

from scala-pact.

bethesque avatar bethesque commented on May 21, 2024

@davesmith00000 Sorry I didn't think to mention this to you. Until recently, I wasn't aware that the scala implementation existed as a separate entity. All the other implementations (apart from the php one which I recently discovered) either use the DiUS JVM code or wrap the Ruby implementation. I'll try to remember to keep you in the loop. I might set up an email list just for the maintainers.

Anyway, in regards to this issue, I've done a bit of an explanation of what is required here: https://stackoverflow.com/questions/47418840/publishing-results-of-pact-verify-to-pact-broker/47426111?noredirect=1#comment81817865_47426111

In summary, a configurable flag should allow the publishing to be turned on or off depending on context (eg. should only run from the CI). It should require that a provider application version is provided to be able to publish the results. The results should be published for both successes and failures, and should be based on the results for that pact alone, not the overall verification result.

Here's the verification results API documentation. https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/publish-verification-results.markdown

We're working on being able to publish the actual test results as well.

from scala-pact.

bethesque avatar bethesque commented on May 21, 2024

You can publish the individual test results JSON (any format currently, we haven't worked out a standard) using the testResults key.

from scala-pact.

davesmith00000 avatar davesmith00000 commented on May 21, 2024

This is now fixed on Master, many thanks to @garraspin. Will go out very shortly, but I need to update the docs to explain how to use it.

from scala-pact.

liquidarmour avatar liquidarmour commented on May 21, 2024

This is now fixed on Master, many thanks to @garraspin. Will go out very shortly, but I need to update the docs to explain how to use it.

Can you please point me to the documentation on using the results publishing?

from scala-pact.

sallareznov avatar sallareznov commented on May 21, 2024

Hi @davesmith00000 , do you have a working example using the setting enablePublishResults?
I've used it on my project, and when I run the command sbt "infrastructure/pactVerify --host localhost --port 8080 --clientTimeout 5", I encounter a Publish verification results failed with 400 error after the verification succeeds.
Do I need to give a token since I use credentials?
Here is my complete settings in SBT related to pact:

providerName := "xxx",
consumerNames := List("yyy"),
pactBrokerAddress := "<broker-address>",
pactBrokerCredentials := "<username>" -> "<password>",
scalaPactEnv := ScalaPactEnv.defaults
      .withClientTimeOut(5 seconds)
      .enablePublishResults("GIT_COMMIT", Some("https://<broker-address>/pacts/provider/xxx/consumer/yyy/pact-version/7f8374cf668ce96935bbbc753b7efd5410516572/verification-results")) // not sure about the url though

Thank you! :)

from scala-pact.

davesmith00000 avatar davesmith00000 commented on May 21, 2024

Thanks @bethesque, good to know!

from scala-pact.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.