knapsack_pro 3.9.0 → 3.11.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: e420b07793ab2ae891d047a88791a664ef1049cb3011a752e8c38b4c6f6a7ef7
4
- data.tar.gz: 378a11f2229b60b8491b705764d71efb241de8b8ab56a5cffd0476157584f0f9
3
+ metadata.gz: a43c73ef1e2535db96433d5a39659b4a02cf0ecb9baac50f5effef464c0638de
4
+ data.tar.gz: 49739064aea9230e17d9719bd3ee8bff27dead716bf388530eb4c9e5e079d6e1
5
5
  SHA512:
6
- metadata.gz: 6fc8003860fd45599a4f7ffe7dd2d0fbe6a472fab237e8ec704da2ca7084bbb84dac1859624f6ec2f40e0555ba266e29568520208c43b74b90dfcebb026a20f9
7
- data.tar.gz: a76e2e4d9b598aec22f261c40087c3b19ba67d7d3ad14a84255e135345dd373ac252d2697aa88a982e67f95e1be0ab8dab2cdfce9b4e494843ea87de1bfd5db7
6
+ metadata.gz: d019adc9a5a78d7b795e380828a5be81eca28702aba936c1fb6759b7294bffe3e90dfcc7ab009c844863cfbe4ead8c9a1bf1159a89dee44305f9d50803d798b7
7
+ data.tar.gz: c92054f2b1cdc5c842e0130d89ee8f9ebc9a44985721718b9af48e3c9e6db9f3e391fe2a8ead8ad8ebf040f0526a3ce4600014b4bbf62d1f43952c4b5e24025f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ### 3.11.0
4
+
5
+ * Send distinguishable user seat info over to the API
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/192
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.10.0...v3.11.0
10
+
11
+ ### 3.10.0
12
+
13
+ * Remove Solano CI and Snap CI support because they do not exist anymore
14
+
15
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/194
16
+
17
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.9.0...v3.10.0
18
+
3
19
  ### 3.9.0
4
20
 
5
21
  * Suppress all RSpec spec file names displayed in stdout at the beginning of running tests in Regular Mode only when the log level is >= `warn`
@@ -15,6 +15,7 @@ module KnapsackPro
15
15
  :node_total => args.fetch(:node_total),
16
16
  :node_index => args.fetch(:node_index),
17
17
  :ci_build_id => KnapsackPro::Config::Env.ci_node_build_id,
18
+ :user_seat => KnapsackPro::Config::Env.user_seat_hash,
18
19
  }
19
20
 
20
21
  unless request_hash[:cache_read_attempt]
@@ -16,6 +16,7 @@ module KnapsackPro
16
16
  :node_total => args.fetch(:node_total),
17
17
  :node_index => args.fetch(:node_index),
18
18
  :node_build_id => KnapsackPro::Config::Env.ci_node_build_id,
19
+ :user_seat => KnapsackPro::Config::Env.user_seat_hash,
19
20
  }
20
21
 
21
22
  if request_hash[:can_initialize_queue] && !request_hash[:attempt_connect_to_queue]
@@ -22,6 +22,9 @@ module KnapsackPro
22
22
 
23
23
  def project_dir
24
24
  end
25
+
26
+ def user_seat
27
+ end
25
28
  end
26
29
  end
27
30
  end
@@ -29,6 +29,10 @@ module KnapsackPro
29
29
  def project_dir
30
30
  ENV['BUILDKITE_BUILD_CHECKOUT_PATH']
31
31
  end
32
+
33
+ def user_seat
34
+ ENV['BUILDKITE_BUILD_AUTHOR'] || ENV['BUILDKITE_BUILD_CREATOR']
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -25,6 +25,10 @@ module KnapsackPro
25
25
  def project_dir
26
26
  ENV['CIRCLE_WORKING_DIRECTORY']
27
27
  end
28
+
29
+ def user_seat
30
+ ENV['CIRCLE_USERNAME'] || ENV['CIRCLE_PR_USERNAME']
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -29,6 +29,10 @@ module KnapsackPro
29
29
  def project_dir
30
30
  ENV['GITHUB_WORKSPACE']
31
31
  end
