Publishing Pact Verification Statuses to Github

If you’re using Travis CI, Code Climate, or one of many other CI tools with Github, you’ve probably noticed the little checklist of items that shows just above the “merge” button when you open a pull request.

These are called commit “statuses”, and there is a Github API for reporting these (Gitlab also has a similarAPI). If you are using a git sha for the consumer version number when you publish your pacts, you can now use Pact Broker webhooks to report the verification statuses of your pacts back to Github.

To do this, open up your Pact Broker API Browser, and click on the NON-GET button next to the pb:webhooks relation. Modify the JSON below to match your consumer, repository and Github auth details (we recommend you make a separate token for this purpose with the repo:status grant), and click Make Request.

If all your consumer names match their repository names in Github, you can make this a global webhook by removing the consumer node and replacing the hardcoded project name in the URL with the parameter ${pactbroker.consumerName}.

Want to use this cool feature? You’ll need version 2.21.0 or later of the Pact Broker.

Check out the webhook template library for more handy webhooks.

This post first appeared on the pact blog here and is re-posted with permission.

NOTE: The Pact Broker is an open source tool that requires you to deploy, administer and host it yourself. If you would prefer a plug-and-play option, we’ve created Pactflow, a fully managed Pact Broker with additional features to simplify teams getting started and scaling with Pact and contract testing. You can get started quickly and for free on our Developer Plan

Want to know more about how DiUS can help you?

Offices

Melbourne

Level 3, 31 Queen St
Melbourne, Victoria, 3000
Phone: 03 9008 5400

DiUS wishes to acknowledge the Traditional Custodians of the lands on which we work and gather at both our Melbourne and Sydney offices. We pay respect to Elders past, present and emerging and celebrate the diversity of Aboriginal peoples and their ongoing cultures and connections to the lands and waters of Australia.

Subscribe to updates from DiUS

Sign up to receive the latest news, insights and event invites from DiUS straight into your inbox.

© 2024 DiUS®. All rights reserved.

Privacy  |  Terms