Alan Boshier
07/01/2024, 8:34 AM[ selector_1, selector_2, ..., selector_n ]
where each selector_i represents an individual cvs (e.g. { "tag": "develop", "latest": true }) then are these selectors logically OR'd together or AND'd together or is it not as simple as that?
My assumption is that its a disjunction (logical OR) but the first example on this page confused me:
consumerVersionSelectors: [
{
mainBranch: true, // (recommended) - Returns the pacts for consumers configured mainBranch property
},
{
deployedOrReleased: true, // (recommended) - Returns the pacts for all versions of the consumer that are currently deployed or released and currently supported in any environment.
},
{
environment: 'test', // Normally, this would not be needed, as it is recommended to verify the pacts for all currently deployed/currently supported released versions.
},
{
environment: 'production', // Normally, this would not be needed, as it is recommended to verify the pacts for all currently deployed/currently supported released versions.
},
]
where the explanation is that this will target:
> • any pacts for the consumer associated with their configured mainBranch property
> • any pacts for the consumers, deployed to any environment
> ◦ This if (sic) filtered by only pacts deployed or released to the test / production environments.
> ◦ If this consumer/provider pair, has an additional environment staging, it would not be picked up, due to the named test / production environments. Removing these conditions, will return any pacts, deployed or released to any environment, which is the recommended setup for the majority of cases. (coupled with enabling pending pacts.)
It looks like cvs #1 and #2 are expressing a disjunction (either the pact is associated with the main branch of the consumer or the pact is deployed or support-released)
However cvs #3 and #4 then appear to be used as additional mandatory subcriteria on #2 (i.e. not only does the pact have to be deployed, the deployment has to be to either test or production).
This has confused me; if the cvs's are logically OR'd together then the above example seems to be saying return all pacts that are either on main branch, or deployed and released, or deployed to test, or deployed to production. Under those criteria we would get pacts deployed to staging because they would satisfy the 2nd cvs.
I was expecting the desired filter to be expressed in pure disjunctive form
consumerVersionSelectors: [
{
// pacts for consumers configured mainBranch property
mainBranch: true,
},
{
// pacts currently released and supported
released: true
},
{
// pacts currently deployed to test
deployed: true,
environment: 'test'
},
{
// pacts currently deployed to production
deployed: true,
environment: 'production'
},
]
where the cvs's are logically OR'd together (disjunction) and with each csv, its predicates are logically AND'd together (conjunction).Yousaf Nabi (pactflow.io)
deployedOrReleased would also include for example staging.
consumerVersionSelectors: [
{
mainBranch: true, // (recommended) - Returns the pacts for consumers configured mainBranch property
},
{
deployedOrReleased: true, // (recommended) - Returns the pacts for all versions of the consumer that are currently deployed or released and currently supported in any environment.
}
]
if I wanted to qualify just deployedOrReleased to test/prod (excluding any other envs that may exist) I believe I can do
consumerVersionSelectors: [
{
// pacts for consumers configured mainBranch property
mainBranch: true,
},
{
// pacts currently deployedOrReleased to test
deployedOrReleased: true,
environment: 'test'
},
{
// pacts currently deployedOrReleased to production
deployedOrReleased: true,
environment: 'production'
},
]Yousaf Nabi (pactflow.io)
{
deployedOrReleased: true, // (recommended) - Returns the pacts for all versions of the consumer that are currently deployed or released and currently supported in any environment.
},
{
environment: 'test', // Normally, this would not be needed, as it is recommended to verify the pacts for all currently deployed/currently supported released versions.
},
{
environment: 'production', // Normally, this would not be needed, as it is recommended to verify the pacts for all currently deployed/currently supported released versions.
},Alan Boshier
07/01/2024, 2:25 PMYousaf Nabi (pactflow.io)
- any pacts for the consumers, deployed toenvironmentany
- This if filtered by only pactsordeployedto thereleased/testenvironments.production
- If this consumer/provider pair, has an additional environmentWill give it a test and will update the docs. Do you think it is also worth removing the comments from the code snippets? there is an explainer at the top., it would not be picked up, due to the namedstaging/testenvironments. Removing these conditions, will return any pacts, deployed or released to any environment, which is the recommended setup for the majority of cases. (coupled with enabling pending pacts.)production
// (recommended) - Returns the pacts for all versions of the consumer that are currently deployed or released and currently supported in any environment.Alan Boshier
07/01/2024, 2:36 PMYousaf Nabi (pactflow.io)
Alan Boshier
07/01/2024, 3:32 PMMatt (pactflow.io / pact-js / pact-go)