pact_broker-client 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66e0409305fdcec099daca823e1cb127ef56081d
4
- data.tar.gz: 810b2cd5e4f581e229104fb30cf9fddaf1387aa6
3
+ metadata.gz: 7a240cb5444a544a20e73c613823dbb906a91f72
4
+ data.tar.gz: 017c87cc9083555bbeedd798ff3da5a006af2136
5
5
  SHA512:
6
- metadata.gz: c5d6208dedba22ebcbd587bf593d3ca626c54d60d3f3e0a5b3fc23c2d02b6d282e416ae024fdbad77ab1a0915602f3d715fb6ad04b59bcd17c579a249be47de2
7
- data.tar.gz: 4b37910c9a784962d4f9e054d0308e13227f7a267e60c8e64f8803faf6a71cb7a1d215a4eb7b35300fef35f6437dcd229bc991af636e6e7cb1de2a89051b5639
6
+ metadata.gz: de778e9c51875c42ef42c82847cbd2dd1684d275229de7feaec5c478e21ae3c6f4caa10f690e9ce054b3c067c33d48d544a30346bb0d581b89087e0509415427
7
+ data.tar.gz: 978a327dc7114bf433b81b0e95ce9a3ac0ef6c08399f133a52af36c52eee90dd211438c0a916957344b62f85b7caca5c461f8df7b28de6ece4e8b49c3535738c
@@ -1,3 +1,19 @@
1
+ <a name="v1.13.0"></a>
2
+ ### v1.13.0 (2017-11-09)
3
+
4
+
5
+ #### Features
6
+
7
+ * **can-i-deploy**
8
+ * allow pacticipant version to be checked against latest tagged versions of all the other pacticipants ([7f10e13](/../../commit/7f10e13))
9
+
10
+
11
+ #### Bug Fixes
12
+
13
+ * **publish**
14
+ * accept pact file paths using windows separator ([5ee9dd7](/../../commit/5ee9dd7))
15
+
16
+
1
17
  <a name="v1.12.0"></a>
2
18
  ### v1.12.0 (2017-11-06)
3
19
 
@@ -0,0 +1,17 @@
1
+ # fix lineendings in Windows
2
+ init:
3
+ - git config --global core.autocrlf input
4
+
5
+ build: off
6
+
7
+ install:
8
+ - set PATH=C:\Ruby22\bin;%PATH%
9
+ - bundle install
10
+
11
+ before_test:
12
+ - ruby -v
13
+ - gem -v
14
+ - bundle -v
15
+
16
+ test_script:
17
+ - bundle exec rake
@@ -17,13 +17,14 @@ module PactBroker
17
17
  end
18
18
  end
19
19
 
20
- def self.call(pact_broker_base_url, version_selectors, options, pact_broker_client_options={})
21
- new(pact_broker_base_url, version_selectors, options, pact_broker_client_options).call
20
+ def self.call(pact_broker_base_url, version_selectors, matrix_options, options, pact_broker_client_options={})
21
+ new(pact_broker_base_url, version_selectors, matrix_options, options, pact_broker_client_options).call
22
22
  end
23
23
 
24
- def initialize(pact_broker_base_url, version_selectors, options, pact_broker_client_options)
24
+ def initialize(pact_broker_base_url, version_selectors, matrix_options, options, pact_broker_client_options)
25
25
  @pact_broker_base_url = pact_broker_base_url
26
26
  @version_selectors = version_selectors
27
+ @matrix_options = matrix_options
27
28
  @options = options
28
29
  @pact_broker_client_options = pact_broker_client_options
29
30
  end
@@ -42,7 +43,7 @@ module PactBroker
42
43
 
43
44
  private
44
45
 
45
- attr_reader :pact_broker_base_url, :version_selectors, :options, :pact_broker_client_options
46
+ attr_reader :pact_broker_base_url, :version_selectors, :matrix_options, :options, :pact_broker_client_options
46
47
 
47
48
  def success_message(matrix)
48
49
  message = format_matrix(matrix)
@@ -73,7 +74,7 @@ module PactBroker
73
74
  end
74
75
 
75
76
  def matrix
76
- @matrix ||= Retry.until_true { pact_broker_client.matrix.get(version_selectors) }
77
+ @matrix ||= Retry.until_true { pact_broker_client.matrix.get(version_selectors, matrix_options) }
77
78
  end
78
79
 
79
80
  def pact_broker_client
@@ -21,6 +21,7 @@ module PactBroker
21
21
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
22
22
  method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
23
23
  method_option :latest, required: false, aliases: "-l", banner: '[TAG]', desc: "Use the latest pacticipant version. Optionally specify a TAG to use the latest version with the specified tag."
24
+ method_option :to, required: false, banner: 'TAG', desc: "This is too hard to explain in a short sentence. Look at the examples.", default: nil
24
25
  method_option :broker_base_url, required: true, aliases: "-b", desc: "The base URL of the Pact Broker"
25
26
  method_option :broker_username, aliases: "-u", desc: "Pact Broker basic auth username"
26
27
  method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password"