32
+
33
+ def user_seat
34
+ ENV['GITHUB_ACTOR']
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -16,7 +16,7 @@ module KnapsackPro
16
16
 
17
17
  def node_build_id
18
18
  ENV['CI_PIPELINE_ID'] || # Gitlab Release 9.0+
19
- ENV['CI_BUILD_ID'] # Gitlab Release 8.x
19
+ ENV['CI_BUILD_ID'] # Gitlab Release 8.x
20
20
  end
21
21
 
22
22
  def commit_hash
@@ -32,6 +32,11 @@ module KnapsackPro
32
32
  def project_dir
33
33
  ENV['CI_PROJECT_DIR']
34
34
  end
35
+
36
+ def user_seat
37
+ ENV['GITLAB_USER_NAME'] || # Gitlab Release 10.0
38
+ ENV['GITLAB_USER_EMAIL'] # Gitlab Release 8.12
39
+ end
35
40
  end
36
41
  end
37
42
  end
@@ -58,6 +58,16 @@ module KnapsackPro
58
58
  ci_env_for(:project_dir)
59
59
  end
60
60
 
61
+ def user_seat
62
+ ENV['KNAPSACK_PRO_USER_SEAT'] ||
63
+ ci_env_for(:user_seat)
64
+ end
65
+
66
+ def user_seat_hash
67
+ return unless user_seat
68
+ Digest::SHA2.hexdigest(user_seat)
69
+ end
70
+
61
71
  def test_file_pattern
62
72
  ENV['KNAPSACK_PRO_TEST_FILE_PATTERN']
63
73
  end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '3.9.0'
2
+ VERSION = '3.11.0'
3
3
  end
data/lib/knapsack_pro.rb CHANGED
@@ -21,8 +21,6 @@ require_relative 'knapsack_pro/config/ci/semaphore'
21
21
  require_relative 'knapsack_pro/config/ci/semaphore2'
22
22
  require_relative 'knapsack_pro/config/ci/buildkite'
23
23
  require_relative 'knapsack_pro/config/ci/travis'
24
- require_relative 'knapsack_pro/config/ci/snap_ci'
25
- require_relative 'knapsack_pro/config/ci/solano_ci'
26
24
  require_relative 'knapsack_pro/config/ci/codeship'
27
25
  require_relative 'knapsack_pro/config/ci/github_actions'
28
26
  require_relative 'knapsack_pro/config/ci/heroku'
@@ -6,6 +6,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
6
6
  let(:node_total) { double }
7
7
  let(:node_index) { double }
8
8
  let(:ci_build_id) { double }
9
+ let(:user_seat_hash) { double }
9
10
  let(:test_files) { double }
10
11
 
11
12
  subject do
@@ -22,6 +23,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
22
23
  before do
23
24
  expect(KnapsackPro::Config::Env).to receive(:fixed_test_suite_split).and_return(fixed_test_suite_split)
24
25
  expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(ci_build_id)
26
+ expect(KnapsackPro::Config::Env).to receive(:user_seat_hash).and_return(user_seat_hash)
25
27
  end
26
28
 
27
29
  context 'when cache_read_attempt=true' do
@@ -40,6 +42,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
40
42
  node_total: node_total,
41
43
  node_index: node_index,
42
44
  ci_build_id: ci_build_id,
45
+ user_seat: user_seat_hash,
43
46
  }
44
47
  }).and_return(action)
45
48
  expect(subject).to eq action
@@ -62,6 +65,7 @@ describe KnapsackPro::Client::API::V1::BuildDistributions do
62
65
  node_total: node_total,
63
66
  node_index: node_index,
64
67
  ci_build_id: ci_build_id,
68
+ user_seat: user_seat_hash,
65
69
  test_files: test_files
66
70
  }
67
71
  }).and_return(action)
@@ -7,6 +7,7 @@ describe KnapsackPro::Client::API::V1::Queues do
7
7
  let(:node_index) { double }
8
8
  let(:test_files) { double }
9
9
  let(:node_build_id) { double }
10
+ let(:user_seat_hash) { double }
10
11
 
11
12
  subject do
