knapsack_pro 3.8.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +377 -23
- data/.github/dependabot.yml +11 -0
- data/.github/pull_request_template.md +22 -0
- data/.gitignore +4 -0
- data/CHANGELOG.md +325 -1
- data/Gemfile +9 -0
- data/README.md +3 -10
- data/bin/test +15 -0
- data/knapsack_pro.gemspec +7 -6
- data/lib/knapsack_pro/adapters/base_adapter.rb +17 -2
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +3 -3
- data/lib/knapsack_pro/adapters/minitest_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +88 -49
- data/lib/knapsack_pro/adapters/spinach_adapter.rb +2 -0
- data/lib/knapsack_pro/adapters/test_unit_adapter.rb +2 -0
- data/lib/knapsack_pro/allocator.rb +2 -0
- data/lib/knapsack_pro/allocator_builder.rb +2 -0
- data/lib/knapsack_pro/base_allocator_builder.rb +8 -25
- data/lib/knapsack_pro/build_distribution_fetcher.rb +2 -0
- data/lib/knapsack_pro/client/api/action.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/base.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/build_distributions.rb +5 -0
- data/lib/knapsack_pro/client/api/v1/build_subsets.rb +2 -0
- data/lib/knapsack_pro/client/api/v1/queues.rb +6 -1
- data/lib/knapsack_pro/client/connection.rb +5 -6
- data/lib/knapsack_pro/config/ci/app_veyor.rb +18 -0
- data/lib/knapsack_pro/config/ci/base.rb +27 -0
- data/lib/knapsack_pro/config/ci/buildkite.rb +18 -0
- data/lib/knapsack_pro/config/ci/circle.rb +18 -0
- data/lib/knapsack_pro/config/ci/cirrus_ci.rb +18 -0
- data/lib/knapsack_pro/config/ci/codefresh.rb +18 -0
- data/lib/knapsack_pro/config/ci/codeship.rb +18 -0
- data/lib/knapsack_pro/config/ci/github_actions.rb +26 -0
- data/lib/knapsack_pro/config/ci/gitlab_ci.rb +20 -1
- data/lib/knapsack_pro/config/ci/heroku.rb +18 -0
- data/lib/knapsack_pro/config/ci/semaphore.rb +16 -0
- data/lib/knapsack_pro/config/ci/semaphore2.rb +19 -0
- data/lib/knapsack_pro/config/ci/travis.rb +18 -0
- data/lib/knapsack_pro/config/env.rb +46 -22
- data/lib/knapsack_pro/config/env_generator.rb +2 -0
- data/lib/knapsack_pro/config/temp_files.rb +8 -4
- data/lib/knapsack_pro/crypto/branch_encryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/decryptor.rb +2 -0
- data/lib/knapsack_pro/crypto/digestor.rb +2 -0
- data/lib/knapsack_pro/crypto/encryptor.rb +2 -0
- data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
- data/lib/knapsack_pro/formatters/rspec_json_formatter.rb +2 -0
- data/lib/knapsack_pro/formatters/time_tracker.rb +152 -0
- data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +20 -0
- data/lib/knapsack_pro/hooks/queue.rb +2 -0
- data/lib/knapsack_pro/logger_wrapper.rb +2 -0
- data/lib/knapsack_pro/mask_string.rb +9 -0
- data/lib/knapsack_pro/presenter.rb +6 -3
- data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
- data/lib/knapsack_pro/queue_allocator.rb +2 -0
- data/lib/knapsack_pro/queue_allocator_builder.rb +2 -0
- data/lib/knapsack_pro/railtie.rb +2 -0
- data/lib/knapsack_pro/report.rb +15 -9
- data/lib/knapsack_pro/repository_adapter_initiator.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/base_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/env_adapter.rb +2 -0
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +50 -0
- data/lib/knapsack_pro/runners/base_runner.rb +2 -0
- data/lib/knapsack_pro/runners/cucumber_runner.rb +2 -0
- data/lib/knapsack_pro/runners/minitest_runner.rb +2 -0
- data/lib/knapsack_pro/runners/queue/base_runner.rb +29 -0
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +9 -6
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +13 -6
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +128 -135
- data/lib/knapsack_pro/runners/rspec_runner.rb +22 -3
- data/lib/knapsack_pro/runners/spinach_runner.rb +2 -0
- data/lib/knapsack_pro/runners/test_unit_runner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +2 -0
- data/lib/knapsack_pro/slow_test_file_finder.rb +2 -0
- data/lib/knapsack_pro/task_loader.rb +2 -0
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/base_merger.rb +2 -0
- data/lib/knapsack_pro/test_case_mergers/rspec_merger.rb +2 -0
- data/lib/knapsack_pro/test_file_cleaner.rb +2 -0
- data/lib/knapsack_pro/test_file_finder.rb +2 -0
- data/lib/knapsack_pro/test_file_pattern.rb +2 -0
- data/lib/knapsack_pro/test_file_presenter.rb +2 -0
- data/lib/knapsack_pro/test_files_with_test_cases_composer.rb +2 -0
- data/lib/knapsack_pro/test_flat_distributor.rb +2 -0
- data/lib/knapsack_pro/tracker.rb +3 -3
- data/lib/knapsack_pro/urls.rb +4 -0
- data/lib/knapsack_pro/utils.rb +2 -0
- data/lib/knapsack_pro/version.rb +3 -1
- data/lib/knapsack_pro.rb +5 -3
- data/lib/tasks/cucumber.rake +2 -0
- data/lib/tasks/encrypted_branch_names.rake +2 -0
- data/lib/tasks/encrypted_test_file_names.rake +2 -0
- data/lib/tasks/minitest.rake +2 -0
- data/lib/tasks/queue/cucumber.rake +13 -0
- data/lib/tasks/queue/minitest.rake +13 -0
- data/lib/tasks/queue/rspec.rake +13 -0
- data/lib/tasks/rspec.rake +5 -0
- data/lib/tasks/salt.rake +2 -0
- data/lib/tasks/spinach.rake +2 -0
- data/lib/tasks/test_unit.rake +2 -0
- data/spec/integration/api/build_distributions_subset_spec.rb +1 -0
- data/spec/integration/runners/queue/rspec_runner.rb +80 -0
- data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +30 -11
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +146 -174
- data/spec/knapsack_pro/base_allocator_builder_spec.rb +22 -48
- data/spec/knapsack_pro/client/api/v1/build_distributions_spec.rb +19 -27
- data/spec/knapsack_pro/client/api/v1/queues_spec.rb +23 -43
- data/spec/knapsack_pro/client/connection_spec.rb +59 -7
- data/spec/knapsack_pro/config/ci/app_veyor_spec.rb +22 -8
- data/spec/knapsack_pro/config/ci/base_spec.rb +1 -0
- data/spec/knapsack_pro/config/ci/buildkite_spec.rb +51 -16
- data/spec/knapsack_pro/config/ci/circle_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/cirrus_ci_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/codefresh_spec.rb +21 -6
- data/spec/knapsack_pro/config/ci/codeship_spec.rb +20 -6
- data/spec/knapsack_pro/config/ci/github_actions_spec.rb +37 -10
- data/spec/knapsack_pro/config/ci/gitlab_ci_spec.rb +48 -13
- data/spec/knapsack_pro/config/ci/heroku_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/semaphore2_spec.rb +11 -11
- data/spec/knapsack_pro/config/ci/semaphore_spec.rb +12 -12
- data/spec/knapsack_pro/config/ci/travis_spec.rb +8 -8
- data/spec/knapsack_pro/config/env_spec.rb +204 -124
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +424 -0
- data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
- data/spec/knapsack_pro/presenter_spec.rb +1 -1
- data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
- data/spec/knapsack_pro/repository_adapters/git_adapter_spec.rb +72 -0
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +18 -16
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +17 -14
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +40 -23
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +1 -0
- data/spec/knapsack_pro/tracker_spec.rb +0 -4
- data/spec/knapsack_pro_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +26 -23
- data/lib/knapsack_pro/config/ci/snap_ci.rb +0 -35
- data/lib/knapsack_pro/config/ci/solano_ci.rb +0 -32
- data/lib/knapsack_pro/extensions/time.rb +0 -7
- data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -56
- data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -112
- data/spec/knapsack_pro/config/ci/snap_ci_spec.rb +0 -104
- data/spec/knapsack_pro/config/ci/solano_ci_spec.rb +0 -73
- data/spec/knapsack_pro/extensions/time_spec.rb +0 -5
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -342
@@ -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,56 +0,0 @@
|
|
1
|
-
RSpec::Support.require_rspec_core('formatters/profile_formatter')
|
2
|
-
|
3
|
-
module KnapsackPro
|
4
|
-
module Formatters
|
5
|
-
module RSpecQueueProfileFormatterExtension
|
6
|
-
def self.print_summary
|
7
|
-
return unless KnapsackPro::Config::Env.modify_default_rspec_formatters?
|
8
|
-
::RSpec::Core::Formatters::ProfileFormatter.print_profile_summary
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(output)
|
12
|
-
@output = output
|
13
|
-
self.class.registered_output = output
|
14
|
-
end
|
15
|
-
|
16
|
-
def dump_profile(profile)
|
17
|
-
self.class.most_recent_profile = profile
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
if KnapsackPro::Config::Env.modify_default_rspec_formatters?
|
24
|
-
class RSpec::Core::Formatters::ProfileFormatter
|
25
|
-
prepend KnapsackPro::Formatters::RSpecQueueProfileFormatterExtension
|
26
|
-
|
27
|
-
def self.registered_output=(output)
|
28
|
-
@registered_output = {
|
29
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => output
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.registered_output
|
34
|
-
@registered_output ||= {}
|
35
|
-
@registered_output[ENV['KNAPSACK_PRO_QUEUE_ID']]
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.most_recent_profile=(profile)
|
39
|
-
@most_recent_profile = {
|
40
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => profile
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.most_recent_profile
|
45
|
-
@most_recent_profile ||= {}
|
46
|
-
@most_recent_profile[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.print_profile_summary
|
50
|
-
return unless registered_output
|
51
|
-
profile_formatter = new(registered_output)
|
52
|
-
profile_formatter.send(:dump_profile_slowest_examples, most_recent_profile)
|
53
|
-
profile_formatter.send(:dump_profile_slowest_example_groups, most_recent_profile)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
RSpec::Support.require_rspec_core('formatters/base_formatter')
|
2
|
-
RSpec::Support.require_rspec_core('formatters/base_text_formatter')
|
3
|
-
|
4
|
-
module KnapsackPro
|
5
|
-
module Formatters
|
6
|
-
module RSpecHideFailuresAndPendingExtension
|
7
|
-
def dump_failures(notification); end
|
8
|
-
def dump_pending(notification); end
|
9
|
-
def dump_summary(summary); end
|
10
|
-
end
|
11
|
-
|
12
|
-
class RSpecQueueSummaryFormatter < ::RSpec::Core::Formatters::BaseFormatter
|
13
|
-
::RSpec::Core::Formatters.register self, :dump_summary, :dump_failures, :dump_pending
|
14
|
-
|
15
|
-
def self.registered_output=(output)
|
16
|
-
@registered_output = {
|
17
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => output
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.registered_output
|
22
|
-
@registered_output[ENV['KNAPSACK_PRO_QUEUE_ID']]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.most_recent_failures_summary=(fully_formatted_failed_examples)
|
26
|
-
@most_recent_failures_summary = {
|
27
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted_failed_examples
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.most_recent_failures_summary
|
32
|
-
@most_recent_failures_summary ||= {}
|
33
|
-
@most_recent_failures_summary[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.most_recent_pending=(fully_formatted_pending_examples)
|
37
|
-
@most_recent_pending = {
|
38
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted_pending_examples
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.most_recent_pending
|
43
|
-
@most_recent_pending ||= {}
|
44
|
-
@most_recent_pending[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.most_recent_summary=(fully_formatted)
|
48
|
-
@most_recent_summary = {
|
49
|
-
ENV['KNAPSACK_PRO_QUEUE_ID'] => fully_formatted
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.most_recent_summary
|
54
|
-
@most_recent_summary ||= {}
|
55
|
-
@most_recent_summary[ENV['KNAPSACK_PRO_QUEUE_ID']] || []
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.print_summary
|
59
|
-
registered_output.puts('Knapsack Pro Queue finished!')
|
60
|
-
registered_output.puts('')
|
61
|
-
|
62
|
-
unless most_recent_pending.empty?
|
63
|
-
registered_output.puts('All pending tests on this CI node:')
|
64
|
-
registered_output.puts(most_recent_pending)
|
65
|
-
end
|
66
|
-
|
67
|
-
unless most_recent_failures_summary.empty?
|
68
|
-
registered_output.puts('All failed tests on this CI node:')
|
69
|
-
registered_output.puts(most_recent_failures_summary)
|
70
|
-
end
|
71
|
-
|
72
|
-
registered_output.puts(most_recent_summary)
|
73
|
-
end
|
74
|
-
|
75
|
-
def initialize(output)
|
76
|
-
super
|
77
|
-
self.class.registered_output = output
|
78
|
-
end
|
79
|
-
|
80
|
-
def dump_failures(notification)
|
81
|
-
return if notification.failure_notifications.empty?
|
82
|
-
self.class.most_recent_failures_summary = notification.fully_formatted_failed_examples
|
83
|
-
end
|
84
|
-
|
85
|
-
def dump_pending(notification)
|
86
|
-
return if notification.pending_examples.empty?
|
87
|
-
self.class.most_recent_pending = notification.fully_formatted_pending_examples
|
88
|
-
end
|
89
|
-
|
90
|
-
def dump_summary(summary)
|
91
|
-
colorizer = ::RSpec::Core::Formatters::ConsoleCodes
|
92
|
-
duration = KnapsackPro.tracker.global_time_since_beginning
|
93
|
-
formatted_duration = ::RSpec::Core::Formatters::Helpers.format_duration(duration)
|
94
|
-
|
95
|
-
formatted = "\nFinished in #{formatted_duration}\n" \
|
96
|
-
"#{summary.colorized_totals_line(colorizer)}\n"
|
97
|
-
|
98
|
-
unless summary.failed_examples.empty?
|
99
|
-
formatted += (summary.colorized_rerun_commands(colorizer) + "\n")
|
100
|
-
end
|
101
|
-
|
102
|
-
self.class.most_recent_summary = formatted
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
if KnapsackPro::Config::Env.modify_default_rspec_formatters?
|
109
|
-
class RSpec::Core::Formatters::BaseTextFormatter
|
110
|
-
prepend KnapsackPro::Formatters::RSpecHideFailuresAndPendingExtension
|
111
|
-
end
|
112
|
-
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
|