pact_broker-client 1.54.0 → 1.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9478634ba01370a4d9cfff8a54ae4165a95b5525258795e57d3da002b6ca510f
4
- data.tar.gz: 3ca1944dacbff6fcf88c718d5ec7c4a85e3d2b764492024aca504c4dd5b02235
3
+ metadata.gz: 9b5e2bdbb0df7479cecc969634bc78e79fb64b799410bab2b1b45e33c6db635e
4
+ data.tar.gz: df5775b4c3c5d0a52cf0777cdbcffeb2b51ecafed78d40d092d4961620b21001
5
5
  SHA512:
6
- metadata.gz: fddb34d2ce7a559323ab51b90dabb2c003f731e8dc8b5666b9531fb7fc689452f54fc9d273d1c894cc398a36168817b8ab46ceba112975075660f935d6700292
7
- data.tar.gz: b2e377f2f4e823699847f1be5e366b0c95a5ad9cbff7e37b6e149e6eb510b1c1826b0bd0cdd8ed186adaaac7c0001dd4b982222cfeb38b2f38a3bd15b4f0c1c6
6
+ metadata.gz: 89df36d9fe800cd97e0500d6d89305d3596e5f17d34c3ea4e6286a88c4257db39427c938792d784b3ed8450011d53592fb5bd436785d87cc73edefeca8722067
7
+ data.tar.gz: 617675fd4f1de88ef167c9fd5ef3b82d190d5f63fd22f1fa1e19fb8af437ad268e6406c7bd75be56f1b5c65a515b530ae878f0ba44c912d66973cb5af7193405
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ <a name="v1.55.0"></a>
2
+ ### v1.55.0 (2021-10-03)
3
+
4
+ #### Features
5
+
6
+ * support Github Actions environment variables for --tag-with-git-branch ([2b8dac5](/../../commit/2b8dac5))
7
+
1
8
  <a name="v1.54.0"></a>
2
9
  ### v1.54.0 (2021-10-01)
3
10
 
@@ -25,9 +25,8 @@ module PactBroker
25
25
  using PactBroker::Client::HashRefinements
26
26
 
27
27
  COMMAND = 'git rev-parse --abbrev-ref HEAD'.freeze
28
- 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
29
- COMMIT_ENV_VAR_NAMES = %w{BUILDKITE_COMMIT CIRCLE_SHA1 TRAVIS_COMMIT GIT_COMMIT APPVEYOR_REPO_COMMIT CI_COMMIT_ID BITBUCKET_COMMIT}
30
-
28
+ BRANCH_ENV_VAR_NAMES = %w{GITHUB_REF BUILDKITE_BRANCH CIRCLE_BRANCH TRAVIS_BRANCH GIT_BRANCH GIT_LOCAL_BRANCH APPVEYOR_REPO_BRANCH CI_COMMIT_REF_NAME BITBUCKET_BRANCH}.freeze
29
+ COMMIT_ENV_VAR_NAMES = %w{GITHUB_SHA BUILDKITE_COMMIT CIRCLE_SHA1 TRAVIS_COMMIT GIT_COMMIT APPVEYOR_REPO_COMMIT CI_COMMIT_ID BITBUCKET_COMMIT}
31
30
  BUILD_URL_ENV_VAR_NAMES = %w{BUILDKITE_BUILD_URL CIRCLE_BUILD_URL TRAVIS_BUILD_WEB_URL BUILD_URL }
32
31
 
33
32
  def self.commit
@@ -38,6 +37,10 @@ module PactBroker
38
37
  find_branch_from_known_env_vars || find_branch_from_env_var_ending_with_branch || branch_from_git_command(options[:raise_error])
39
38
  end
40
39
 
40
+ def self.build_url
41
+ github_build_url || BUILD_URL_ENV_VAR_NAMES.collect{ | name | value_from_env_var(name) }.compact.first
42
+ end
43
+
41
44
  # private
42
45
 
43
46
  def self.find_commit_from_env_vars
@@ -45,7 +48,8 @@ module PactBroker
45
48
  end
46
49
 
47
50
  def self.find_branch_from_known_env_vars