12
13
  described_class.queue(
@@ -23,6 +24,7 @@ describe KnapsackPro::Client::API::V1::Queues do
23
24
  before do
24
25
  expect(KnapsackPro::Config::Env).to receive(:fixed_queue_split).and_return(fixed_queue_split)
25
26
  expect(KnapsackPro::Config::Env).to receive(:ci_node_build_id).and_return(node_build_id)
27
+ expect(KnapsackPro::Config::Env).to receive(:user_seat_hash).and_return(user_seat_hash)
26
28
  end
27
29
 
28
30
  context 'when can_initialize_queue=true and attempt_connect_to_queue=true' do
@@ -43,6 +45,7 @@ describe KnapsackPro::Client::API::V1::Queues do
43
45
  node_total: node_total,
44
46
  node_index: node_index,
45
47
  node_build_id: node_build_id,
48
+ user_seat: user_seat_hash,
46
49
  }
47
50
  }).and_return(action)
48
51
  expect(subject).to eq action
@@ -67,6 +70,7 @@ describe KnapsackPro::Client::API::V1::Queues do
67
70
  node_total: node_total,
68
71
  node_index: node_index,
69
72
  node_build_id: node_build_id,
73
+ user_seat: user_seat_hash,
70
74
  test_files: test_files
71
75
  }
72
76
  }).and_return(action)
@@ -92,6 +96,7 @@ describe KnapsackPro::Client::API::V1::Queues do
92
96
  node_total: node_total,
93
97
  node_index: node_index,
94
98
  node_build_id: node_build_id,
99
+ user_seat: user_seat_hash,
95
100
  }
96
101
  }).and_return(action)
97
102
  expect(subject).to eq action
@@ -6,4 +6,5 @@ describe KnapsackPro::Config::CI::Base do
6
6
  its(:commit_hash) { should be nil }
7
7
  its(:branch) { should be nil }
8
8
  its(:project_dir) { should be nil }
9
+ its(:user_seat) { should be nil }
9
10
  end
@@ -76,8 +76,8 @@ describe KnapsackPro::Config::CI::Buildkite do
76
76
  subject { described_class.new.branch }
77
77
 
78
78
  context 'when environment exists' do
79
- let(:env) { { 'BUILDKITE_BRANCH' => 'master' } }
80
- it { should eql 'master' }
79
+ let(:env) { { 'BUILDKITE_BRANCH' => 'main' } }
80
+ it { should eql 'main' }
81
81
  end
82
82
 
83
83
  context "when environment doesn't exist" do
@@ -97,4 +97,39 @@ describe KnapsackPro::Config::CI::Buildkite do
97
97
  it { should be nil }
98
98
  end
99
99
  end
