question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Publishing Results Using URI Sources

See original GitHub issue

Existing State

Currently, PactNet only supports publishing verification results using the Broker source, like this:

string version = Environment.GetEnvironmentVariable("GIT_SHA");
string branch = Environment.GetEnvironmentVariable("GIT_BRANCH");
string username = Environment.GetEnvironmentVariable("BROKER_USERNAME");
string password = Environment.GetEnvironmentVariable("BROKER_PASSWORD");

verifier.ServiceProvider("My API", this.fixture.ServerUri)
        .WithPactBrokerSource(new Uri("https://broker.example.org"), options =>
        {
            options.EnablePending()
                   .ConsumerVersionSelectors(new ConsumerVersionSelector { MainBranch = true })
                   .PublishResults(version, publish => publish.ProviderBranch(branch)); // 👈 enable publishing results
        })
        .Verify();

Proposed API

It should be possible to publish verification results to a Pact Broker when using a URI source, as recommended in some of the Pact CI/CD setup guides. In these flows, a verifier is triggered from a webhook with the URI of the pact that has changed (instead of all pacts). The verifier should then pull the pact from this URI, verify just this one pact, then publish results back to the broker.

The API would be something like:

Uri uri = new Uri(Environment.GetEnvironmentVariable("PACT_URI")); // 👈 from the webhook

verifier.ServiceProvider("My API", this.fixture.ServerUri)
        .WithUriSource(uri, options =>
        {
            options.BasicAuthentication(username, password)
                   .PublishResults(version, publish => publish.ProviderBranch(branch)); // 👈 new
        })
        .Verify();

Open Questions

  • How is the broker URI discovered?
    • Is it inferred from the webhook URI itself?
    • Is that even safe?
    • What if you retrieve the pact from any old URI and then try to publish results as if it’s a broker?
    • Should we force people to provide the broker URI instead? That seems the safest solution
    • Answer: The pact file itself will contain a link to publish verification results if it was retrieved from a Pact Broker. Thus, if the link is missing then the publish option shouldn’t do anything, and if it is present then publshing can be safely achieved.
  • What support is available in the FFI for this?
  • Should other types of sources be supported as well? e.g. could a CI job put the pact file somewhere, then a file source verifies it and publishes the verification results?
    • Answer: No, at least not for now

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
adamrodgercommented, Jul 14, 2022

It’s in 4.1.0

2reactions
adamrodgercommented, Jul 13, 2022

Added in c44c919

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - URI Open Access Fund
No. Authors are free to publish wherever they want. Their choice is only restricted if they wish to apply for funding from the...
Read more >
Best Practices for Publishing Linked Data
STEP #5 GOOD URIs FOR LINKED DATA: The core of Linked Data is a well-considered URI naming strategy and implementation plan, based on...
Read more >
Frequently Asked Questions - URI Open Access Policy
In practice, you have given the University permission to reproduce, display, and distribute your articles as long as the articles are not sold, ......
Read more >
Government Publications – University Libraries
Most government publications and web resources are available through the URI Libraries Search platform. Many research guides to finding government publications ...
Read more >
Wiley's Data Sharing Policies
“[Journal] encourages authors to share the data and other artefacts supporting the results in the paper by archiving it in an appropriate public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found