pact_broker-client 1.68.0 → 1.69.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
  SHA256:
3
- metadata.gz: 34449d696b8c2dd03158cb963bb29d5a98df30563b1dfc34172a2e0005421824
4
- data.tar.gz: 77f60ba7270a1b1fb8f59a41fd97e047d28536d6857d88109a52efedb6b018ff
3
+ metadata.gz: d04543119f56e452c3c57968e73850a026d249e4db7a179b07d7fd9e08b1b39e
4
+ data.tar.gz: e29701ac23814dc00deea077e9dc318e21dcad486b5e01f28e3b422e0394310c
5
5
  SHA512:
6
- metadata.gz: 62f45e1885ff173605607913f796f87c1dae40b2618c92b240ffca95fd9e2be4cbae2c50d89676ac82fb26b6e0deb610bec00b2f81a23314b4d9a2927f7c9a9b
7
- data.tar.gz: 4bac04b4928c5f1846a963f7b8fb27a860332090ae7c69edce1de6537f63974e5a959ed62333a5fa17feda196525503d6dda3c470794303ddb9d03aff9723063
6
+ metadata.gz: 79f0f70224a4991f745e25b04251831f6a57872247780a9c0a4de75f3c1e04116534f42501a0c5fec982305fe235887ab21b7d915651be9275f706fba334a097
7
+ data.tar.gz: 007d7e79f2ffe068775cecb79324f811371bec604f18d657befebbe597391e70fda5bca489719dcd1fc395d673518b2dcc5a11537a94155562d353a8fc37fa11
@@ -0,0 +1,15 @@
1
+ name: Triage Issue
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+ - labeled
8
+ pull_request:
9
+ types:
10
+ - labeled
11
+
12
+ jobs:
13
+ call-workflow:
14
+ uses: pact-foundation/.github/.github/workflows/triage.yml@master
15
+ secrets: inherit
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ <a name="v1.69.0"></a>
2
+ ### v1.69.0 (2023-08-29)
3
+
4
+ #### Features
5
+
6
+ * can-i-merge (#117) ([badb030](/../../commit/badb030))
7
+
1
8
  <a name="v1.68.0"></a>
2
9
  ### v1.68.0 (2023-07-08)
3
10
 
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -444,16 +444,24 @@ Options:
444
444
  -l, [--latest=[TAG]]
445
445
  # Use the latest pacticipant version. Optionally specify a TAG
446
446
  to use the latest version with the specified tag.
447
- [--to-environment=ENVIRONMENT]
448
- # The environment into which the pacticipant(s) are to be
449
- deployed
450
447
  [--branch=BRANCH]
451
448
  # The branch of the version for which you want to check the
449
+ verification results.
450
+ [--main-branch], [--no-main-branch]
451
+ # Use the latest version of the configured main branch of the
452
+ pacticipant as the version for which you want to check the
452
453
  verification results
454
+ [--to-environment=ENVIRONMENT]
455
+ # The environment into which the pacticipant(s) are to be
456
+ deployed
453
457
  [--to=TAG]
454
458
  # The tag that represents the branch or environment of the
455
459
  integrated applications for which you want to check the
456
460
  verification result status.
461
+ [--ignore=IGNORE]
462
+ # The pacticipant name to ignore. Use once for each pacticipant
463
+ being ignored. A specific version can be ignored by also
464
+ specifying a --version after the pacticipant name option.
457
465
  -o, [--output=OUTPUT]
458
466
  # json or table
459
467
  # Default: table
@@ -1,20 +1,25 @@
1
+ require "pact_broker/client/string_refinements"
1
2
  module PactBroker
2
3
  module Client
3
4
  module CLI
4
5
  module MatrixCommands
6
+ using PactBroker::Client::StringRefinements
7
+
5
8
  def self.included(thor)
6
9
  thor.class_eval do
7
10
 
8
- desc "can-i-deploy", ""
11
+ desc "can-i-deploy", "Checks if the specified pacticipant version is safe to be deployed."
9
12
  long_desc File.read(File.join(__dir__, "can_i_deploy_long_desc.txt"))
10
13
 
11
14
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
12
15
  method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
13
16
  method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option. The environment variable PACT_BROKER_CAN_I_DEPLOY_IGNORE may also be used to specify a pacticipant name to ignore, with commas to separate multiple pacticipant names if necessary."
14
17
  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."
18
+ method_option :branch, required: false, desc: "The branch of the version for which you want to check the verification results.", default: nil
19
+ method_option :main_branch, required: false, type: :boolean, desc: "Use the latest version of the configured main branch of the pacticipant as the version for which you want to check the verification results", default: false
15
20
  method_option :to_environment, required: false, banner: "ENVIRONMENT", desc: "The environment into which the pacticipant(s) are to be deployed", default: nil
16
- method_option :branch, required: false, desc: "The branch of the version for which you want to check the verification results", default: nil
17
21
  method_option :to, required: false, banner: "TAG", desc: "The tag that represents the branch or environment of the integrated applications for which you want to check the verification result status.", default: nil
22
+ method_option :ignore, required: false, desc: "The pacticipant name to ignore. Use once for each pacticipant being ignored. A specific version can be ignored by also specifying a --version after the pacticipant name option."
18
23
  method_option :output, aliases: "-o", desc: "json or table", default: "table"
19
24
  method_option :retry_while_unknown, banner: "TIMES", type: :numeric, default: 0, required: false, desc: "The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)"
20
25
  method_option :retry_interval, banner: "SECONDS", type: :numeric, default: 10, required: false, desc: "The time between retries in seconds. Use in conjuction with --retry-while-unknown"
@@ -40,6 +45,31 @@ module PactBroker
40
45
  exit(can_i_deploy_exit_status) unless result.success
41
46
  end
42
47
 
48
+ desc "can-i-merge", "Checks if the specified pacticipant version is safe to merge into the main branch."
49
+ long_desc "Checks if the specified pacticipant version is compatible with the configured main branch of each of the pacticipants with which it is integrated."
50
+ method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
51
+ method_option :version, required: false, aliases: "-e", desc: "The pacticipant version. Must be entered after the --pacticipant that it relates to."
52
+ method_option :output, aliases: "-o", desc: "json or table", default: "table"
53
+ method_option :retry_while_unknown, banner: "TIMES", type: :numeric, default: 0, required: false, desc: "The number of times to retry while there is an unknown verification result (ie. the provider verification is likely still running)"
54
+ method_option :retry_interval, banner: "SECONDS", type: :numeric, default: 10, required: false, desc: "The time between retries in seconds. Use in conjuction with --retry-while-unknown"
55
+ method_option :dry_run, type: :boolean, default: false, desc: "When dry-run is enabled, always exit process with a success code. Can also be enabled by setting the environment variable PACT_BROKER_CAN_I_MERGE_DRY_RUN=true. This mode is useful when setting up your CI/CD pipeline for the first time, or in a 'break glass' situation where you need to knowingly deploy what Pact considers a breaking change. For the second scenario, it is recommended to use the environment variable and just set it for the build required to deploy that particular version, so you don't accidentally leave the dry run mode enabled."
56
+ shared_authentication_options
57
+
58
+ def can_i_merge(*ignored_but_necessary)
59
+ require "pact_broker/client/cli/version_selector_options_parser"
60
+ require "pact_broker/client/can_i_deploy"
61
+
62
+ validate_credentials
63
+ selectors = VersionSelectorOptionsParser.call(ARGV)
64
+ validate_can_i_deploy_selectors(selectors)
65
+ dry_run = options.dry_run || ENV["PACT_BROKER_CAN_I_MERGE_DRY_RUN"] == "true"
66
+ can_i_merge_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval, dry_run: dry_run, verbose: options.verbose }
67
+ result = CanIDeploy.call(selectors, { with_main_branches: true }, can_i_merge_options, pact_broker_client_options)
68
+ $stdout.puts result.message
69
+ $stdout.flush
70
+ exit(1) unless result.success
71
+ end
72
+
43
73
  if ENV.fetch("PACT_BROKER_FEATURES", "").include?("verification_required")