100
+
101
+ describe '#user_seat' do
102
+ subject { described_class.new.user_seat }
103
+
104
+ context 'when the BUILDKITE_BUILD_AUTHOR env var exists' do
105
+ let(:env) do
106
+ { 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
107
+ 'BUILDKITE_BUILD_CREATOR' => nil }
108
+ end
109
+
110
+ it { should eql 'Jane Doe' }
111
+ end
112
+
113
+ context 'when the BUILDKITE_BUILD_CREATOR env var exists' do
114
+ let(:env) do
115
+ { 'BUILDKITE_BUILD_AUTHOR' => nil,
116
+ 'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
117
+ end
118
+
119
+ it { should eql 'John Doe' }
120
+ end
121
+
122
+ context 'when both BUILDKITE_BUILD_AUTHOR and BUILDKITE_BUILD_CREATOR env vars exist' do
123
+ let(:env) do
124
+ { 'BUILDKITE_BUILD_AUTHOR' => 'Jane Doe',
125
+ 'BUILDKITE_BUILD_CREATOR' => 'John Doe' }
126
+ end
127
+
128
+ it { should eql 'Jane Doe' }
129
+ end
130
+
131
+ context "when neither env var exists" do
132
+ it { should be nil }
133
+ end
134
+ end
100
135
  end
@@ -63,8 +63,8 @@ describe KnapsackPro::Config::CI::Circle do
63
63
  subject { described_class.new.branch }
64
64
 
65
65
  context 'when environment exists' do
66
- let(:env) { { 'CIRCLE_BRANCH' => 'master' } }
67
- it { should eql 'master' }
66
+ let(:env) { { 'CIRCLE_BRANCH' => 'main' } }
67
+ it { should eql 'main' }
68
68
  end
69
69
 
70
70
  context "when environment doesn't exist" do
@@ -84,4 +84,39 @@ describe KnapsackPro::Config::CI::Circle do
84
84
  it { should be nil }
85
85
  end
86
86
  end
87
+
88
+ describe '#user_seat' do
89
+ subject { described_class.new.user_seat }
90
+
91
+ context 'when the CIRCLE_USERNAME env var exists' do
92
+ let(:env) do
93
+ { 'CIRCLE_USERNAME' => 'Jane Doe',
94
+ 'CIRCLE_PR_USERNAME' => nil }
95
+ end
96
+
97
+ it { should eql 'Jane Doe' }
98
+ end
99
+
100
+ context 'when the CIRCLE_PR_USERNAME env var exists' do
101
+ let(:env) do
102
+ { 'CIRCLE_USERNAME' => nil,
103
+ 'CIRCLE_PR_USERNAME' => 'John Doe' }
104
+ end
105
+
106
+ it { should eql 'John Doe' }
107
+ end
108
+
109
+ context 'when both CIRCLE_USERNAME and CIRCLE_PR_USERNAME env vars exist' do
110
+ let(:env) do
111
+ { 'CIRCLE_USERNAME' => 'Jane Doe',
112
+ 'CIRCLE_PR_USERNAME' => 'John Doe' }
113
+ end
114
+
115
+ it { should eql 'Jane Doe' }
116
+ end
117
+
118
+ context "when neither env var exists" do
119
+ it { should be nil }
120
+ end
121
+ end
87
122
  end
@@ -52,12 +52,12 @@ describe KnapsackPro::Config::CI::GithubActions do
52
52
  context 'when GITHUB_REF has value' do
53
53
  let(:env) do
54
54
  {
55
- 'GITHUB_REF' => 'master',
55
+ 'GITHUB_REF' => 'main',
56
56
  'GITHUB_SHA' => '2e13512fc230d6f9ebf4923352718e4d',
57
57
  }
58
58
  end
59
59
 
60
- it { should eql 'master' }
60
+ it { should eql 'main' }
61
61
  end
62
62
 
63
63
  context 'when GITHUB_REF is not set' do
@@ -88,4 +88,18 @@ describe KnapsackPro::Config::CI::GithubActions do
88
88
  it { should be nil }
89
89
  end
90
90
  end
91
+
92
+ describe '#user_seat' do
93
+ subject { described_class.new.user_seat }
94
+
95
+ context 'when the GITHUB_ACTOR environment variable exists' do
96
+ let(:env) { { 'GITHUB_ACTOR' => 'jane_doe' } }
97
+
98
+ it { should eql 'jane_doe' }
99
+ end
100
+
101
+ context "when the GITHUB_ACTOR environment variable doesn't exist" do
102
+ it { should be nil }
103
+ end
104
+ end
91
105
  end
@@ -73,13 +73,13 @@ describe KnapsackPro::Config::CI::GitlabCI do
73
73
  subject { described_class.new.branch }
74
74
 
75
75
  context 'when Gitlab Release 9.0+ and environment exists' do
76
- let(:env) { { 'CI_COMMIT_REF_NAME' => 'master' } }
77
- it { should eql 'master' }
76
+ let(:env) { { 'CI_COMMIT_REF_NAME' => 'main' } }
77
+ it { should eql 'main' }
78
78
  end
79
79
 
80
80
  context 'when Gitlab Release 8.x and environment exists' do
81
- let(:env) { { 'CI_BUILD_REF_NAME' => 'master' } }
82
- it { should eql 'master' }
81
+ let(:env) { { 'CI_BUILD_REF_NAME' => 'main' } }
82
+ it { should eql 'main' }
83
83
  end
84
84
 
85
85
  context "when environment doesn't exist" do
@@ -99,4 +99,39 @@ describe KnapsackPro::Config::CI::GitlabCI do
99
99
  it { should be nil }
100
100
  end
101
101
  end
102
+
103
+ describe '#user_seat' do
104
+ subject { described_class.new.user_seat }
105
+
106
+ context 'when the GITLAB_USER_NAME env var exists' do
107
+ let(:env) do
108
+ { 'GITLAB_USER_NAME' => 'Jane Doe',
109
+ 'GITLAB_USER_EMAIL' => nil }
110
+ end
111
+
112
+ it { should eql 'Jane Doe' }
113
+ end
114
+
115
+ context 'when the GITLAB_USER_EMAIL env var exists' do
116
+ let(:env) do
117
+ { 'GITLAB_USER_NAME' => nil,
118
+ 'GITLAB_USER_EMAIL' => 'janed@example.com' }
119
+ end
120
+
121
+ it { should eql 'janed@example.com' }
122
+ end
123
+
124
+ context 'when both GITLAB_USER_NAME and GITLAB_USER_EMAIL env vars exist' do
125
+ let(:env) do
126
+ { 'GITLAB_USER_NAME' => 'Jane Doe',
127
+ 'GITLAB_USER_EMAIL' => 'janed@example.com' }
128
+ end
129
+
130
+ it { should eql 'Jane Doe' }
131
+ end
132
+
133
+ context "when neither env var exists" do
134
+ it { should be nil }
135
+ end
136
+ end
102
137
  end
@@ -182,6 +182,51 @@ describe KnapsackPro::Config::Env do
182
182
  end
183
183
  end
184
184
 
185
+ describe '.user_seat' do
186
+ subject { described_class.user_seat }
187
+
188
+ context 'when ENV exists' do
189
+ context 'when KNAPSACK_PRO_USER_SEAT has value' do
190
+ before { stub_const("ENV", { 'KNAPSACK_PRO_USER_SEAT' => 'John Doe' }) }
191
+ it { should eq 'John Doe' }
192
+ end
193
+
194
+ context 'when CI environment has value' do
195
+ before do
196
+ expect(described_class).to receive(:ci_env_for).with(:user_seat).and_return('Jane Doe')
197
+ end
198
+
199
+ it { should eq 'Jane Doe' }
200
+ end
201
+ end
202
+
203
+ context "when ENV doesn't exist" do
204
+ it { should be nil }
205
+ end
206
+ end
207
+
208
+ describe '.user_seat_hash' do
209
+ subject { described_class.user_seat_hash }
210
+
211
+ before do
212
+ expect(described_class).to receive(:user_seat).at_least(1).and_return(user_seat)
213
+ end
214
+
215
+ context 'when the user seat has a value' do
216
+ let(:user_seat) { 'John Doe' }
217
+
218
+ it 'returns a SHA256 hash for the user seat' do
219
+ expect(subject).to eq '6cea57c2fb6cbc2a40411135005760f241fffc3e5e67ab99882726431037f908'
220
+ end
221
+ end
222
+
223
+ context 'when the user seat has no value' do
224
+ let(:user_seat) { nil }
225
+
226
+ it { expect(subject).to be_nil }
227
+ end
228
+ end
229
+
185
230
  describe '.test_file_pattern' do
186
231
  subject { described_class.test_file_pattern }
187
232
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -230,8 +230,6 @@ files:
230
230
  - lib/knapsack_pro/config/ci/heroku.rb
231
231
  - lib/knapsack_pro/config/ci/semaphore.rb
232
232
  - lib/knapsack_pro/config/ci/semaphore2.rb
233
- - lib/knapsack_pro/config/ci/snap_ci.rb
234
- - lib/knapsack_pro/config/ci/solano_ci.rb
235
233
  - lib/knapsack_pro/config/ci/travis.rb
236
234
  - lib/knapsack_pro/config/env.rb
237
235
  - lib/knapsack_pro/config/env_generator.rb
@@ -327,8 +325,6 @@ files:
327
325
  - spec/knapsack_pro/config/ci/heroku_spec.rb
328
326
  - spec/knapsack_pro/config/ci/semaphore2_spec.rb
329
327
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
330
- - spec/knapsack_pro/config/ci/snap_ci_spec.rb
331
- - spec/knapsack_pro/config/ci/solano_ci_spec.rb
332
328
  - spec/knapsack_pro/config/ci/travis_spec.rb
333
329
  - spec/knapsack_pro/config/env_generator_spec.rb
334
330
  - spec/knapsack_pro/config/env_spec.rb
@@ -408,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
408
404
  - !ruby/object:Gem::Version
409
405
  version: '0'
410
406
  requirements: []
411
- rubygems_version: 3.4.6
407
+ rubygems_version: 3.4.10
412
408
  signing_key:
413
409
  specification_version: 4
414
410
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
@@ -449,8 +445,6 @@ test_files:
449
445
  - spec/knapsack_pro/config/ci/heroku_spec.rb
450
446
  - spec/knapsack_pro/config/ci/semaphore2_spec.rb
451
447
  - spec/knapsack_pro/config/ci/semaphore_spec.rb
452
- - spec/knapsack_pro/config/ci/snap_ci_spec.rb
453
- - spec/knapsack_pro/config/ci/solano_ci_spec.rb
454
448
  - spec/knapsack_pro/config/ci/travis_spec.rb
455
449
  - spec/knapsack_pro/config/env_generator_spec.rb
456
450
  - spec/knapsack_pro/config/env_spec.rb
@@ -1,35 +0,0 @@
1
- module KnapsackPro
2
- module Config
3
- module CI
4
- class SnapCI < Base
5
- def node_total
6
- ENV['SNAP_WORKER_TOTAL']
7
- end
8
-
9
- def node_index
10
- index = ENV['SNAP_WORKER_INDEX']
11
- index.to_i - 1 if index
12
- end
13
-
14
- def node_build_id
15
- ENV['SNAP_PIPELINE_COUNTER']
16
- end
17
-
18
- def commit_hash
19
- ENV['SNAP_COMMIT']
20
- end
21
-
22
- # https://docs.snap-ci.com/environment-variables/
23
- # SNAP_BRANCH - the name of the git branch (not present on pull requests)
24
- # SNAP_UPSTREAM_BRANCH - the upstream branch for which the pull request was opened
25
- def branch
26
- ENV['SNAP_BRANCH'] || ENV['SNAP_UPSTREAM_BRANCH']
27
- end
28
-
29
- def project_dir
30
- ENV['SNAP_WORKING_DIR']
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,32 +0,0 @@
1
- # http://docs.solanolabs.com/Setup/tddium-set-environment-variables/
2
- module KnapsackPro
3
- module Config
4
- module CI
5
- class SolanoCI < Base
6
- def node_total
7
- # not provided
8
- end
9
-
10
- def node_index
11
- # not provided
12
- end
13
-
14
- def node_build_id
15
- ENV['TDDIUM_SESSION_ID']
16
- end
17
-
18
- def commit_hash
19
- ENV['TDDIUM_CURRENT_COMMIT']
20
- end
21
-
22
- def branch
23
- ENV['TDDIUM_CURRENT_BRANCH']
24
- end
25
-
26
- def project_dir
27
- ENV['TDDIUM_REPO_ROOT']
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,104 +0,0 @@
1
- describe KnapsackPro::Config::CI::SnapCI do
2
- let(:env) { {} }
3
-
4
- before do
5
- stub_const('ENV', env)
6
- end
7
-
8
- it { should be_kind_of KnapsackPro::Config::CI::Base }
9
-
10
- describe '#node_total' do
11
- subject { described_class.new.node_total }
12
-
13
- context 'when environment exists' do
14
- let(:env) { { 'SNAP_WORKER_TOTAL' => 4 } }
15
- it { should eql 4 }
16
- end
17
-
18
- context "when environment doesn't exist" do
19
- it { should be nil }
20
- end
21
- end
22
-
23
- describe '#node_index' do
24
- subject { described_class.new.node_index }
25
-
26
- context 'when environment exists' do
27
- let(:env) { { 'SNAP_WORKER_INDEX' => 4 } }
28
- it { should eql 3 }
29
- end
30
-
31
- context "when environment doesn't exist" do
32
- it { should be nil }
33
- end
34
- end
35
-
36
- describe '#node_build_id' do
37
- subject { described_class.new.node_build_id }
38
-
39
- context 'when environment exists' do
40
- let(:env) { { 'SNAP_PIPELINE_COUNTER' => 123 } }
41
- it { should eql 123 }
42
- end
43
-
44
- context "when environment doesn't exist" do
45
- it { should be nil }
46
- end
47
- end
48
-
49
- describe '#commit_hash' do
50
- subject { described_class.new.commit_hash }
51
-
52
- context 'when environment exists' do
53
- let(:env) { { 'SNAP_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
54
- it { should eql '3fa64859337f6e56409d49f865d13fd7' }
55
- end
56
-
57
- context "when environment doesn't exist" do
58
- it { should be nil }
59
- end
60
- end
61
-
62
- describe '#branch' do
63
- subject { described_class.new.branch }
64
-
65
- context 'when environment exists' do
66
- context 'when branch present' do
67
- let(:env) { { 'SNAP_BRANCH' => 'master' } }
68
- it { should eql 'master' }
69
- end
70
-
71
- context 'when pull request' do
72
- let(:env) { { 'SNAP_UPSTREAM_BRANCH' => 'feature-branch' } }
73
- it { should eql 'feature-branch' }
74
- end
75
-
76
- context 'branch has higher priority' do
77
- let(:env) do
78
- {
79
- 'SNAP_BRANCH' => 'master',
80
- 'SNAP_UPSTREAM_BRANCH' => 'feature-branch'
81
- }
82
- end
83
- it { should eql 'master' }
84
- end
85
- end
86
-
87
- context "when environment doesn't exist" do
88
- it { should be nil }
89
- end
90
- end
91
-
92
- describe '#project_dir' do
93
- subject { described_class.new.project_dir }
94
-
95
- context 'when environment exists' do
96
- let(:env) { { 'SNAP_WORKING_DIR' => '/var/snap-ci/repo' } }
97
- it { should eql '/var/snap-ci/repo' }
98
- end
99
-
100
- context "when environment doesn't exist" do
101
- it { should be nil }
102
- end
103
- end
104
- end
@@ -1,73 +0,0 @@
1
- describe KnapsackPro::Config::CI::SolanoCI do
2
- let(:env) { {} }
3
-
4
- before do
5
- stub_const('ENV', env)
6
- end
7
-
8
- it { should be_kind_of KnapsackPro::Config::CI::Base }
9
-
10
- describe '#node_total' do
11
- subject { described_class.new.node_total }
12
-
13
- it { should be nil }
14
- end
15
-
16
- describe '#node_index' do
17
- subject { described_class.new.node_index }
18
-
19
- it { should be nil }
20
- end
21
-
22
- describe '#node_build_id' do
23
- subject { described_class.new.node_build_id }
24
-
25
- context 'when environment exists' do
26
- let(:env) { { 'TDDIUM_SESSION_ID' => 123 } }
27
- it { should eql 123 }
28
- end
29
-
30
- context "when environment doesn't exist" do
31
- it { should be nil }
32
- end
33
- end
34
-
35
- describe '#commit_hash' do
36
- subject { described_class.new.commit_hash }
37
-
38
- context 'when environment exists' do
39
- let(:env) { { 'TDDIUM_CURRENT_COMMIT' => '2e13512fc230d6f9ebf4923352718e4d' } }
40
- it { should eql '2e13512fc230d6f9ebf4923352718e4d' }
41
- end
42
-
43
- context "when environment doesn't exist" do
44
- it { should be nil }
45
- end
46
- end
47
-
48
- describe '#branch' do
49
- subject { described_class.new.branch }
50
-
51
- context 'when environment exists' do
52
- let(:env) { { 'TDDIUM_CURRENT_BRANCH' => 'master' } }
53
- it { should eql 'master' }
54
- end
55
-
56
- context "when environment doesn't exist" do
57
- it { should be nil }
58
- end
59
- end
60
-
61
- describe '#project_dir' do
62
- subject { described_class.new.project_dir }
63
-
64
- context 'when environment exists' do
65
- let(:env) { { 'TDDIUM_REPO_ROOT' => '/example/repo/root' } }
66
- it { should eql '/example/repo/root' }
67
- end
68
-
69
- context "when environment doesn't exist" do
70
- it { should be nil }
71
- end
72
- end
73
- end