pact_broker 2.88.0 → 2.89.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release_gem.yml +1 -1
- data/.github/workflows/trigger_pact_docs_update.yml +1 -0
- data/CHANGELOG.md +14 -0
- data/docs/CONFIGURATION.md +1 -1
- data/lib/pact_broker/api/contracts/pacts_for_verification_json_query_schema.rb +14 -4
- data/lib/pact_broker/api/decorators/deployed_version_decorator.rb +2 -1
- data/lib/pact_broker/api/decorators/pacts_for_verification_query_decorator.rb +18 -0
- data/lib/pact_broker/api/resources/currently_deployed_versions_for_environment.rb +3 -1
- data/lib/pact_broker/api/resources/deployed_versions_for_version_and_environment.rb +4 -3
- data/lib/pact_broker/api/resources/pact.rb +1 -1
- data/lib/pact_broker/api/resources/publish_contracts.rb +27 -4
- data/lib/pact_broker/config/runtime_configuration_database_methods.rb +1 -1
- data/lib/pact_broker/contracts/contracts_publication_results.rb +2 -7
- data/lib/pact_broker/contracts/notice.rb +8 -0
- data/lib/pact_broker/contracts/service.rb +25 -0
- data/lib/pact_broker/doc/views/index/publish-contracts.markdown +32 -2
- data/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown +2 -0
- data/lib/pact_broker/locale/en.yml +1 -1
- data/lib/pact_broker/pacts/content.rb +18 -0
- data/lib/pact_broker/pacts/create_formatted_diff.rb +9 -2
- data/lib/pact_broker/pacts/selector.rb +35 -21
- data/lib/pact_broker/pacts/sort_content.rb +1 -0
- data/lib/pact_broker/verifications/required_verification.rb +5 -2
- data/lib/pact_broker/verifications/service.rb +14 -7
- data/lib/pact_broker/version.rb +1 -1
- data/lib/pact_broker/versions/selector.rb +32 -0
- data/lib/pact_broker/versions/selectors.rb +20 -0
- data/lib/pact_broker/webhooks/pact_and_verification_parameters.rb +2 -2
- data/lib/pact_broker/webhooks/trigger_service.rb +9 -1
- data/script/docs/generate-configuration-docs.rb +9 -9
- data/script/github-issues/add-branch-support/issue-text.txt +7 -0
- data/script/github-issues/add-branch-support/issues.txt +0 -0
- data/script/github-issues/add-branch-support/raise-issue-in-client-repos.sh +10 -0
- data/script/github-issues/add-branch-support-for-provider-versions/issue-text.txt +9 -0
- data/script/github-issues/add-branch-support-for-provider-versions/issues.txt +6 -0
- data/script/github-issues/add-branch-support-for-provider-versions/raise-issue-in-client-repos.sh +10 -0
- data/script/github-issues/branch-consumer-version-selector/issue-text.txt +52 -0
- data/script/github-issues/branch-consumer-version-selector/issues.txt +9 -0
- data/script/github-issues/branch-consumer-version-selector/raise-issue-in-client-repos.sh +10 -0
- data/script/{issues → github-issues}/consumer-version-selectors-docs/issue-text.txt +0 -0
- data/script/{issues → github-issues}/consumer-version-selectors-docs/issues.txt +0 -0
- data/script/{issues → github-issues}/consumer-version-selectors-docs/raise-issue-in-client-repos.sh +0 -0
- data/script/github-issues/deployed-and-released-selectors-docs/issue-text.txt +26 -0
- data/script/github-issues/deployed-and-released-selectors-docs/issues.txt +9 -0
- data/script/github-issues/deployed-and-released-selectors-docs/raise-issue-in-client-repos.sh +10 -0
- data/script/github-issues/include-pending-by-default/issue-text.txt +5 -0
- data/script/github-issues/include-pending-by-default/issues.txt +10 -0
- data/script/github-issues/include-pending-by-default/raise-issue-in-client-repos.sh +10 -0
- data/spec/features/get_currently_deployed_versions_for_environment_spec.rb +23 -6
- data/spec/features/publish_pact_all_in_one_spec.rb +19 -0
- data/spec/features/record_deployment_spec.rb +17 -4
- data/spec/lib/pact_broker/api/contracts/pacts_for_verification_json_query_schema_combinations_spec.rb +5 -3
- data/spec/lib/pact_broker/api/contracts/pacts_for_verification_json_query_schema_spec.rb +10 -0
- data/spec/lib/pact_broker/api/decorators/pacts_for_verification_query_decorator_spec.rb +10 -0
- data/spec/lib/pact_broker/contracts/service_spec.rb +64 -0
- data/spec/lib/pact_broker/verifications/service_spec.rb +18 -12
- data/spec/lib/pact_broker/webhooks/trigger_service_spec.rb +67 -3
- metadata +22 -5
@@ -1,7 +1,7 @@
|
|
1
1
|
module PactBroker
|
2
2
|
module Verifications
|
3
3
|
class RequiredVerification
|
4
|
-
attr_reader :provider_version, :provider_version_descriptions
|
4
|
+
attr_reader :provider_version, :provider_version_selectors, :provider_version_descriptions
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
7
|
attributes.each do | (name, value) |
|
@@ -10,7 +10,9 @@ module PactBroker
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def == other
|
13
|
-
provider_version == other.provider_version &&
|
13
|
+
provider_version == other.provider_version &&
|
14
|
+
provider_version_selectors == other.provider_version_selectors &&
|
15
|
+
provider_version_descriptions == other.provider_version_descriptions
|
14
16
|
end
|
15
17
|
|
16
18
|
def + other
|
@@ -20,6 +22,7 @@ module PactBroker
|
|
20
22
|
|
21
23
|
RequiredVerification.new(
|
22
24
|
provider_version: provider_version,
|
25
|
+
provider_version_selectors: provider_version_selectors + other.provider_version_selectors,
|
23
26
|
provider_version_descriptions: (provider_version_descriptions + other.provider_version_descriptions).uniq
|
24
27
|
)
|
25
28
|
end
|
@@ -6,6 +6,8 @@ require "pact_broker/logging"
|
|
6
6
|
require "pact_broker/hash_refinements"
|
7
7
|
require "pact_broker/events/publisher"
|
8
8
|
require "pact_broker/verifications/required_verification"
|
9
|
+
require "pact_broker/versions/selector"
|
10
|
+
require "pact_broker/versions/selectors"
|
9
11
|
|
10
12
|
module PactBroker
|
11
13
|
module Verifications
|
@@ -101,7 +103,7 @@ module PactBroker
|
|
101
103
|
|
102
104
|
def calculate_required_verifications_for_pact(pact)
|
103
105
|
pact_version = PactBroker::Pacts::PactVersion.for_pact_domain(pact)
|
104
|
-
required_verifications = required_verifications_for_main_branch(pact_version) +
|
106
|
+
required_verifications = required_verifications_for_main_branch(pact_version, pact.provider.main_branch) +
|
105
107
|
required_verifications_for_deployed_versions(pact_version) +
|
106
108
|
required_verifications_for_released_versions(pact_version)
|
107
109
|
required_verifications
|
@@ -126,19 +128,24 @@ module PactBroker
|
|
126
128
|
end
|
127
129
|
private :broadcast_events
|
128
130
|
|
129
|
-
def identify_required_verification(pact_version, provider_version, description)
|
131
|
+
def identify_required_verification(pact_version, provider_version, description, provider_version_selector)
|
130
132
|
any_verifications = PactBroker::Domain::Verification.where(pact_version_id: pact_version.id, provider_version_id: provider_version.id).any?
|
131
133
|
if !any_verifications
|
132
|
-
RequiredVerification.new(
|
134
|
+
RequiredVerification.new(
|
135
|
+
provider_version: provider_version,
|
136
|
+
provider_version_selectors: PactBroker::Versions::Selectors.new(provider_version_selector),
|
137
|
+
provider_version_descriptions: [description]
|
138
|
+
)
|
133
139
|
end
|
134
140
|
end
|
135
141
|
private :identify_required_verification
|
136
142
|
|
137
|
-
def required_verifications_for_main_branch(pact_version)
|
143
|
+
def required_verifications_for_main_branch(pact_version, main_branch_name)
|
138
144
|
latest_version_from_main_branch = [version_service.find_latest_version_from_main_branch(pact_version.provider)].compact
|
139
145
|
|
140
146
|
latest_version_from_main_branch.collect do | main_branch_version |
|
141
|
-
|
147
|
+
selector = PactBroker::Versions::Selector.for_main_branch.resolve_for_branch(main_branch_version, main_branch_name)
|
148
|
+
identify_required_verification(pact_version, main_branch_version, "latest from main branch", selector)
|
142
149
|
end.compact
|
143
150
|
end
|
144
151
|
private :required_verifications_for_main_branch
|
@@ -148,7 +155,7 @@ module PactBroker
|
|
148
155
|
unscoped_service.find_currently_deployed_versions_for_pacticipant(pact_version.provider)
|
149
156
|
end
|
150
157
|
deployed_versions.collect do | deployed_version |
|
151
|
-
identify_required_verification(pact_version, deployed_version.version, "deployed in #{deployed_version.environment_name}")
|
158
|
+
identify_required_verification(pact_version, deployed_version.version, "deployed in #{deployed_version.environment_name}", PactBroker::Versions::Selector.for_currently_deployed)
|
152
159
|
end.compact
|
153
160
|
end
|
154
161
|
private :required_verifications_for_deployed_versions
|
@@ -158,7 +165,7 @@ module PactBroker
|
|
158
165
|
unscoped_service.find_currently_supported_versions_for_pacticipant(pact_version.provider)
|
159
166
|
end
|
160
167
|
released_versions.collect do | released_version |
|
161
|
-
identify_required_verification(pact_version, released_version.version, "released in #{released_version.environment_name}")
|
168
|
+
identify_required_verification(pact_version, released_version.version, "released in #{released_version.environment_name}", PactBroker::Versions::Selector.for_currently_supported)
|
162
169
|
end.compact
|
163
170
|
end
|
164
171
|
private :required_verifications_for_released_versions
|
data/lib/pact_broker/version.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "pact_broker/pacts/selector"
|
2
|
+
require "pact_broker/hash_refinements"
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Versions
|
6
|
+
class Selector < PactBroker::Pacts::Selector
|
7
|
+
def resolve_for_branch(consumer_version, resolved_branch_name)
|
8
|
+
# Need to rename branch to branch_name
|
9
|
+
ResolvedSelector.new(self.to_h.merge({ resolved_branch_name: resolved_branch_name }.compact), consumer_version)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ResolvedSelector < PactBroker::Pacts::ResolvedSelector
|
14
|
+
using PactBroker::HashRefinements
|
15
|
+
|
16
|
+
PROPERTY_NAMES = PactBroker::Pacts::Selector::PROPERTY_NAMES + [:version, :resolved_branch_name]
|
17
|
+
|
18
|
+
def initialize(properties = {}, version)
|
19
|
+
properties.without(*PROPERTY_NAMES).tap { |it| warn("WARN: Unsupported property for #{self.class.name}: #{it.keys.join(", ")} at #{caller[0..3]}") if it.any? }
|
20
|
+
merge!(properties.merge(version: version))
|
21
|
+
end
|
22
|
+
|
23
|
+
def resolved_branch_name
|
24
|
+
self[:resolved_branch_name]
|
25
|
+
end
|
26
|
+
|
27
|
+
def version
|
28
|
+
self[:version]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "pact_broker/pacts/selector"
|
2
|
+
require "pact_broker/versions/selector"
|
3
|
+
|
4
|
+
module PactBroker
|
5
|
+
module Versions
|
6
|
+
class Selectors < Array
|
7
|
+
def initialize *selectors
|
8
|
+
super([*selectors].flatten)
|
9
|
+
end
|
10
|
+
|
11
|
+
def + other
|
12
|
+
Selectors.new(super)
|
13
|
+
end
|
14
|
+
|
15
|
+
def sort
|
16
|
+
Selectors.new(super)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -171,8 +171,8 @@ module PactBroker
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def provider_version_branch
|
174
|
-
if webhook_context
|
175
|
-
webhook_context[:provider_version_branch]
|
174
|
+
if webhook_context.key?(:provider_version_branch)
|
175
|
+
webhook_context[:provider_version_branch] || ""
|
176
176
|
else
|
177
177
|
verification&.provider_version&.branch || ""
|
178
178
|
end
|
@@ -135,13 +135,21 @@ module PactBroker
|
|
135
135
|
required_verifications = verification_service.calculate_required_verifications_for_pact(pact)
|
136
136
|
event_contexts.flat_map do | event_context |
|
137
137
|
required_verifications.collect do | required_verification |
|
138
|
-
event_context.merge(
|
138
|
+
event_context.merge(
|
139
|
+
provider_version_number: required_verification.provider_version.number,
|
140
|
+
provider_version_branch: provider_version_branch_for_required_verification(required_verification, ),
|
141
|
+
provider_version_descriptions: required_verification.provider_version_descriptions.uniq
|
142
|
+
)
|
139
143
|
end
|
140
144
|
end
|
141
145
|
else
|
142
146
|
event_contexts
|
143
147
|
end
|
144
148
|
end
|
149
|
+
|
150
|
+
def provider_version_branch_for_required_verification(required_verification)
|
151
|
+
required_verification.provider_version_selectors.find(&:latest_for_main_branch?)&.resolved_branch_name || required_verification.provider_version.branch_versions.last&.branch_name
|
152
|
+
end
|
145
153
|
end
|
146
154
|
end
|
147
155
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
INTRO = <<EOM
|
4
|
-
<!-- This is a generated file. Please do not edit it directly. -->
|
4
|
+
<!-- This is a generated file. Please do not edit it directly. The source is https://github.com/pact-foundation/pact_broker/blob/master/docs/configuration.yml -->
|
5
5
|
|
6
|
-
The Pact Broker supports configuration via environment variables or a YAML file.
|
6
|
+
The Pact Broker supports configuration via environment variables or a YAML file from version 2.87.0.1 of the Docker images.
|
7
7
|
|
8
8
|
To configure the application using a YAML file, place it in the location `config/pact_broker.yml`,
|
9
9
|
relative to the working directory of the application, or set the environment
|
@@ -94,14 +94,14 @@ end
|
|
94
94
|
|
95
95
|
File.open(configuration_doc_path, "w") { |file| file << $stream.string }
|
96
96
|
|
97
|
-
required_env_vars = []
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
97
|
+
required_env_vars = doc["groups"].flat_map do | group |
|
98
|
+
group["vars"].collect do | name, _metadata |
|
99
|
+
if name != "port"
|
100
|
+
"env PACT_BROKER_#{name.upcase};"
|
101
|
+
end
|
102
|
+
end.compact
|
103
103
|
end
|
104
104
|
|
105
|
-
puts "
|
105
|
+
puts "Env vars for https://github.com/DiUS/pact_broker-docker/blob/master/container/etc/nginx/main.d/pactbroker-env.conf :"
|
106
106
|
puts required_env_vars
|
107
107
|
puts configuration_doc_path
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Add branch support
|
2
|
+
|
3
|
+
The Pact Broker now supports branches as first class entities. You can read more about this here: https://github.com/pact-foundation/docs.pact.io/blob/feat/deployments-and-releases/website/blog/2021-07-04-why-we-are-getting-rid-of-tags.md
|
4
|
+
|
5
|
+
Please add support for branches in the following way (depending on how you publish pacts and verifications):
|
6
|
+
|
7
|
+
* If this
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
repos="pact-js pact-jvm pact-net pact-python scala-pact pact-php pact-go pact pact-reference pact4s"
|
4
|
+
|
5
|
+
issue_text_file=$(realpath $(dirname "$0")/issue-text.txt)
|
6
|
+
|
7
|
+
for repo in $repos; do
|
8
|
+
cd "../${repo}"
|
9
|
+
hub issue create --file "${issue_text_file}" --labels "help wanted,good first issue,enhancement"
|
10
|
+
done
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Add support for publishing verification results with a branch using the pact-ruby-standalone
|
2
|
+
|
3
|
+
The Pact Broker now supports branches as first class entities. You can read more about this here: https://github.com/pact-foundation/docs.pact.io/blob/feat/deployments-and-releases/website/blog/2021-07-04-why-we-are-getting-rid-of-tags.md
|
4
|
+
|
5
|
+
To allow users to use this feature:
|
6
|
+
|
7
|
+
* Upgrade the pact-ruby-standalone to at least version `1.88.70`
|
8
|
+
* Add an appropriately prefixed "branch" property to the user facing interface (make it match the existing provider name, tag, and version properties)
|
9
|
+
* Pass the branch through to the pact provider verifier CLI using the parameter `--provider-version-branch`
|
@@ -0,0 +1,6 @@
|
|
1
|
+
https://github.com/pact-foundation/pact-js/issues/750
|
2
|
+
https://github.com/pact-foundation/pact-net/issues/327
|
3
|
+
https://github.com/pact-foundation/pact-python/issues/267
|
4
|
+
https://github.com/pact-foundation/pact-php/issues/223
|
5
|
+
https://github.com/pact-foundation/pact-go/issues/180
|
6
|
+
https://github.com/DiUS/pact-consumer-swift/issues/127
|
data/script/github-issues/add-branch-support-for-provider-versions/raise-issue-in-client-repos.sh
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
repos="pact-js pact-net pact-python pact-php pact-go pact-consumer-swift"
|
4
|
+
|
5
|
+
issue_text_file=$(realpath $(dirname "$0")/issue-text.txt)
|
6
|
+
|
7
|
+
for repo in $repos; do
|
8
|
+
cd "../${repo}"
|
9
|
+
hub issue create --file "${issue_text_file}" --labels "help wanted,enhancement"
|
10
|
+
done
|
@@ -0,0 +1,52 @@
|
|
1
|
+
Add support for branches in consumer version selectors
|
2
|
+
|
3
|
+
The Pact Broker now supports branches as first class entities. You can read more about this here: https://docs.pact.io/pact_broker/branches
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
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.
|
8
|
+
|
9
|
+
* For implementations that wrap the pact-ruby-standalone, update to the latest standalone version
|
10
|
+
* For implementations that use the rust implementation, update to the latest rust version.
|
11
|
+
* Add a String `branch` property to the consumer version selector (if there is a domain model for this).
|
12
|
+
* Add a Boolean `mainBranch` (or `main_branch` for snake case languages) property consumer version selector (if there is a domain model for this).
|
13
|
+
* Add a Boolean `matchingBranch` (or `matching_branch` for snake case languages) property consumer version selector (if there is a domain model for this).
|
14
|
+
* Expose and document the `branch`, `mainBranch` (or `main_branch` for snake case languages) and `matchingBranch` (or `matching_branch`) properties in the user facing API.
|
15
|
+
* Pass the `branch`, `mainBranch` and `matchingBranch` (must be camelcase) through to the relevant implementation (ruby and/or rust)
|
16
|
+
|
17
|
+
## Verifying the changes
|
18
|
+
|
19
|
+
* Publish test pacts to the test broker
|
20
|
+
|
21
|
+
```
|
22
|
+
export PACT_BROKER_BASE_URL="https://test.pact.dius.com.au"
|
23
|
+
export PACT_BROKER_USERNAME="dXfltyFMgNOFZAxr8io9wJ37iUpY42M"
|
24
|
+
export PACT_BROKER_PASSWORD="O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1"
|
25
|
+
|
26
|
+
docker run --rm \
|
27
|
+
-e PACT_BROKER_BASE_URL \
|
28
|
+
-e PACT_BROKER_USERNAME \
|
29
|
+
-e PACT_BROKER_PASSWORD \
|
30
|
+
pactfoundation/pact-cli:0.50.0.14 \
|
31
|
+
publish \
|
32
|
+
/pact/example/pacts \
|
33
|
+
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
|
34
|
+
--branch main
|
35
|
+
|
36
|
+
docker run --rm \
|
37
|
+
-e PACT_BROKER_BASE_URL \
|
38
|
+
-e PACT_BROKER_USERNAME \
|
39
|
+
-e PACT_BROKER_PASSWORD \
|
40
|
+
pactfoundation/pact-cli:0.50.0.14 \
|
41
|
+
publish \
|
42
|
+
/pact/example/pacts \
|
43
|
+
--consumer-app-version fake-git-sha-for-demo-$(date +%s) \
|
44
|
+
--branch feat/x
|
45
|
+
```
|
46
|
+
|
47
|
+
* Using your pact client library, verify `{ "mainBranch": true }`
|
48
|
+
* You should receive the main pact
|
49
|
+
* Using your pact client library, verify `{ "branch": "feat/x" }`
|
50
|
+
* You should receive the feat/x pact
|
51
|
+
* Using your pact client library, verify `{ "matchingBranch": true }` with the provider branch set to `feat/x`
|
52
|
+
* You should receive the feat/x pact
|
@@ -0,0 +1,9 @@
|
|
1
|
+
https://github.com/pact-foundation/pact-js/issues/757
|
2
|
+
https://github.com/pact-foundation/pact-jvm/issues/1465
|
3
|
+
https://github.com/pact-foundation/pact-net/issues/336
|
4
|
+
https://github.com/pact-foundation/pact-python/issues/272
|
5
|
+
https://github.com/pact-foundation/pact-php/issues/226
|
6
|
+
https://github.com/pact-foundation/pact-go/issues/184
|
7
|
+
https://github.com/pact-foundation/pact-reference/issues/158
|
8
|
+
https://github.com/jbwheatley/pact4s/issues/89
|
9
|
+
https://github.com/ITV/scala-pact/issues/230
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
repos="pact-js pact-jvm pact-net pact-python pact-php pact-go pact-reference pact4s scala-pact" #pact_elixir
|
4
|
+
|
5
|
+
issue_text_file=$(realpath $(dirname "$0")/issue-text.txt)
|
6
|
+
|
7
|
+
for repo in $repos; do
|
8
|
+
cd "../${repo}"
|
9
|
+
hub issue create --file "${issue_text_file}" --labels "help wanted,enhancement"
|
10
|
+
done
|
File without changes
|
File without changes
|
data/script/{issues → github-issues}/consumer-version-selectors-docs/raise-issue-in-client-repos.sh
RENAMED
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Add support for consumer version selectors for deployed and released versions
|
2
|
+
|
3
|
+
Please add support for the following keys to be used in the consumer version selectors when fetching pacts for verification:
|
4
|
+
|
5
|
+
```
|
6
|
+
{ "deployedOrReleased": true }
|
7
|
+
|
8
|
+
{ "deployed": true }
|
9
|
+
|
10
|
+
{ "released": true }
|
11
|
+
|
12
|
+
{ "environment": "<env name>" }
|
13
|
+
|
14
|
+
{ "deployed": true }
|
15
|
+
|
16
|
+
{ "released": true }
|
17
|
+
|
18
|
+
```
|
19
|
+
|
20
|
+
These keys can be used in various combinations ( eg. `{ "environment": "prod", released: true, consumer: "Foo" }` ). Please allow any combination of keys, and do not validate them locally, as the validation rules can change over time as support is added for new selectors - just ensure that any errors returned from the API are displayed clearly to the user.
|
21
|
+
|
22
|
+
See https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/provider-pacts-for-verification.markdown for the usage docs of each selector.
|
23
|
+
|
24
|
+
As more selectors will be added over time, it's my preference that the consumer version selectors are not strongly typed, and are just passed through straight from the configuration object to the API, so that we don't have to make code changes to the Pact clients each time we add new selectors. (eg. there will be new selectors coming for branch support very soon). I understand that this is not compatible with the idioms of every Pact client language however, so do whatever you need to do to make the new selectors work elegantly within your language.
|
25
|
+
|
26
|
+
Please update https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ for your language once the selectors have been released.
|
@@ -0,0 +1,9 @@
|
|
1
|
+
https://github.com/pact-foundation/pact-js/issues/715
|
2
|
+
https://github.com/pact-foundation/pact-jvm/issues/1407
|
3
|
+
https://github.com/pact-foundation/pact-net/issues/311
|
4
|
+
https://github.com/pact-foundation/pact-python/issues/246
|
5
|
+
https://github.com/ITV/scala-pact/issues/224
|
6
|
+
https://github.com/pact-foundation/pact-php/issues/206
|
7
|
+
https://github.com/pact-foundation/pact-go/issues/172
|
8
|
+
https://github.com/pact-foundation/pact-ruby/issues/243
|
9
|
+
https://github.com/pact-foundation/pact-reference/issues/125
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
repos="pact-js pact-jvm pact-net pact-python scala-pact pact-php pact-go pact pact-reference"
|
4
|
+
|
5
|
+
issue_text_file=$(realpath $(dirname "$0")/issue-text.txt)
|
6
|
+
|
7
|
+
for repo in $repos; do
|
8
|
+
cd "../${repo}"
|
9
|
+
hub issue create --file "${issue_text_file}" --labels "help wanted,good first issue,enhancement"
|
10
|
+
done
|
@@ -0,0 +1,5 @@
|
|
1
|
+
Set "enable pending" to true by default
|
2
|
+
|
3
|
+
The [pending](https://docs.pact.io/pending) feature has been used for long enough now to show that it works, and that there is little reason to ever have it turned off any more. The Pact Broker now defaults to `true` if the `includePendingStatus` field is not set, however, this will not take effect if the client side has it set to false by default. Please set `enablePending` to true by default now, to ensure it is turned on for all older and future versions of the Pact Broker.
|
4
|
+
|
5
|
+
Consider printing a warning message if the user does set it to false explicitly, along the lines of "We recommend setting enablePending to true. For more information, please see https://docs.pact.io/pending"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
https://github.com/pact-foundation/pact-js/issues/740
|
2
|
+
https://github.com/pact-foundation/pact-jvm/issues/1440
|
3
|
+
https://github.com/pact-foundation/pact-net/issues/322
|
4
|
+
https://github.com/pact-foundation/pact-python/issues/264
|
5
|
+
https://github.com/ITV/scala-pact/issues/228
|
6
|
+
https://github.com/pact-foundation/pact-php/issues/221
|
7
|
+
https://github.com/pact-foundation/pact-go/issues/178
|
8
|
+
https://github.com/pact-foundation/pact-ruby/issues/246
|
9
|
+
https://github.com/pact-foundation/pact-reference/issues/143
|
10
|
+
https://github.com/jbwheatley/pact4s/issues/69
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
repos="pact-js pact-jvm pact-net pact-python scala-pact pact-php pact-go pact pact-reference pact4s"
|
4
|
+
|
5
|
+
issue_text_file=$(realpath $(dirname "$0")/issue-text.txt)
|
6
|
+
|
7
|
+
for repo in $repos; do
|
8
|
+
cd "../${repo}"
|
9
|
+
hub issue create --file "${issue_text_file}" --labels "help wanted,good first issue,enhancement"
|
10
|
+
done
|
@@ -29,9 +29,8 @@ RSpec.describe "Get currently deployed versions for environment" do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
context "with query params" do
|
32
|
-
|
33
|
-
|
34
|
-
let(:query_params) { { pacticipant: "Bar", target: "customer-1" } }
|
32
|
+
context "with a pacticipant name and applicationInstance" do
|
33
|
+
let(:query_params) { { pacticipant: "Bar", applicationInstance: "customer-1" } }
|
35
34
|
|
36
35
|
it "returns a list of matching deployed versions" do
|
37
36
|
expect(response_body_hash[:_embedded][:deployedVersions].size).to eq 1
|
@@ -39,8 +38,8 @@ RSpec.describe "Get currently deployed versions for environment" do
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
context "with pacticipant name and a blank
|
43
|
-
let(:query_params) { { pacticipant: "Bar",
|
41
|
+
context "with pacticipant name and a blank applicationInstance" do
|
42
|
+
let(:query_params) { { pacticipant: "Bar", applicationInstance: "" } }
|
44
43
|
|
45
44
|
it "returns a list of matching deployed versions" do
|
46
45
|
expect(response_body_hash[:_embedded][:deployedVersions].size).to eq 1
|
@@ -48,12 +47,30 @@ RSpec.describe "Get currently deployed versions for environment" do
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
context "with pacticipant name and no target" do
|
50
|
+
context "with pacticipant name and no target or applicationInstance" do
|
52
51
|
let(:query_params) { { pacticipant: "Bar" } }
|
53
52
|
|
54
53
|
it "returns a list of matching deployed versions" do
|
55
54
|
expect(response_body_hash[:_embedded][:deployedVersions].size).to eq 2
|
56
55
|
end
|
57
56
|
end
|
57
|
+
|
58
|
+
context "with a pacticipant name and target (deprecated)" do
|
59
|
+
let(:query_params) { { pacticipant: "Bar", target: "customer-1" } }
|
60
|
+
|
61
|
+
it "returns a list of matching deployed versions" do
|
62
|
+
expect(response_body_hash[:_embedded][:deployedVersions].size).to eq 1
|
63
|
+
expect(response_body_hash[:_embedded][:deployedVersions].first[:_embedded][:version][:number]).to eq "4"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "with pacticipant name and a blank target (deprecated)" do
|
68
|
+
let(:query_params) { { pacticipant: "Bar", target: "" } }
|
69
|
+
|
70
|
+
it "returns a list of matching deployed versions" do
|
71
|
+
expect(response_body_hash[:_embedded][:deployedVersions].size).to eq 1
|
72
|
+
expect(response_body_hash[:_embedded][:deployedVersions].first[:_embedded][:version][:number]).to eq "5"
|
73
|
+
end
|
74
|
+
end
|
58
75
|
end
|
59
76
|
end
|
@@ -39,4 +39,23 @@ RSpec.describe "publishing a pact using the all in one endpoint" do
|
|
39
39
|
|
40
40
|
it { is_expected.to be_a_json_error_response("missing") }
|
41
41
|
end
|
42
|
+
|
43
|
+
context "with a conflicting pact" do
|
44
|
+
before do
|
45
|
+
allow(PactBroker.configuration).to receive(:allow_dangerous_contract_modification).and_return(false)
|
46
|
+
td.create_pact_with_hierarchy("Foo", "1", "Bar")
|
47
|
+
end
|
48
|
+
|
49
|
+
its(:status) { is_expected.to eq 409 }
|
50
|
+
|
51
|
+
it "returns notices" do
|
52
|
+
expect(JSON.parse(subject.body)["notices"]).to be_a(Array)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns errors" do
|
56
|
+
contract_errors = JSON.parse(subject.body)["errors"]["contracts"]
|
57
|
+
expect(contract_errors).to be_a(Array)
|
58
|
+
expect(contract_errors.size).to eq 1
|
59
|
+
end
|
60
|
+
end
|
42
61
|
end
|
@@ -14,13 +14,13 @@ describe "Record deployment" do
|
|
14
14
|
let(:response_body) { JSON.parse(subject.body, symbolize_names: true) }
|
15
15
|
let(:version_path) { "/pacticipants/Foo/versions/2" }
|
16
16
|
let(:version_response) { get(version_path, nil, { "HTTP_ACCEPT" => "application/hal+json" } ) }
|
17
|
-
let(:
|
17
|
+
let(:application_instance) { nil }
|
18
18
|
let(:path) do
|
19
19
|
JSON.parse(version_response.body)["_links"]["pb:record-deployment"]
|
20
20
|
.find{ |relation| relation["name"] == "test" }
|
21
21
|
.fetch("href")
|
22
22
|
end
|
23
|
-
let(:request_body) { {
|
23
|
+
let(:request_body) { { applicationInstance: application_instance }.to_json }
|
24
24
|
|
25
25
|
subject { post(path, request_body, headers) }
|
26
26
|
|
@@ -33,6 +33,7 @@ describe "Record deployment" do
|
|
33
33
|
it "returns the newly created deployment" do
|
34
34
|
expect(response_body[:currentlyDeployed]).to be true
|
35
35
|
expect(response_body).to_not have_key(:target)
|
36
|
+
expect(response_body).to_not have_key(:application_instance)
|
36
37
|
end
|
37
38
|
|
38
39
|
it "creates a new deployed version" do
|
@@ -79,8 +80,20 @@ describe "Record deployment" do
|
|
79
80
|
it { is_expected.to be_a_hal_json_created_response }
|
80
81
|
end
|
81
82
|
|
82
|
-
context "when the deployment is to a different
|
83
|
-
let(:
|
83
|
+
context "when the deployment is to a different application instance" do
|
84
|
+
let(:application_instance) { "foo" }
|
85
|
+
|
86
|
+
it "creates a new deployed version" do
|
87
|
+
expect { subject }.to change { PactBroker::Deployments::DeployedVersion.currently_deployed.count }.by(1)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "sets the applicationInstance" do
|
91
|
+
expect(response_body).to have_key(:applicationInstance)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "when the deployment is to a different target (deprecated)" do
|
96
|
+
let(:request_body) { { target: "foo" }.to_json }
|
84
97
|
|
85
98
|
it "creates a new deployed version" do
|
86
99
|
expect { subject }.to change { PactBroker::Deployments::DeployedVersion.currently_deployed.count }.by(1)
|
@@ -6,6 +6,7 @@ module PactBroker
|
|
6
6
|
describe PactsForVerificationJSONQuerySchema do
|
7
7
|
ALL_PROPERTIES = {
|
8
8
|
mainBranch: true,
|
9
|
+
matchingBranch: true,
|
9
10
|
tag: "tag",
|
10
11
|
branch: "branch",
|
11
12
|
latest: true,
|
@@ -20,6 +21,7 @@ module PactBroker
|
|
20
21
|
|
21
22
|
VALID_KEY_COMBINATIONS = [
|
22
23
|
[:mainBranch],
|
24
|
+
[:matchingBranch],
|
23
25
|
[:tag],
|
24
26
|
[:tag, :latest],
|
25
27
|
[:tag, :latest, :fallbackTag],
|
@@ -45,7 +47,7 @@ module PactBroker
|
|
45
47
|
end
|
46
48
|
|
47
49
|
it "is valid" do
|
48
|
-
params = { consumerVersionSelectors: [selector] }
|
50
|
+
params = { consumerVersionSelectors: [selector], providerVersionBranch: "main" }
|
49
51
|
expect(PactsForVerificationJSONQuerySchema.(params)).to be_empty
|
50
52
|
end
|
51
53
|
|
@@ -53,7 +55,7 @@ module PactBroker
|
|
53
55
|
extra_keys.each do | extra_key |
|
54
56
|
selector_with_extra_key = selector.merge(extra_key => ALL_PROPERTIES[extra_key])
|
55
57
|
expect_to_be_valid = !!VALID_KEY_COMBINATIONS.find{ | k | k.sort == selector_with_extra_key.keys.sort }
|
56
|
-
params = { consumerVersionSelectors: [selector_with_extra_key] }
|
58
|
+
params = { consumerVersionSelectors: [selector_with_extra_key], providerVersionBranch: "main" }
|
57
59
|
|
58
60
|
describe "with #{selector_with_extra_key}" do
|
59
61
|
if expect_to_be_valid
|
@@ -71,7 +73,7 @@ module PactBroker
|
|
71
73
|
|
72
74
|
describe "with #{selector_with_consumer}" do
|
73
75
|
it "is valid" do
|
74
|
-
params = { consumerVersionSelectors: [selector_with_consumer] }
|
76
|
+
params = { consumerVersionSelectors: [selector_with_consumer], providerVersionBranch: "main" }
|
75
77
|
|
76
78
|
expect(PactsForVerificationJSONQuerySchema.(params).empty?).to be true
|
77
79
|
end
|
@@ -342,6 +342,16 @@ module PactBroker
|
|
342
342
|
|
343
343
|
its([:consumerVersionSelectors, 0]) { is_expected.to eq "environment with name 'prod' does not exist at index 0" }
|
344
344
|
end
|
345
|
+
|
346
|
+
context "when matchingBranch is true, but the providerVersionBranch is not set" do
|
347
|
+
let(:consumer_version_selectors) do
|
348
|
+
[{
|
349
|
+
matchingBranch: true
|
350
|
+
}]
|
351
|
+
end
|
352
|
+
|
353
|
+
its([:consumerVersionSelectors, 0]) { is_expected.to include "the providerVersionBranch must be specified"}
|
354
|
+
end
|
345
355
|
end
|
346
356
|
end
|
347
357
|
end
|