@@ -30,7 +31,7 @@ module PactBroker
30
31
  def can_i_deploy(*ignored_but_necessary)
31
32
  selectors = VersionSelectorOptionsParser.call(ARGV)
32
33
  validate_can_i_deploy_selectors(selectors)
33
- result = CanIDeploy.call(options.broker_base_url, selectors, {output: options.output}, pact_broker_client_options)
34
+ result = CanIDeploy.call(options.broker_base_url, selectors, {to_tag: options.to}, {output: options.output}, pact_broker_client_options)
34
35
  $stdout.puts result.message
35
36
  exit(1) unless result.success
36
37
  end
@@ -104,7 +105,8 @@ module PactBroker
104
105
  end
105
106
 
106
107
  def file_list pact_files
107
- Rake::FileList[pact_files].collect do | path |
108
+ correctly_separated_pact_files = pact_files.collect{ |path| path.gsub(/\\+/, '/') }
109
+ Rake::FileList[correctly_separated_pact_files].collect do | path |
108
110
  if File.directory?(path)
109
111
  Rake::FileList[File.join(path, "*.json")]
110
112
  else
@@ -6,10 +6,14 @@ The environment variables PACT_BROKER_BASE_URL_BASE_URL, PACT_BROKER_BASE_URL_US
6
6
 
7
7
  SCENARIOS
8
8
 
9
- Check the status of the pacts for a pacticipant version:
9
+ Check the status of the pacts for a pacticipant version. Note that this only checks that the most recent verification for each pact is successful. It doesn't provide any assurance that the pact has been verified by the *production* version of the provider, however, it is sufficient if you are doing true continuous deployment.
10
10
 
11
11
  $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --broker-base-url BROKER_BASE_URL
12
12
 
13
+ If all applications within the pact network are not being deployed continuously (ie. if there is a gap between pact verification and actual deployment) then the following strategy is recommended. Each application version should be tagged in the broker with the name of the stage (eg. test, staging, production) as it is deployed (see the pact-broker create-version-tag CLI). This enables you to use the following very simple command to check if the application version you are about to deploy is compatible with every other application version already deployed in that environment.
14
+
15
+ $ pact-broker can-i-deploy --pacticipant PACTICIPANT --version VERSION --to TAG --broker-base-url BROKER_BASE_URL
16
+
13
17
  Check the status of the pacts for the latest pacticipant version:
14
18
 
15
19
  $ pact-broker can-i-deploy --pacticipant PACTICIPANT --latest --broker-base-url BROKER_BASE_URL
@@ -47,6 +47,10 @@ module PactBroker
47
47
  if options.key?(:success)
48
48
  opts[:success] = [*options[:success]]
49
49
  end
50
+ if options[:to_tag]
51
+ opts[:latest] = 'true'
52
+ opts[:tag] = options[:to_tag]
53
+ end
50
54
  opts
51
55
  end
52
56
 
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.12.0'
3
+ VERSION = '1.13.0'
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ module PactBroker
5
5
  describe CanIDeploy do
6
6
  let(:pact_broker_base_url) { 'http://example.org' }
7
7
  let(:version_selectors) { [{ pacticipant: "Foo", version: "1" }] }
8
+ let(:matrix_options) { {} }
8
9
  let(:pact_broker_client_options) { { foo: 'bar' } }
9
10
  let(:matrix_client) { instance_double('PactBroker::Client::Matrix') }
10
11
  let(:matrix) { { matrix: ['foo'], summary: { deployable: true, reason: 'some reason' } } }
@@ -16,10 +17,10 @@ module PactBroker
16
17
  allow(Matrix::Formatter).to receive(:call).and_return('text matrix')
17
18
  end
18
19
 
19
- subject { CanIDeploy.call(pact_broker_base_url, version_selectors, options, pact_broker_client_options) }
20
+ subject { CanIDeploy.call(pact_broker_base_url, version_selectors, matrix_options, options, pact_broker_client_options) }
20
21
 
21
22
  it "retrieves the matrix from the pact broker" do
22
- expect(matrix_client).to receive(:get).with(version_selectors)
23
+ expect(matrix_client).to receive(:get).with(version_selectors, matrix_options)
23
24
  subject
24
25
  end
25
26
 
@@ -32,7 +32,7 @@ module PactBroker
32
32
  end
33
33
 
34
34
  it "invokes the CanIDeploy service" do
35
- expect(CanIDeploy).to receive(:call).with('http://pact-broker', version_selectors, {output: 'table'}, {verbose: 'verbose'})
35
+ expect(CanIDeploy).to receive(:call).with('http://pact-broker', version_selectors, {to_tag: nil}, {output: 'table'}, {verbose: 'verbose'})
36
36
  invoke_can_i_deploy
37
37
  end
38
38
 
@@ -44,13 +44,25 @@ module PactBroker
44
44
  end
45
45
  end
46
46
 
47
+ context "with --to" do
48
+ before do
49
+ subject.options.to = 'prod'
50
+ end
51
+
52
+ it "passes the value as the matrix options" do
53
+ expect(CanIDeploy).to receive(:call).with(anything, anything, {to_tag: 'prod'}, anything, anything)
54
+ invoke_can_i_deploy
55
+ end
56
+ end
57
+
47
58
  context "with basic auth" do