44
74
 
45
75
  method_option :pacticipant, required: true, aliases: "-a", desc: "The pacticipant name. Use once for each pacticipant being checked."
@@ -50,7 +80,7 @@ module PactBroker
50
80
  method_option :output, aliases: "-o", desc: "json or table", default: "table"
51
81
 
52
82
  shared_authentication_options
53
- desc "verification-required", "Checks if there is a verification required between the given pacticipant versions"
83
+ desc "verification-required", "Checks if there is a verification required between the given pacticipant versions."
54
84
  def verification_required(*ignored_but_necessary)
55
85
  require "pact_broker/client/cli/version_selector_options_parser"
56
86
  require "pact_broker/client/verification_required"
@@ -78,7 +108,7 @@ module PactBroker
78
108
  end
79
109
  end
80
110
 
81
- def validate_can_i_deploy_selectors selectors
111
+ def validate_can_i_deploy_selectors(selectors)
82
112
  pacticipants_without_versions = selectors.select{ |s| s[:version].nil? && s[:latest].nil? && s[:tag].nil? && s[:branch].nil? }.collect{ |s| s[:pacticipant] }
83
113
  raise ::Thor::RequiredArgumentMissingError, "The version must be specified using `--version VERSION`, `--branch BRANCH` `--latest`, `--latest TAG`, or `--all TAG` for pacticipant #{pacticipants_without_versions.join(", ")}" if pacticipants_without_versions.any?