48
- BRANCH_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
51
+ val = BRANCH_ENV_VAR_NAMES.collect { |env_var_name| value_from_env_var(env_var_name) }.compact.first
52
+ val.gsub(%r{^refs/heads/}, "") if val
49
53
  end
50
54
 
51
55
  def self.find_branch_from_env_var_ending_with_branch
@@ -104,6 +108,13 @@ module PactBroker
104
108
  return []
105
109
  end
106
110
  end
111
+
112
+ def self.github_build_url
113
+ parts = %w{GITHUB_SERVER_URL GITHUB_REPOSITORY GITHUB_RUN_ID}.collect{ | name | value_from_env_var(name) }
114
+ if parts.all?
115
+ [parts[0], parts[1], "actions", "runs", parts[2]].join("/")
116
+ end
117
+ end
107
118
  end
108
119
  end
109
120
  end
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.54.0'
3
+ VERSION = '1.55.0'
4
4
  end
5
5
  end
@@ -35,6 +35,16 @@ module PactBroker
35
35
  end
36
36
  end
37
37
 
38
+ context "when the branch starts with refs/heads/" do
39
+ before do
40
+ allow(ENV).to receive(:[]).with("GITHUB_REF").and_return("refs/heads/feature-x")
41
+ end
42
+
43
+ it "trims off the refs/heads/" do
44
+ expect(subject).to eq "feature-x"
45
+ end
46
+ end
47
+
38
48
  context "when there is one environment variable ending with _BRANCH" do
39
49
  before do
40
50
  allow(ENV).to receive(:keys).and_return(%w{FOO_BRANCH BAR_BRANCH BLAH})
@@ -108,6 +118,42 @@ module PactBroker
108
118
  include_examples "when raise_error is false"
109
119
  end
110
120
  end
121
+
122
+ describe ".build_url" do
123
+ before do
124
+ allow(ENV).to receive(:[]).and_call_original
125
+ end
126
+
127
+ subject { Git.build_url }
128
+
129
+ context "when nothing is set" do
130
+ before do
131
+ allow(ENV).to receive(:[]).and_return(nil)
132
+ end
133
+
134
+ it { is_expected.to eq nil }
135
+ end
136
+
137
+ context "when BUILDKITE_BUILD_URL is set" do
138
+ before do
139
+ allow(ENV).to receive(:[]).and_return(nil)
140
+ allow(ENV).to receive(:[]).with("BUILDKITE_BUILD_URL").and_return("http://build")
141
+ end
142
+
143
+ it { is_expected.to eq "http://build" }
144
+ end
145
+
146
+ context "when the Github Actions env vars are set" do
147
+ before do
148
+ allow(ENV).to receive(:[]).and_return(nil)
149
+ allow(ENV).to receive(:[]).with("GITHUB_SERVER_URL").and_return("https://github.com")
150
+ allow(ENV).to receive(:[]).with("GITHUB_REPOSITORY").and_return("org/repo")
151
+ allow(ENV).to receive(:[]).with("GITHUB_RUN_ID").and_return("1")
152
+ end
153
+
154
+ it { is_expected.to eq "https://github.com/org/repo/actions/runs/1" }
155
+ end
156
+ end
111
157
  end
112
158
  end
113
159
  end
data/tasks/pact.rake CHANGED
@@ -1,4 +1,5 @@
1
- require 'pact_broker/client/tasks'
1
+ require "pact_broker/client/tasks"
2
+ require "pact_broker/client/git"
2
3
 
3
4
  PactBroker::Client::PublicationTask.new(:localhost) do | task |
4
5
  require 'pact_broker/client/version'
@@ -35,4 +36,5 @@ PactBroker::Client::PublicationTask.new(:pactflow) do | task |
35
36
  task.consumer_version = version
36
37
  task.pact_broker_base_url = "https://pact-oss.pactflow.io"
37
38
  task.pact_broker_token = ENV['PACT_BROKER_TOKEN']
39
+ task.build_url = PactBroker::Client::Git.build_url
38
40
  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.54.0
4
+ version: 1.55.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: 2021-10-01 00:00:00.000000000 Z
11
+ date: 2021-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty