pact_broker-client 1.28.2 → 1.30.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 +18 -3
- data/.github/workflows/trigger_pact_docs_update.yml +3 -0
- data/CHANGELOG.md +32 -0
- data/Gemfile +0 -4
- data/README.md +8 -1
- data/lib/pact_broker/client/base_client.rb +6 -0
- data/lib/pact_broker/client/cli/broker.rb +1 -0
- data/lib/pact_broker/client/git.rb +12 -3
- data/lib/pact_broker/client/hal/http_client.rb +5 -0
- data/lib/pact_broker/client/publish_pacts.rb +11 -9
- data/lib/pact_broker/client/version.rb +1 -1
- data/script/create-pacticipant.sh +2 -0
- data/spec/lib/pact_broker/client/publish_pacts_spec.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7be73ef3705005ce0808a1d74dba560c4f590fce09871ae7597c06479ce2316
|
4
|
+
data.tar.gz: ec3b757187ce7c60dbc4835933debbe68fa2f5fb2b08ffdb6f9e5cb7141943e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f035fa2d68c909fc2d3865ebcd76be24ae9af0a0a4bc4cd0e2503f3a1da822456a6439b61364a83a73ff6e9021a5fa5caa24addeb4f9d9a10980ab33e1ffb74
|
7
|
+
data.tar.gz: 2fe9a489c6c2824f1d218b693559bf1be1713d2989c62283979acc7ddda0684a0b60607fce0abd5d813dbb279c7ff5a4b5ca6bb186c79af3911855803f79837a
|
@@ -6,7 +6,21 @@ on:
|
|
6
6
|
- release-triggered
|
7
7
|
|
8
8
|
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: '2.6'
|
16
|
+
- run: |
|
17
|
+
gem install bundler -v 2.1
|
18
|
+
bundle install
|
19
|
+
- name: Test
|
20
|
+
run: bundle exec rake
|
21
|
+
|
9
22
|
release:
|
23
|
+
needs: test
|
10
24
|
runs-on: ubuntu-latest
|
11
25
|
outputs:
|
12
26
|
gem_name: ${{ steps.release.outputs.gem_name }}
|
@@ -16,17 +30,18 @@ jobs:
|
|
16
30
|
- uses: actions/checkout@v2
|
17
31
|
with:
|
18
32
|
fetch-depth: 0
|
19
|
-
- uses: pact-foundation/release-gem@v0.0.
|
33
|
+
- uses: pact-foundation/release-gem@v0.0.11
|
20
34
|
id: release
|
21
35
|
env:
|
22
36
|
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_API_KEY }}'
|
23
37
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
24
38
|
INCREMENT: '${{ github.event.client_payload.increment }}'
|
25
|
-
|
39
|
+
|
40
|
+
notify-gem-released:
|
26
41
|
needs: release
|
27
42
|
strategy:
|
28
43
|
matrix:
|
29
|
-
repository: [pact-foundation/pact-ruby-cli, pact-foundation/pact-ruby-standalone]
|
44
|
+
repository: [pact-foundation/pact-ruby-cli, pact-foundation/pact-ruby-standalone, pact-foundation/pact_broker-client]
|
30
45
|
runs-on: ubuntu-latest
|
31
46
|
steps:
|
32
47
|
- name: Notify ${{ matrix.repository }} of gem release
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
<a name="v1.30.0"></a>
|
2
|
+
### v1.30.0 (2020-10-09)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* remove outdated comment from pact publishing output ([251b4df](/../../commit/251b4df))
|
7
|
+
|
8
|
+
<a name="v1.29.1"></a>
|
9
|
+
### v1.29.1 (2020-08-07)
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* explicitly set the CA file and path from SSL_CERT_FILE and SSL_CERT_DIR for the pact-ruby-standalone ([27a0fe6](/../../commit/27a0fe6))
|
14
|
+
|
15
|
+
<a name="v1.29.0"></a>
|
16
|
+
### v1.29.0 (2020-08-05)
|
17
|
+
|
18
|
+
#### Features
|
19
|
+
|
20
|
+
* print out helpful error message for 403 ([5d5a18a](/../../commit/5d5a18a))
|
21
|
+
* support publishing pacts for multiple consumers at the same time ([573e97c](/../../commit/573e97c))
|
22
|
+
|
23
|
+
<a name="v1.28.4"></a>
|
24
|
+
### v1.28.4 (2020-07-31)
|
25
|
+
|
26
|
+
#### Bug Fixes
|
27
|
+
|
28
|
+
* add missing require for PactBroker::Client::Error ([72eb796](/../../commit/72eb796))
|
29
|
+
|
30
|
+
<a name="v1.28.3"></a>
|
31
|
+
### v1.28.3 (2020-07-19)
|
32
|
+
|
1
33
|
<a name="v1.28.2"></a>
|
2
34
|
### v1.28.2 (2020-07-17)
|
3
35
|
|
data/Gemfile
CHANGED
@@ -6,10 +6,6 @@ gemspec
|
|
6
6
|
# even thought it's in the development dependencies. Trying it here.
|
7
7
|
gem 'rake', '~> 13.0'
|
8
8
|
|
9
|
-
group :release do
|
10
|
-
gem 'bump', git: 'https://github.com/bethesque/bump.git'
|
11
|
-
end
|
12
|
-
|
13
9
|
if ENV['X_PACT_DEVELOPMENT'] == 'true'
|
14
10
|
gem 'pact-mock_service', path: '../pact-mock_service'
|
15
11
|
gem 'pact-support', path: '../pact-support'
|
data/README.md
CHANGED
@@ -153,7 +153,7 @@ Can I deploy the latest version of the application Foo that has the tag "test" t
|
|
153
153
|
|
154
154
|
If you are unable to use tags, or there is some other limitation that stops you from using the recommended approach, you can specify one or more of the dependencies explictly. You must also do this if you want to use the `--all TAG` option for any of the pacticipants.
|
155
155
|
|
156
|
-
You can specify as many application versions as you like, and you can even specify multiple versions of the same application (repeat the `--pacticipant` name and supply a different version.
|
156
|
+
You can specify as many application versions as you like, and you can even specify multiple versions of the same application (repeat the `--pacticipant` name and supply a different version). If you have a monorepo and you deploy a group of applications together, you can either call `can-i-deploy` once for each application, or you can group them all together by specifying a `--pacticipant` and `--version` for each sub-application.
|
157
157
|
|
158
158
|
You can use explictly declared dependencies with or without the `--to ENVIRONMENT`. For example, if you declare two (or more) application versions with no `--to ENVIRONMENT`, then only the applications you specify will be taken into account when determining if it is safe to deploy. If you declare two (or more) application versions _as well as_ a `--to ENVIRONMENT`, then the Pact Broker will work out what integrations your declared applications will have in that environment when determining if it safe to deploy. When using this script for a production release, and you are using tags, it is always the most future-proof option to use the `--to` if possible, as it will catch any newly added consumers or providers.
|
159
159
|
|
@@ -182,6 +182,13 @@ Can I deploy the latest version of Foo with tag "master" and the latest version
|
|
182
182
|
--pacticipant Bar --latest master \
|
183
183
|
--broker-base-url BROKER_BASE_URL
|
184
184
|
|
185
|
+
Can I deploy all the applications in my monorepo to prod?
|
186
|
+
|
187
|
+
$ pact-broker can-i-deploy --pacticipant A --version a7e28207 \
|
188
|
+
--pacticipant B --version a7e28207 \
|
189
|
+
--pacticipant C --version a7e28207 \
|
190
|
+
--to prod \
|
191
|
+
--broker-base-url BROKER_BASE_URL
|
185
192
|
|
186
193
|
Mobile provider use case - can I deploy version b80e7b1b of Bar, all versions of Foo with tag "prod", and the latest version tagged "prod" of any other automatically calculated dependencies together? (Eg. where Bar is a provider and Foo is a mobile consumer with multiple versions in production, and Bar also has its own providers it needs to be compatible with.)
|
187
194
|
|
@@ -69,6 +69,12 @@ module PactBroker
|
|
69
69
|
yield response
|
70
70
|
elsif response.code == 404
|
71
71
|
nil
|
72
|
+
elsif response.code == 403
|
73
|
+
message = "Authorization failed (insufficient permissions)"
|
74
|
+
if response.body && response.body.size > 0
|
75
|
+
message = message + ": #{response.body}"
|
76
|
+
end
|
77
|
+
raise Error.new(message)
|
72
78
|
elsif response.code == 401
|
73
79
|
message = "Authentication failed"
|
74
80
|
if response.body && response.body.size > 0
|
@@ -53,6 +53,7 @@ module PactBroker
|
|
53
53
|
method_option :verbose, aliases: "-v", type: :boolean, default: false, required: false, desc: "Verbose output. Default: false"
|
54
54
|
|
55
55
|
def publish(*pact_files)
|
56
|
+
require 'pact_broker/client/error'
|
56
57
|
validate_credentials
|
57
58
|
validate_pact_files(pact_files)
|
58
59
|
success = publish_pacts(pact_files)
|
@@ -11,7 +11,7 @@ APPVEYOR_REPO_COMMIT APPVEYOR_REPO_BRANCH https://www.appveyor.com/docs/en
|
|
11
11
|
CI_COMMIT_REF_NAME https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
|
12
12
|
CI_BRANCH CI_COMMIT_ID https://documentation.codeship.com/pro/builds-and-configuration/environment-variables/
|
13
13
|
bamboo.repository.git.branch https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html
|
14
|
-
BITBUCKET_BRANCH https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html
|
14
|
+
BITBUCKET_BRANCH BITBUCKET_COMMIT https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html
|
15
15
|
|
16
16
|
=end
|
17
17
|
|
@@ -21,6 +21,11 @@ module PactBroker
|
|
21
21
|
module Git
|
22
22
|
COMMAND = 'git name-rev --name-only HEAD'.freeze
|
23
23
|
BRANCH_ENV_VAR_NAMES = %w{BUILDKITE_BRANCH CIRCLE_BRANCH TRAVIS_BRANCH GIT_BRANCH GIT_LOCAL_BRANCH APPVEYOR_REPO_BRANCH CI_COMMIT_REF_NAME BITBUCKET_BRANCH}.freeze
|
24
|
+
COMMIT_ENV_VAR_NAMES = %w{BUILDKITE_COMMIT CIRCLE_SHA1 TRAVIS_COMMIT GIT_COMMIT APPVEYOR_REPO_COMMIT CI_COMMIT_ID BITBUCKET_COMMIT}
|
25
|
+
|
26
|
+
def self.commit
|
27
|
+
find_commit_from_env_vars
|
28
|
+
end
|
24
29
|
|
25
30
|
def self.branch
|
26
31
|
find_branch_from_env_vars || branch_from_git_command
|
@@ -28,11 +33,15 @@ module PactBroker
|
|
28
33
|
|
29
34
|
# private
|
30
35
|
|
36
|
+
def self.find_commit_from_env_vars
|
37
|
+
COMMIT_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
|
38
|
+
end
|
39
|
+
|
31
40
|
def self.find_branch_from_env_vars
|
32
|
-
BRANCH_ENV_VAR_NAMES.collect { |env_var_name|
|
41
|
+
BRANCH_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
|
33
42
|
end
|
34
43
|
|
35
|
-
def self.
|
44
|
+
def self.value_from_env_var(env_var_name)
|
36
45
|
val = ENV[env_var_name]
|
37
46
|
if val && val.strip.size > 0
|
38
47
|
val
|
@@ -57,6 +57,11 @@ module PactBroker
|
|
57
57
|
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
58
58
|
http.set_debug_output(output_stream) if verbose
|
59
59
|
http.use_ssl = (uri.scheme == 'https')
|
60
|
+
# Need to manually set the ca_file and ca_path for the pact-ruby-standalone.
|
61
|
+
# The env vars seem to be picked up automatically in later Ruby versions.
|
62
|
+
# See https://github.com/pact-foundation/pact-ruby-standalone/issues/57
|
63
|
+
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
|
64
|
+
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
|
60
65
|
http.start do |http|
|
61
66
|
http.request request
|
62
67
|
end
|
@@ -52,6 +52,10 @@ module PactBroker
|
|
52
52
|
@pact_files ||= pact_file_paths.collect{ |pact_file_path| PactFile.new(pact_file_path) }
|
53
53
|
end
|
54
54
|
|
55
|
+
def consumer_names
|
56
|
+
pact_files.collect(&:consumer_name).uniq
|
57
|
+
end
|
58
|
+
|
55
59
|
def publish_pact pact
|
56
60
|
begin
|
57
61
|
$stdout.puts "Publishing #{pact.pact_name} to pact broker at #{pact_broker_base_url}"
|
@@ -72,12 +76,14 @@ module PactBroker
|
|
72
76
|
def tag_consumer_version tag
|
73
77
|
versions = pact_broker_client.pacticipants.versions
|
74
78
|
Retry.while_error do
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
consumer_names.collect do | consumer_name |
|
80
|
+
$stdout.puts "Tagging version #{consumer_version} of #{consumer_name} as #{tag.inspect}"
|
81
|
+
versions.tag(pacticipant: consumer_name, version: consumer_version, tag: tag)
|
82
|
+
true
|
83
|
+
end
|
78
84
|
end
|
79
85
|
rescue => e
|
80
|
-
$stderr.puts "Failed to tag
|
86
|
+
$stderr.puts "Failed to tag versions due to error: #{e.class} - #{e}"
|
81
87
|
false
|
82
88
|
end
|
83
89
|
|
@@ -89,15 +95,11 @@ module PactBroker
|
|
89
95
|
end
|
90
96
|
|
91
97
|
latest_pact_url = pacts.publish(pact_hash: pact, consumer_version: consumer_version)
|
92
|
-
$stdout.puts "The latest version of this pact can be accessed at the following URL
|
98
|
+
$stdout.puts "The latest version of this pact can be accessed at the following URL:\n#{latest_pact_url}"
|
93
99
|
true
|
94
100
|
end
|
95
101
|
end
|
96
102
|
|
97
|
-
def consumer_name
|
98
|
-
pact_files.first.consumer_name
|
99
|
-
end
|
100
|
-
|
101
103
|
def validate
|
102
104
|
raise PactBroker::Client::Error.new("Please specify the consumer_version") unless (consumer_version && consumer_version.to_s.strip.size > 0)
|
103
105
|
raise PactBroker::Client::Error.new("Please specify the pact_broker_base_url") unless (pact_broker_base_url && pact_broker_base_url.to_s.strip.size > 0)
|
@@ -81,6 +81,25 @@ module PactBroker
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
context "when publishing multiple files with different consumers" do
|
85
|
+
let(:pact_file_paths) { ['spec/pacts/consumer-provider.json','spec/pacts/foo-bar.json']}
|
86
|
+
let(:tags) { ['dev'] }
|
87
|
+
|
88
|
+
it "tags each consumer" do
|
89
|
+
expect(pact_versions_client).to receive(:tag).with(
|
90
|
+
pacticipant: "Consumer",
|
91
|
+
version: consumer_version,
|
92
|
+
tag: "dev"
|
93
|
+
)
|
94
|
+
expect(pact_versions_client).to receive(:tag).with(
|
95
|
+
pacticipant: "Foo",
|
96
|
+
version: consumer_version,
|
97
|
+
tag: "dev"
|
98
|
+
)
|
99
|
+
subject.call
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
84
103
|
context "when publishing one or more pacts fails" do
|
85
104
|
let(:pact_file_paths) { ['spec/pacts/consumer-provider.json','spec/pacts/foo-bar.json']}
|
86
105
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.30.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Skurrie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/pact_broker/client/webhooks/test.rb
|
217
217
|
- lib/pact_broker_client.rb
|
218
218
|
- pact-broker-client.gemspec
|
219
|
+
- script/create-pacticipant.sh
|
219
220
|
- script/generate-cli-usage.sh
|
220
221
|
- script/publish-pact.sh
|
221
222
|
- script/release.sh
|