knapsack_pro 8.3.3 → 9.0.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 +4 -4
- data/.circleci/config.yml +1 -2
- data/.gitignore +0 -1
- data/CHANGELOG.md +23 -2
- data/README.md +1 -1
- data/knapsack_pro.gemspec +1 -1
- data/lib/knapsack_pro/client/api/v1/queues.rb +1 -0
- data/lib/knapsack_pro/client/connection.rb +97 -52
- data/lib/knapsack_pro/config/ci/github_actions.rb +6 -4
- data/lib/knapsack_pro/queue_allocator.rb +13 -12
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/knapsack_pro.rb +9 -3
- data/spec/integration/runners/fallback_spec.rb +4 -4
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +4 -4
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +4 -4
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +4 -4
- data/spec/integration/runners/queue/rspec_runner_spec.rb +20 -20
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +3 -1
- data/spec/knapsack_pro/client/connection_spec.rb +19 -15
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +40 -18
- data/spec/knapsack_pro/config/env_spec.rb +330 -352
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +448 -0
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +5 -5
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -1
- data/spec/knapsack_pro_spec.rb +63 -39
- data/spec_time_tracker/spec_helper.rb +29 -0
- metadata +6 -9
- data/bin/test +0 -15
- data/lib/knapsack_pro/logger_wrapper.rb +0 -22
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +0 -545
- data/spec/knapsack_pro/logger_wrapper_spec.rb +0 -21
|
@@ -137,22 +137,22 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
137
137
|
|
|
138
138
|
actual = subject
|
|
139
139
|
|
|
140
|
-
expect(actual.stdout).to include('DEBUG -- :
|
|
140
|
+
expect(actual.stdout).to include('DEBUG -- knapsack_pro: Queue Mode enabled.')
|
|
141
141
|
|
|
142
142
|
expect(actual.stdout).to include('A1 test example')
|
|
143
143
|
expect(actual.stdout).to include('B1 test example')
|
|
144
144
|
expect(actual.stdout).to include('C1 test example')
|
|
145
145
|
|
|
146
|
-
expect(actual.stdout).to include('INFO -- :
|
|
147
|
-
expect(actual.stdout).to include('INFO -- :
|
|
148
|
-
expect(actual.stdout).to include('INFO -- :
|
|
146
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:')
|
|
147
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --format d --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb"')
|
|
148
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --format d --default-path spec_integration "spec_integration/c_spec.rb"')
|
|
149
149
|
|
|
150
|
-
expect(actual.stdout).to include('INFO -- :
|
|
151
|
-
expect(actual.stdout).to include('INFO -- :
|
|
150
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: To retry all the tests assigned to this CI node, please run the following command on your machine:')
|
|
151
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --format d --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"')
|
|
152
152
|
|
|
153
153
|
expect(actual.stdout).to include('3 examples, 0 failures')
|
|
154
154
|
|
|
155
|
-
expect(actual.stdout).to include('DEBUG -- :
|
|
155
|
+
expect(actual.stdout).to include('DEBUG -- knapsack_pro: Global test execution duration:')
|
|
156
156
|
|
|
157
157
|
expect(actual.exit_code).to eq 0
|
|
158
158
|
end
|
|
@@ -230,7 +230,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
230
230
|
|
|
231
231
|
actual = subject
|
|
232
232
|
|
|
233
|
-
expect(actual.stdout).to include('ERROR -- :
|
|
233
|
+
expect(actual.stdout).to include('ERROR -- knapsack_pro: You forgot to call KnapsackPro::Adapters::RSpecAdapter.bind method in your test runner configuration file. It is needed to record test files time execution. Please follow the installation guide to configure your project properly https://knapsackpro.com/perma/ruby/installation-guide')
|
|
234
234
|
|
|
235
235
|
expect(actual.exit_code).to eq 1
|
|
236
236
|
end
|
|
@@ -917,12 +917,12 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
917
917
|
expect(actual.stdout).to include('Randomized with seed 123')
|
|
918
918
|
|
|
919
919
|
# 1st batch
|
|
920
|
-
expect(actual.stdout).to include('INFO -- :
|
|
920
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --order rand:123 --format progress --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb"')
|
|
921
921
|
# 2nd batch
|
|
922
|
-
expect(actual.stdout).to include('INFO -- :
|
|
922
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --order rand:123 --format progress --default-path spec_integration "spec_integration/c_spec.rb"')
|
|
923
923
|
|
|
924
924
|
# the final RSpec command with seed
|
|
925
|
-
expect(actual.stdout).to include('INFO -- :
|
|
925
|
+
expect(actual.stdout).to include('INFO -- knapsack_pro: bundle exec rspec --order rand:123 --format progress --default-path spec_integration "spec_integration/a_spec.rb" "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"')
|
|
926
926
|
|
|
927
927
|
expect(actual.exit_code).to eq 0
|
|
928
928
|
end
|
|
@@ -1061,7 +1061,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1061
1061
|
|
|
1062
1062
|
expect(actual.stdout).to include('An error occurred while loading ./spec_integration/failing_spec.rb')
|
|
1063
1063
|
expect(actual.stdout).to match(/undefined local variable or method .a_fake_method. for.* RSpec::ExampleGroups::BDescribe/)
|
|
1064
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1064
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: RSpec wants to quit')
|
|
1065
1065
|
expect(actual.stdout).to include('1 example, 0 failures, 1 error occurred outside of examples')
|
|
1066
1066
|
|
|
1067
1067
|
expect(actual.exit_code).to eq 1
|
|
@@ -1263,7 +1263,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1263
1263
|
# It breaks RSpec so it was not marked as failed.
|
|
1264
1264
|
expect(actual.stdout).to include('2 examples, 0 failures')
|
|
1265
1265
|
|
|
1266
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1266
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: Unexecuted tests on this CI node (including pending tests): spec_integration/b_spec.rb')
|
|
1267
1267
|
|
|
1268
1268
|
expect(actual.exit_code).to eq 1
|
|
1269
1269
|
end
|
|
@@ -1497,7 +1497,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1497
1497
|
|
|
1498
1498
|
actual = subject
|
|
1499
1499
|
|
|
1500
|
-
expect(actual.stdout).to include('ERROR -- :
|
|
1500
|
+
expect(actual.stdout).to include('ERROR -- knapsack_pro: The run_all_when_everything_filtered option is deprecated. See: https://knapsackpro.com/perma/ruby/rspec-deprecated-run-all-when-everything-filtered')
|
|
1501
1501
|
|
|
1502
1502
|
expect(actual.stdout).to_not include('A1 test example')
|
|
1503
1503
|
expect(actual.stdout).to_not include('B1 test example')
|
|
@@ -1576,8 +1576,8 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1576
1576
|
actual = subject
|
|
1577
1577
|
|
|
1578
1578
|
expect(actual.stdout).to include('0 examples, 0 failures')
|
|
1579
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1580
|
-
expect(actual.stdout).to include('DEBUG -- :
|
|
1579
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: No test files were executed on this CI node.')
|
|
1580
|
+
expect(actual.stdout).to include('DEBUG -- knapsack_pro: This CI node likely started work late after the test files were already executed by other CI nodes consuming the queue.')
|
|
1581
1581
|
|
|
1582
1582
|
expect(actual.exit_code).to eq 0
|
|
1583
1583
|
end
|
|
@@ -1601,8 +1601,8 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1601
1601
|
actual = subject
|
|
1602
1602
|
|
|
1603
1603
|
expect(actual.stdout).to include('0 examples, 0 failures')
|
|
1604
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1605
|
-
expect(actual.stdout).to include('DEBUG -- :
|
|
1604
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: No test files were executed on this CI node.')
|
|
1605
|
+
expect(actual.stdout).to include('DEBUG -- knapsack_pro: This CI node likely started work late after the test files were already executed by other CI nodes consuming the queue.')
|
|
1606
1606
|
|
|
1607
1607
|
expect(actual.exit_code).to eq 0
|
|
1608
1608
|
end
|
|
@@ -1821,7 +1821,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1821
1821
|
expect(actual.stdout).to_not include('C1 test example')
|
|
1822
1822
|
expect(actual.stdout).to_not include('C2 test example')
|
|
1823
1823
|
|
|
1824
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1824
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: Test execution has been canceled because the RSpec --fail-fast option is enabled. It will cause other CI nodes to run tests longer because they need to consume more tests from the Knapsack Pro Queue API.')
|
|
1825
1825
|
|
|
1826
1826
|
expect(actual.stdout).to include('2 examples, 1 failure')
|
|
1827
1827
|
|
|
@@ -1885,7 +1885,7 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
|
|
|
1885
1885
|
expect(actual.stdout).to_not include('C1 test example')
|
|
1886
1886
|
expect(actual.stdout).to_not include('C2 test example')
|
|
1887
1887
|
|
|
1888
|
-
expect(actual.stdout).to include('WARN -- :
|
|
1888
|
+
expect(actual.stdout).to include('WARN -- knapsack_pro: Test execution has been canceled because the RSpec --fail-fast option is enabled. It will cause other CI nodes to run tests longer because they need to consume more tests from the Knapsack Pro Queue API.')
|
|
1889
1889
|
|
|
1890
1890
|
expect(actual.stdout).to include('3 examples, 2 failures')
|
|
1891
1891
|
|
|
@@ -10,6 +10,7 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
|
10
10
|
let(:masked_user_seat) { double }
|
|
11
11
|
let(:can_initialize_queue) { [false, true].sample }
|
|
12
12
|
let(:attempt_connect_to_queue) { [false, true].sample }
|
|
13
|
+
let(:batch_uuid) { SecureRandom.uuid }
|
|
13
14
|
|
|
14
15
|
subject do
|
|
15
16
|
described_class.queue(
|
|
@@ -19,7 +20,8 @@ describe KnapsackPro::Client::API::V1::Queues do
|
|
|
19
20
|
branch: branch,
|
|
20
21
|
node_total: node_total,
|
|
21
22
|
node_index: node_index,
|
|
22
|
-
test_files: test_files
|
|
23
|
+
test_files: test_files,
|
|
24
|
+
batch_uuid: batch_uuid
|
|
23
25
|
)
|
|
24
26
|
end
|
|
25
27
|
|
|
@@ -72,6 +72,9 @@ shared_examples 'when retry request' do
|
|
|
72
72
|
|
|
73
73
|
before do
|
|
74
74
|
expect(KnapsackPro).to receive(:logger).at_least(1).and_return(logger)
|
|
75
|
+
allow(http).to receive(:set_debug_output)
|
|
76
|
+
allow(http).to receive(:ipaddr).and_return(nil)
|
|
77
|
+
allow(logger).to receive(:warn).at_least(:once)
|
|
75
78
|
end
|
|
76
79
|
|
|
77
80
|
it do
|
|
@@ -88,11 +91,11 @@ shared_examples 'when retry request' do
|
|
|
88
91
|
expect(logger).to receive(:warn).exactly(3).with('Request failed due to:')
|
|
89
92
|
expect(logger).to receive(:warn).exactly(3).with(server_error.inspect)
|
|
90
93
|
|
|
91
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
|
|
94
|
+
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
92
95
|
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
93
96
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
94
97
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
95
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
|
|
98
|
+
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
96
99
|
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
97
100
|
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
98
101
|
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
@@ -127,12 +130,12 @@ shared_examples 'when retry request' do
|
|
|
127
130
|
expect(logger).to receive(:warn).exactly(4).with('Request failed due to:')
|
|
128
131
|
expect(logger).to receive(:warn).exactly(4).with(server_error.inspect)
|
|
129
132
|
|
|
130
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
|
|
133
|
+
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
131
134
|
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
132
135
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
133
136
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
134
137
|
|
|
135
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
|
|
138
|
+
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
136
139
|
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
137
140
|
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
138
141
|
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
@@ -141,7 +144,7 @@ shared_examples 'when retry request' do
|
|
|
141
144
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
142
145
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
143
146
|
|
|
144
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
|
|
147
|
+
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
145
148
|
11.times do |i|
|
|
146
149
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
147
150
|
end
|
|
@@ -174,12 +177,12 @@ shared_examples 'when retry request' do
|
|
|
174
177
|
expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
|
|
175
178
|
expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
|
|
176
179
|
|
|
177
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
|
|
180
|
+
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
178
181
|
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
179
182
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
180
183
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
181
184
|
|
|
182
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
|
|
185
|
+
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
183
186
|
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
184
187
|
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
185
188
|
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
@@ -188,17 +191,17 @@ shared_examples 'when retry request' do
|
|
|
188
191
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
189
192
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
190
193
|
|
|
191
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
|
|
194
|
+
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
192
195
|
11.times do |i|
|
|
193
196
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
194
197
|
end
|
|
195
198
|
|
|
196
|
-
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to Knapsack Pro API.")
|
|
199
|
+
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to the Knapsack Pro API.")
|
|
197
200
|
15.times do |i|
|
|
198
201
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
199
202
|
end
|
|
200
203
|
|
|
201
|
-
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to Knapsack Pro API.")
|
|
204
|
+
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to the Knapsack Pro API.")
|
|
202
205
|
19.times do |i|
|
|
203
206
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
204
207
|
end
|
|
@@ -231,12 +234,12 @@ shared_examples 'when retry request' do
|
|
|
231
234
|
expect(logger).to receive(:warn).exactly(6).with('Request failed due to:')
|
|
232
235
|
expect(logger).to receive(:warn).exactly(6).with(server_error.inspect)
|
|
233
236
|
|
|
234
|
-
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to Knapsack Pro API.")
|
|
237
|
+
expect(logger).to receive(:warn).with("Wait for 8s before retrying the request to the Knapsack Pro API.")
|
|
235
238
|
expect(logger).to receive(:warn).with("6s left before retry...")
|
|
236
239
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
237
240
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
238
241
|
|
|
239
|
-
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to Knapsack Pro API.")
|
|
242
|
+
expect(logger).to receive(:warn).with("Wait for 16s before retrying the request to the Knapsack Pro API.")
|
|
240
243
|
expect(logger).to receive(:warn).with("14s left before retry...")
|
|
241
244
|
expect(logger).to receive(:warn).with("12s left before retry...")
|
|
242
245
|
expect(logger).to receive(:warn).with("10s left before retry...")
|
|
@@ -245,17 +248,17 @@ shared_examples 'when retry request' do
|
|
|
245
248
|
expect(logger).to receive(:warn).with("4s left before retry...")
|
|
246
249
|
expect(logger).to receive(:warn).with("2s left before retry...")
|
|
247
250
|
|
|
248
|
-
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to Knapsack Pro API.")
|
|
251
|
+
expect(logger).to receive(:warn).with("Wait for 24s before retrying the request to the Knapsack Pro API.")
|
|
249
252
|
11.times do |i|
|
|
250
253
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
251
254
|
end
|
|
252
255
|
|
|
253
|
-
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to Knapsack Pro API.")
|
|
256
|
+
expect(logger).to receive(:warn).with("Wait for 32s before retrying the request to the Knapsack Pro API.")
|
|
254
257
|
15.times do |i|
|
|
255
258
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
256
259
|
end
|
|
257
260
|
|
|
258
|
-
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to Knapsack Pro API.")
|
|
261
|
+
expect(logger).to receive(:warn).with("Wait for 40s before retrying the request to the Knapsack Pro API.")
|
|
259
262
|
19.times do |i|
|
|
260
263
|
expect(logger).to receive(:warn).with("#{(i+1)*2}s left before retry...")
|
|
261
264
|
end
|
|
@@ -311,6 +314,7 @@ describe KnapsackPro::Client::Connection do
|
|
|
311
314
|
expect(http).to receive(:use_ssl=).with(false)
|
|
312
315
|
expect(http).to receive(:open_timeout=).with(15)
|
|
313
316
|
expect(http).to receive(:read_timeout=).with(15)
|
|
317
|
+
allow(http).to receive(:ipaddr=).at_least(:once)
|
|
314
318
|
end
|
|
315
319
|
|
|
316
320
|
context 'when http method is POST on GitHub Actions' do
|
|
@@ -61,30 +61,52 @@ describe KnapsackPro::Config::CI::GithubActions do
|
|
|
61
61
|
describe '#branch' do
|
|
62
62
|
subject { described_class.new.branch }
|
|
63
63
|
|
|
64
|
-
context 'when
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it { should eql 'main' }
|
|
64
|
+
context 'when GITHUB_HEAD_REF is set' do
|
|
65
|
+
let(:env) do
|
|
66
|
+
{
|
|
67
|
+
'GITHUB_HEAD_REF' => 'feature',
|
|
68
|
+
'GITHUB_REF_NAME' => 'main',
|
|
69
|
+
'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d'
|
|
70
|
+
}
|
|
74
71
|
end
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
|
|
80
|
-
}
|
|
81
|
-
end
|
|
73
|
+
it { should eql 'feature' }
|
|
74
|
+
end
|
|
82
75
|
|
|
83
|
-
|
|
76
|
+
context 'when GITHUB_REF_NAME is set' do
|
|
77
|
+
let(:env) do
|
|
78
|
+
{
|
|
79
|
+
'GITHUB_REF_NAME' => 'main',
|
|
80
|
+
'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d'
|
|
81
|
+
}
|
|
84
82
|
end
|
|
83
|
+
|
|
84
|
+
it { should eql 'main' }
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
context
|
|
87
|
+
context 'when GITHUB_HEAD_REF is set to empty string' do
|
|
88
|
+
let(:env) do
|
|
89
|
+
{
|
|
90
|
+
'GITHUB_HEAD_REF' => '',
|
|
91
|
+
'GITHUB_REF_NAME' => 'main',
|
|
92
|
+
'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d'
|
|
93
|
+
}
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it { should eql 'main' }
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context 'when GITHUB_SHA is set' do
|
|
100
|
+
let(:env) do
|
|
101
|
+
{
|
|
102
|
+
'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d'
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context 'with no ENVs' do
|
|
88
110
|
it { should be nil }
|
|
89
111
|
end
|
|
90
112
|
end
|