84
114
  end
@@ -17,6 +17,10 @@ module PactBroker
17
17
  when "--latest", "-l"
18
18
  selectors << { pacticipant: nil } if selectors.empty?
19
19
  selectors.last[:latest] = true
20
+ when "--main-branch"
21
+ selectors << { pacticipant: nil } if selectors.empty?
22
+ selectors.last[:main_branch] = true
23
+ selectors.last[:latest] = true
20
24
  when /^\-/
21
25
  nil
22
26
  else
@@ -35,6 +39,10 @@ module PactBroker
35
39
  selectors << { pacticipant: nil } if selectors.empty?
36
40
  selectors.last[:branch] = word
37
41
  selectors.last[:latest] = true
42
+ when "--main-branch"
43
+ selectors << { pacticipant: nil } if selectors.empty?
44
+ selectors.last[:main_branch] = true
45
+ selectors.last[:latest] = true
38
46
  when "--all"
39
47
  selectors << { pacticipant: nil } if selectors.empty?
40
48
  selectors.last[:tag] = word
@@ -43,6 +43,9 @@ module PactBroker
43
43
  if matrix_options[:to_tag]
44
44
  opts[:latest] = 'true'
45
45
  opts[:tag] = matrix_options[:to_tag]
46
+ elsif matrix_options[:with_main_branches]
47
+ opts[:latest] = 'true'
48
+ opts[:mainBranch] = 'true'
46
49
  elsif selectors.size == 1 && !matrix_options[:to_environment]
47
50
  opts[:latest] = 'true'
48
51
  end
@@ -59,11 +62,11 @@ module PactBroker
59
62
  hash[:latest] = 'true' if selector[:latest]
60
63
  hash[:tag] = selector[:tag] if selector[:tag]
61
64
  hash[:branch] = selector[:branch] if selector[:branch]
65
+ hash[:mainBranch] = 'true' if selector[:main_branch]
62
66
  end
63
67
  end
64
68
  end
65
69
 
66
-
67
70
  def result_message
68
71
  if json_output?
69
72
  response_entity.response.raw_body
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.68.0'
3
+ VERSION = '1.69.0'
4
4
  end
5
5
  end
@@ -0,0 +1,43 @@
1
+ require "pact_broker/client/cli/broker"
2
+
3
+ module PactBroker
4
+ module Client
5
+ module CLI
6
+ describe Broker do
7
+ before do
8
+ subject.options = OpenStruct.new(minimum_valid_options)
9
+ allow($stdout).to receive(:puts)
10
+ allow($stderr).to receive(:puts)
11
+ allow(Retry).to receive(:sleep)
12
+
13
+ stub_const("ARGV", %w[--pacticipant Foo --version 1])
14
+ stub_request(:get, "http://pact-broker/matrix?latest=true&latestby=cvp&mainBranch=true&q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1").
15
+ with(
16
+ headers: {
17
+ 'Accept'=>'application/hal+json',
18
+ }).
19
+ to_return(status: 200, body: File.read("spec/support/matrix.json"), headers: { "Content-Type" => "application/hal+json" })
20
+ end
21
+
22
+ let(:minimum_valid_options) do
23
+ {
24
+ broker_base_url: 'http://pact-broker',
25
+ output: 'table',
26
+ verbose: 'verbose',
27
+ retry_while_unknown: 1,
28
+ retry_interval: 2,
29
+ limit: 1000,
30
+ dry_run: false
31
+ }
32
+ end
33
+
34
+ let(:invoke_can_i_merge) { subject.can_i_merge }
35
+
36
+ it "sends a matrix query" do
37
+ expect($stdout).to receive(:puts).with(/Computer says yes/)
38
+ invoke_can_i_merge
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -75,6 +75,12 @@ module PactBroker
75
75
  ],[
76
76
  ["--branch", "main"],
77
77
  [{ pacticipant: nil, branch: "main", latest: true }]
78
+ ],[
79
+ ["--pacticipant", "Foo", "--main-branch", "--pacticipant", "Bar", "--version", "1"],
80
+ [{ pacticipant: "Foo", main_branch: true, latest: true }, { pacticipant: "Bar", version: "1" }]
81
+ ],[
82
+ ["--main-branch"],
83
+ [{ pacticipant: nil, main_branch: true, latest: true }]
78
84
  ]
79
85
  ]
80
86
 
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.68.0
4
+ version: 1.69.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: 2023-07-10 00:00:00.000000000 Z
11
+ date: 2023-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -217,6 +217,7 @@ files:
217
217
  - ".github/workflows/release_gem.yml"
218
218
  - ".github/workflows/smartbear-issue-label-added.yml"
219
219
  - ".github/workflows/test.yml"
220
+ - ".github/workflows/triage.yml"
220
221
  - ".github/workflows/trigger_pact_docs_update.yml"
221
222
  - ".gitignore"
222
223
  - ".rspec"
@@ -224,6 +225,7 @@ files:
224
225
  - CHANGELOG.md
225
226
  - Dockerfile
226
227
  - Gemfile
228
+ - LICENSE.txt
227
229
  - README.md
228
230
  - RELEASING.md
229
231
  - Rakefile
@@ -353,6 +355,7 @@ files:
353
355
  - spec/fixtures/approvals/list_environments.approved.txt
354
356
  - spec/fixtures/foo-bar.json
355
357
  - spec/integration/can_i_deploy_spec.rb
358
+ - spec/integration/can_i_merge_spec.rb
356
359
  - spec/integration/create_version_tag_spec.rb
357
360
  - spec/integration/describe_environment_spec.rb
358
361
  - spec/lib/pact_broker/client/base_client_spec.rb
@@ -449,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
449
452
  - !ruby/object:Gem::Version
450
453
  version: '0'
451
454
  requirements: []
452
- rubygems_version: 3.4.15
455
+ rubygems_version: 3.4.19
453
456
  signing_key:
454
457
  specification_version: 4
455
458
  summary: See description
@@ -462,6 +465,7 @@ test_files:
462
465
  - spec/fixtures/approvals/list_environments.approved.txt
463
466
  - spec/fixtures/foo-bar.json
464
467
  - spec/integration/can_i_deploy_spec.rb
468
+ - spec/integration/can_i_merge_spec.rb
465
469
  - spec/integration/create_version_tag_spec.rb
466
470
  - spec/integration/describe_environment_spec.rb
467
471
  - spec/lib/pact_broker/client/base_client_spec.rb