48
59
  before do
49
- subject.options = OpenStruct.new(minimum_valid_options.merge(broker_username: 'foo', broker_password: 'bar'))
60
+ subject.options.broker_username = 'foo'
61
+ subject.options.broker_password = 'bar'
50
62
  end
51
63
 
52
64
  it "invokes the CanIDeploy service with the basic auth credentials" do
53
- expect(CanIDeploy).to receive(:call).with(anything, anything, anything, {basic_auth: {username: "foo", password: "bar"}, verbose: 'verbose'})
65
+ expect(CanIDeploy).to receive(:call).with(anything, anything, anything, anything, {basic_auth: {username: "foo", password: "bar"}, verbose: 'verbose'})
54
66
  invoke_can_i_deploy
55
67
  end
56
68
  end
@@ -63,6 +63,21 @@ module PactBroker::Client::CLI
63
63
  end
64
64
  end
65
65
 
66
+ context "with a windows directory specified" do
67
+ let(:file_list) { ['spec\\support\cli_test_pacts'] }
68
+
69
+ it "invokes the PublishPacts command with the list of files in the directory" do
70
+ expect(PactBroker::Client::PublishPacts).to receive(:call).with(
71
+ anything,
72
+ ["spec/support/cli_test_pacts/bar.json", "spec/support/cli_test_pacts/foo.json"],
73
+ anything,
74
+ anything,
75
+ anything
76
+ )
77
+ invoke_broker
78
+ end
79
+ end
80
+
66
81
  context "with a tag" do
67
82
  before do
68
83
  subject.options = OpenStruct.new(minimum_valid_options.merge(tag: ['foo']))
@@ -595,6 +595,38 @@
595
595
  }
596
596
  }
597
597
  },
598
+ {
599
+ "description": "a request for the compatibility matrix for Foo version 1.2.3 and the latest prod versions of all other pacticipants",
600
+ "providerState": "the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 (tagged prod) and version 5.6.7",
601
+ "request": {
602
+ "method": "get",
603
+ "path": "/matrix",
604
+ "query": "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp&latest=true&tag=prod"
605
+ },
606
+ "response": {
607
+ "status": 200,
608
+ "headers": {
609
+ },
610
+ "body": {
611
+ "matrix": [
612
+ {
613
+ "consumer": {
614
+ "name": "Foo",
615
+ "version": {
616
+ "number": "1.2.3"
617
+ }
618
+ },
619
+ "provider": {
620
+ "name": "Bar",
621
+ "version": {
622
+ "number": "4.5.6"
623
+ }
624
+ }
625
+ }
626
+ ]
627
+ }
628
+ }
629
+ },
598
630
  {
599
631
  "description": "a request to publish a pact",
600
632
  "providerState": "the 'Pricing Service' already exists in the pact-broker",
@@ -243,6 +243,42 @@ module PactBroker::Client
243
243
  expect(matrix[:matrix].size).to eq 1
244
244
  end
245
245
  end
246
+
247
+ context "when checking if we can deploy with the latest tagged versions of the other services" do
248
+ before do
249
+ pact_broker.
250
+ given("the pact for Foo version 1.2.3 has been successfully verified by Bar version 4.5.6 (tagged prod) and version 5.6.7").
251
+ upon_receiving("a request for the compatibility matrix for Foo version 1.2.3 and the latest prod versions of all other pacticipants").
252
+ with(
253
+ method: :get,
254
+ path: "/matrix",
255
+ query: "q[][pacticipant]=Foo&q[][version]=1.2.3&latestby=cvp&latest=true&tag=prod"
256
+ ).
257
+ will_respond_with(
258
+ status: 200,
259
+ headers: pact_broker_response_headers,
260
+ body: matrix_response_body
261
+ )
262
+ end
263
+
264
+ let(:selectors) { [{ pacticipant: "Foo", version: "1.2.3" }] }
265
+
266
+ let(:matrix_response_body) {
267
+ {
268
+ matrix: [{
269
+ consumer: { name: 'Foo', version: { number: '1.2.3' } },
270
+ provider: { name: 'Bar', version: { number: '4.5.6'} },
271
+ }]
272
+ }
273
+ }
274
+
275
+ let(:options) { { to_tag: 'prod' } }
276
+
277
+ it "returns the matrix with the latest prod version of Bar" do
278
+ matrix = pact_broker_client.matrix.get(selectors, options)
279
+ expect(matrix[:matrix].size).to eq 1
280
+ end
281
+ end
246
282
  end
247
283
  end
248
284
  end
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.12.0
4
+ version: 1.13.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: 2017-11-06 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -153,6 +153,7 @@ files:
153
153
  - README.md
154
154
  - RELEASING.md
155
155
  - Rakefile
156
+ - appveyor.yml
156
157
  - bin/pact-broker
157
158
  - ci.sh
158
159
  - doc/markdown/Pact Broker Client - Pact Broker.md