Add support for branches in consumer version selectors
See original GitHub issueThe Pact Broker now supports branches as first class entities. You can read more about this here: https://docs.pact.io/pact_broker/branches
Description
Please add support for specifying branch related properties in the consumer version selectors that are sent to the Pact Broker when requesting pacts to verify. Please do not do any verification of the consumer version selectors on the client side - the validation rules are subject to change. Just ensure that any error response is displayed to the user.
- For implementations that wrap the pact-ruby-standalone, update to the latest standalone version
- For implementations that use the rust implementation, update to the latest rust version.
- Add a String
branch
property to the consumer version selector (if there is a domain model for this). - Add a Boolean
mainBranch
(ormain_branch
for snake case languages) property consumer version selector (if there is a domain model for this). - Add a Boolean
matchingBranch
(ormatching_branch
for snake case languages) property consumer version selector (if there is a domain model for this). - Expose and document the
branch
,mainBranch
(ormain_branch
for snake case languages) andmatchingBranch
(ormatching_branch
) properties in the user facing API. - Pass the
branch
,mainBranch
andmatchingBranch
(must be camelcase) through to the relevant implementation (ruby and/or rust)
Verifying the changes
- Publish test pacts to the test broker
export PACT_BROKER_BASE_URL="https://test.pact.dius.com.au"
export PACT_BROKER_USERNAME="dXfltyFMgNOFZAxr8io9wJ37iUpY42M"
export PACT_BROKER_PASSWORD="O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_USERNAME \
-e PACT_BROKER_PASSWORD \
pactfoundation/pact-cli:0.50.0.14 \
publish \
/pact/example/pacts \
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
--branch main
docker run --rm \
-e PACT_BROKER_BASE_URL \
-e PACT_BROKER_USERNAME \
-e PACT_BROKER_PASSWORD \
pactfoundation/pact-cli:0.50.0.14 \
publish \
/pact/example/pacts \
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
--branch feat/x
- Using your pact client library, verify
{ "mainBranch": true }
- You should receive the main pact
- Using your pact client library, verify
{ "branch": "feat/x" }
- You should receive the feat/x pact
- Using your pact client library, verify
{ "matchingBranch": true }
with the provider branch set tofeat/x
- You should receive the feat/x pact
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:19 (18 by maintainers)
Top Results From Across the Web
Consumer Version Selectors | Pact Docs
Consumer version selectors are the (new) way to configure which pacts the provider verifies. Instead of providing a list of tag names (as...
Read more >Prerequisite concepts | Pactflow Documentation
Branches in the Pact Broker are designed to model repository (git, svn etc) branches. A branch in the Pact Broker belongs to a...
Read more >pact_verifier_cli not honoring consumer-version-selectors
If you pass the following flag you'll get some extra output that will show what is sent to the Pact broker and possibly...
Read more >Developers - Add support for consumer version selectors for ...
Please add support for the following keys to be used in the consumer version selectors when fetching pacts for verification:
Read more >Hi do we have an example to use consumer version selector in
Hi do we have an example to use consumer version selector in kotlin ... You can put in either as a test method...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @RadekKoubsky , I started working on this issue but got stuck at some point and did not have time go back to it. If you want you can pick up where I left off. My current version can be found here.
Some of the open tasks:
providerVersionBranch
property.Yeah, in theory yes but that it’s even more “magic”. The current implementation already contains some “magic” e.g. there is the option to either give a list of latest values or a single one or to omit and this is not really documented (or at least I could not find it). I would really opt for simplifying the current implementation instead of adding more “magic”. The optimal solution in my opinion would be to just pass through all the attributes as is and have the broker do the validation.
Just in the case above you would need to add the same logic for the
matchingBranch
for example and there are more properties coming e.g.deployed
andreleased
.