knapsack_pro 9.0.0 → 9.1.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/lib/knapsack_pro/adapters/minitest_adapter.rb +8 -13
- data/lib/knapsack_pro/client/connection.rb +1 -1
- data/lib/knapsack_pro/config/env.rb +1 -24
- data/lib/knapsack_pro/version.rb +1 -1
- metadata +2 -196
- data/.circleci/config.yml +0 -468
- data/.github/assets/install-button.png +0 -0
- data/.github/assets/knapsack-diamonds.png +0 -0
- data/.github/dependabot.yml +0 -11
- data/.github/pull_request_template.md +0 -11
- data/.gitignore +0 -39
- data/.rspec +0 -5
- data/CHANGELOG.md +0 -1995
- data/Gemfile +0 -13
- data/LICENSE +0 -22
- data/README.md +0 -90
- data/Rakefile +0 -2
- data/knapsack_pro.gemspec +0 -43
- data/spec/fixtures/test_file_list_source_file.txt +0 -6
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml +0 -59
- data/spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml +0 -61
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml +0 -50
- data/spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/success.yml +0 -50
- data/spec/integration/api/build_distributions_subset_spec.rb +0 -77
- data/spec/integration/api/build_subsets_create_spec.rb +0 -77
- data/spec/integration/runners/fallback_spec.rb +0 -131
- data/spec/integration/runners/queue/cucumber_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/minitest_runner_fallback_spec.rb +0 -129
- data/spec/integration/runners/queue/rspec_runner.rb +0 -80
- data/spec/integration/runners/queue/rspec_runner_fallback_spec.rb +0 -137
- data/spec/integration/runners/queue/rspec_runner_spec.rb +0 -2672
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +0 -221
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +0 -216
- data/spec/knapsack_pro/adapters/minitest_adapter_spec.rb +0 -189
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +0 -427
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +0 -61
- data/spec/knapsack_pro/adapters/test_unit_adapter_spec.rb +0 -86
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +0 -102
- data/spec/knapsack_pro/build_distribution_fetcher_spec.rb +0 -89
- data/spec/knapsack_pro/client/api/action_spec.rb +0 -17
- data/spec/knapsack_pro/client/api/v1/base_spec.rb +0 -2
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +0 -95
- data/spec/knapsack_pro/client/api/v1/build_subsets_spec.rb +0 -35
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +0 -83
- data/spec/knapsack_pro/client/connection_spec.rb +0 -581
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/base_spec.rb +0 -10
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +0 -135
- data/spec/knapsack_pro/config/ci/circle_spec.rb +0 -122
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +0 -81
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +0 -80
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +0 -140
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +0 -137
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +0 -133
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +0 -87
- data/spec/knapsack_pro/config/ci/travis_spec.rb +0 -73
- data/spec/knapsack_pro/config/env_generator_spec.rb +0 -52
- data/spec/knapsack_pro/config/env_spec.rb +0 -1291
- data/spec/knapsack_pro/config/temp_files_spec.rb +0 -25
- data/spec/knapsack_pro/crypto/branch_encryptor_spec.rb +0 -53
- data/spec/knapsack_pro/crypto/decryptor_spec.rb +0 -83
- data/spec/knapsack_pro/crypto/digestor_spec.rb +0 -13
- data/spec/knapsack_pro/crypto/encryptor_spec.rb +0 -58
- data/spec/knapsack_pro/formatters/time_tracker_fetcher_spec.rb +0 -27
- data/spec/knapsack_pro/formatters/time_tracker_spec.rb +0 -448
- data/spec/knapsack_pro/hooks/queue_spec.rb +0 -199
- data/spec/knapsack_pro/presenter_spec.rb +0 -57
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +0 -248
- data/spec/knapsack_pro/queue_spec.rb +0 -35
- data/spec/knapsack_pro/report_spec.rb +0 -232
- data/spec/knapsack_pro/repository_adapter_initiator_spec.rb +0 -21
- data/spec/knapsack_pro/repository_adapters/base_adapter_spec.rb +0 -13
- data/spec/knapsack_pro/repository_adapters/env_adapter_spec.rb +0 -27
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +0 -106
- data/spec/knapsack_pro/runners/base_runner_spec.rb +0 -87
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +0 -92
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +0 -57
- data/spec/knapsack_pro/runners/queue/base_runner_spec.rb +0 -73
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +0 -209
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +0 -203
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +0 -111
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +0 -56
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +0 -62
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +0 -119
- data/spec/knapsack_pro/slow_test_file_finder_spec.rb +0 -42
- data/spec/knapsack_pro/task_loader_spec.rb +0 -14
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +0 -217
- data/spec/knapsack_pro/test_case_mergers/base_merger_spec.rb +0 -27
- data/spec/knapsack_pro/test_case_mergers/rspec_merger_spec.rb +0 -81
- data/spec/knapsack_pro/test_file_cleaner_spec.rb +0 -11
- data/spec/knapsack_pro/test_file_finder_spec.rb +0 -176
- data/spec/knapsack_pro/test_file_pattern_spec.rb +0 -49
- data/spec/knapsack_pro/test_file_presenter_spec.rb +0 -22
- data/spec/knapsack_pro/test_files_with_test_cases_composer_spec.rb +0 -41
- data/spec/knapsack_pro/test_flat_distributor_spec.rb +0 -60
- data/spec/knapsack_pro/tracker_spec.rb +0 -184
- data/spec/knapsack_pro/utils_spec.rb +0 -55
- data/spec/knapsack_pro_spec.rb +0 -116
- data/spec/spec_helper.rb +0 -47
- data/spec/support/.gitkeep +0 -0
- data/spec/support/fakes/cucumber.rb +0 -25
- data/spec/support/fakes/minitest.rb +0 -18
- data/spec/support/shared_examples/adapter.rb +0 -17
- data/spec_fake/controllers/users_controller_spec.rb +0 -0
- data/spec_fake/models/admin_spec.rb +0 -0
- data/spec_fake/models/user_spec.rb +0 -0
- data/spec_fake/spec_helper.rb +0 -0
- data/spec_time_tracker/spec_helper.rb +0 -29
- data/test_fake/a_test.rb +0 -0
- data/test_fake/b_test.rb +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::GitlabCI 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 the environment exists' do
|
|
14
|
-
let(:env) { { 'CI_NODE_TOTAL' => 4 } }
|
|
15
|
-
it { should eql 4 }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when the 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 the environment exists and is in GitLab CI' do
|
|
27
|
-
let(:env) { { 'CI_NODE_INDEX' => 4, 'GITLAB_CI' => 'true' } }
|
|
28
|
-
it { should eql 3 }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when the 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 Gitlab Release 9.0+ and environment exists' do
|
|
40
|
-
let(:env) { { 'CI_PIPELINE_ID' => 7046507 } }
|
|
41
|
-
it { should eql 7046507 }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context 'when Gitlab Release 8.x and environment exists' do
|
|
45
|
-
let(:env) { { 'CI_BUILD_ID' => 7046508 } }
|
|
46
|
-
it { should eql 7046508 }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context "when the environment doesn't exist" do
|
|
50
|
-
it { should be nil }
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe '#commit_hash' do
|
|
55
|
-
subject { described_class.new.commit_hash }
|
|
56
|
-
|
|
57
|
-
context 'when Gitlab Release 9.0+ and environment exists' do
|
|
58
|
-
let(:env) { { 'CI_COMMIT_SHA' => '4e0c4feec2267261fbcc060e82d7776e' } }
|
|
59
|
-
it { should eql '4e0c4feec2267261fbcc060e82d7776e' }
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
context 'when Gitlab Release 8.x and environment exists' do
|
|
63
|
-
let(:env) { { 'CI_BUILD_REF' => 'f76c468e3e1d570f71f5822b1e48bb04' } }
|
|
64
|
-
it { should eql 'f76c468e3e1d570f71f5822b1e48bb04' }
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
context "when the environment doesn't exist" do
|
|
68
|
-
it { should be nil }
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
describe '#branch' do
|
|
73
|
-
subject { described_class.new.branch }
|
|
74
|
-
|
|
75
|
-
context 'when Gitlab Release 9.0+ and environment exists' do
|
|
76
|
-
let(:env) { { 'CI_COMMIT_REF_NAME' => 'main' } }
|
|
77
|
-
it { should eql 'main' }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context 'when Gitlab Release 8.x and environment exists' do
|
|
81
|
-
let(:env) { { 'CI_BUILD_REF_NAME' => 'main' } }
|
|
82
|
-
it { should eql 'main' }
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
context "when the environment doesn't exist" do
|
|
86
|
-
it { should be nil }
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
describe '#project_dir' do
|
|
91
|
-
subject { described_class.new.project_dir }
|
|
92
|
-
|
|
93
|
-
context 'when the environment exists' do
|
|
94
|
-
let(:env) { { 'CI_PROJECT_DIR' => '/home/user/knapsack_pro-ruby' } }
|
|
95
|
-
it { should eql '/home/user/knapsack_pro-ruby' }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context "when the environment doesn't exist" do
|
|
99
|
-
it { should be nil }
|
|
100
|
-
end
|
|
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
|
|
137
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::Heroku 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 the environment exists' do
|
|
14
|
-
let(:env) { { 'CI_NODE_TOTAL' => 4 } }
|
|
15
|
-
it { should eql 4 }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when the 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 the environment exists' do
|
|
27
|
-
let(:env) { { 'CI_NODE_INDEX' => 3 } }
|
|
28
|
-
it { should eql 3 }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when the 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 the environment exists' do
|
|
40
|
-
let(:env) { { 'HEROKU_TEST_RUN_ID' => 1234 } }
|
|
41
|
-
it { should eql 1234 }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "when the 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 the environment exists' do
|
|
53
|
-
let(:env) { { 'HEROKU_TEST_RUN_COMMIT_VERSION' => 'abbaec3ee5d334fd658da35646b42bc5' } }
|
|
54
|
-
it { should eql 'abbaec3ee5d334fd658da35646b42bc5' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when the 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 the environment exists' do
|
|
66
|
-
let(:env) { { 'HEROKU_TEST_RUN_BRANCH' => 'main' } }
|
|
67
|
-
it { should eql 'main' }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "when the environment doesn't exist" do
|
|
71
|
-
it { should be nil }
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe '#project_dir' do
|
|
76
|
-
subject { described_class.new.project_dir }
|
|
77
|
-
|
|
78
|
-
context 'when the environment exists' do
|
|
79
|
-
let(:env) { { 'HEROKU_TEST_RUN_ID' => 1234 } }
|
|
80
|
-
it { should eq '/app' }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context "when the environment doesn't exist" do
|
|
84
|
-
it { should be nil }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::Semaphore2 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 the environment exists' do
|
|
14
|
-
let(:env) { { 'SEMAPHORE_JOB_COUNT' => 4 } }
|
|
15
|
-
it { should eql 4 }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when the 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 the environment exists' do
|
|
27
|
-
let(:env) { { 'SEMAPHORE_JOB_INDEX' => 4 } }
|
|
28
|
-
it { should eql 3 }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when the 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 the environment exists' do
|
|
40
|
-
let(:env) { { 'SEMAPHORE_WORKFLOW_ID' => 123 } }
|
|
41
|
-
it { should eql 123 }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "when the 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 the environment exists' do
|
|
53
|
-
let(:env) { { 'SEMAPHORE_GIT_SHA' => '4323320992a21b1169e3ac5b7789d379597738e6' } }
|
|
54
|
-
it { should eql '4323320992a21b1169e3ac5b7789d379597738e6' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when the 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 SEMAPHORE_GIT_WORKING_BRANCH is set' do
|
|
66
|
-
let(:env) { { 'SEMAPHORE_GIT_WORKING_BRANCH' => 'feature' } }
|
|
67
|
-
it { should eql 'feature' }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context 'when both SEMAPHORE_GIT_WORKING_BRANCH and SEMAPHORE_GIT_BRANCH are set' do
|
|
71
|
-
let(:env) { { 'SEMAPHORE_GIT_WORKING_BRANCH' => 'feature', 'SEMAPHORE_GIT_BRANCH' => 'main' } }
|
|
72
|
-
it { should eql 'feature' }
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'when SEMAPHORE_GIT_BRANCH is set' do
|
|
76
|
-
let(:env) { { 'SEMAPHORE_GIT_BRANCH' => 'main' } }
|
|
77
|
-
it { should eql 'main' }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "when no ENVs are set" do
|
|
81
|
-
it { should be nil }
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe '#project_dir' do
|
|
86
|
-
subject { described_class.new.project_dir }
|
|
87
|
-
|
|
88
|
-
context 'when HOME and SEMAPHORE_GIT_DIR environments exist' do
|
|
89
|
-
let(:env) do
|
|
90
|
-
{
|
|
91
|
-
'HOME' => '/home/semaphore',
|
|
92
|
-
'SEMAPHORE_GIT_DIR' => 'project-name',
|
|
93
|
-
}
|
|
94
|
-
end
|
|
95
|
-
it { should eql '/home/semaphore/project-name' }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
context 'when only HOME environment exists' do
|
|
99
|
-
let(:env) do
|
|
100
|
-
{
|
|
101
|
-
'HOME' => '/home/semaphore',
|
|
102
|
-
}
|
|
103
|
-
end
|
|
104
|
-
it { should be nil }
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
context 'when only SEMAPHORE_GIT_DIR environment exists' do
|
|
108
|
-
let(:env) do
|
|
109
|
-
{
|
|
110
|
-
'SEMAPHORE_GIT_DIR' => 'project-name'
|
|
111
|
-
}
|
|
112
|
-
end
|
|
113
|
-
it { should be nil }
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
context "when the environments don't exist" do
|
|
117
|
-
it { should be nil }
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe '#user_seat' do
|
|
122
|
-
subject { described_class.new.user_seat }
|
|
123
|
-
|
|
124
|
-
context 'when SEMAPHORE_GIT_COMMITTER is set' do
|
|
125
|
-
let(:env) { { 'SEMAPHORE_GIT_COMMITTER' => 'jane_doe' } }
|
|
126
|
-
it { should eql 'jane_doe' }
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
context "when no ENVs are set" do
|
|
130
|
-
it { should be nil }
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::Semaphore 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 the environment exists' do
|
|
14
|
-
let(:env) { { 'SEMAPHORE_THREAD_COUNT' => 4 } }
|
|
15
|
-
it { should eql 4 }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "when the 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 the environment exists' do
|
|
27
|
-
let(:env) { { 'SEMAPHORE_CURRENT_THREAD' => 4 } }
|
|
28
|
-
it { should eql 3 }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
context "when the 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 the environment exists' do
|
|
40
|
-
let(:env) { { 'SEMAPHORE_BUILD_NUMBER' => 23 } }
|
|
41
|
-
it { should eql 23 }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
context "when the 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 the environment exists' do
|
|
53
|
-
let(:env) { { 'REVISION' => '3fa64859337f6e56409d49f865d13fd7' } }
|
|
54
|
-
it { should eql '3fa64859337f6e56409d49f865d13fd7' }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context "when the 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 the environment exists' do
|
|
66
|
-
let(:env) { { 'BRANCH_NAME' => 'main' } }
|
|
67
|
-
it { should eql 'main' }
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "when the environment doesn't exist" do
|
|
71
|
-
it { should be nil }
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe '#project_dir' do
|
|
76
|
-
subject { described_class.new.project_dir }
|
|
77
|
-
|
|
78
|
-
context 'when the environment exists' do
|
|
79
|
-
let(:env) { { 'SEMAPHORE_PROJECT_DIR' => '/home/runner/knapsack_pro-ruby' } }
|
|
80
|
-
it { should eql '/home/runner/knapsack_pro-ruby' }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context "when the environment doesn't exist" do
|
|
84
|
-
it { should be nil }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::CI::Travis 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 the environment exists' do
|
|
26
|
-
let(:env) { { 'TRAVIS_BUILD_NUMBER' => 4 } }
|
|
27
|
-
it { should eql 4 }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context "when the 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 the environment exists' do
|
|
39
|
-
let(:env) { { 'TRAVIS_COMMIT' => '3fa64859337f6e56409d49f865d13fd7' } }
|
|
40
|
-
it { should eql '3fa64859337f6e56409d49f865d13fd7' }
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "when the 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 the environment exists' do
|
|
52
|
-
let(:env) { { 'TRAVIS_BRANCH' => 'main' } }
|
|
53
|
-
it { should eql 'main' }
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "when the 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 the environment exists' do
|
|
65
|
-
let(:env) { { 'TRAVIS_BUILD_DIR' => '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' } }
|
|
66
|
-
it { should eql '/home/travis/build/KnapsackPro/rails-app-with-knapsack_pro' }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "when the environment doesn't exist" do
|
|
70
|
-
it { should be nil }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
describe KnapsackPro::Config::EnvGenerator do
|
|
2
|
-
describe '.set_queue_id' do
|
|
3
|
-
subject { described_class.set_queue_id }
|
|
4
|
-
|
|
5
|
-
context 'when queue id exists' do
|
|
6
|
-
before do
|
|
7
|
-
stub_const("ENV", { 'KNAPSACK_PRO_QUEUE_ID' => 'fake-queue-id' })
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
it do
|
|
11
|
-
expect { subject }.to raise_error('Queue ID already generated.')
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
context "when queue id doesn't exist" do
|
|
16
|
-
before { stub_const("ENV", {}) }
|
|
17
|
-
|
|
18
|
-
it do
|
|
19
|
-
subject
|
|
20
|
-
expect(ENV['KNAPSACK_PRO_QUEUE_ID']).not_to be_nil
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it do
|
|
24
|
-
now = DateTime.new(2016, 1, 9, 0, 0, 0)
|
|
25
|
-
|
|
26
|
-
Timecop.freeze(now) do
|
|
27
|
-
uuid = 'fake-uuid'
|
|
28
|
-
expect(SecureRandom).to receive(:uuid).and_return(uuid)
|
|
29
|
-
|
|
30
|
-
subject
|
|
31
|
-
|
|
32
|
-
expect(ENV['KNAPSACK_PRO_QUEUE_ID']).to eq '1452297600_fake-uuid'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '.set_subset_queue_id' do
|
|
39
|
-
subject { described_class.set_subset_queue_id }
|
|
40
|
-
|
|
41
|
-
before { stub_const("ENV", {}) }
|
|
42
|
-
|
|
43
|
-
it do
|
|
44
|
-
uuid = 'fake-uuid'
|
|
45
|
-
expect(SecureRandom).to receive(:uuid).and_return(uuid)
|
|
46
|
-
|
|
47
|
-
subject
|
|
48
|
-
|
|
49
|
-
expect(ENV['KNAPSACK_PRO_SUBSET_QUEUE_ID']).to eq uuid
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|