knapsack_pro 2.18.0 → 3.1.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 +1 -1
- data/.gitignore +1 -0
- data/CHANGELOG.md +33 -0
- data/README.md +3 -3
- data/knapsack_pro.gemspec +1 -1
- data/lib/knapsack_pro.rb +1 -0
- data/lib/knapsack_pro/adapters/base_adapter.rb +4 -4
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +5 -10
- data/lib/knapsack_pro/base_allocator_builder.rb +1 -0
- data/lib/knapsack_pro/config/env.rb +8 -1
- data/lib/knapsack_pro/config/temp_files.rb +38 -0
- data/lib/knapsack_pro/report.rb +7 -8
- data/lib/knapsack_pro/runners/cucumber_runner.rb +3 -0
- data/lib/knapsack_pro/runners/minitest_runner.rb +3 -0
- data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +3 -1
- data/lib/knapsack_pro/runners/queue/minitest_runner.rb +3 -1
- data/lib/knapsack_pro/runners/queue/rspec_runner.rb +1 -0
- data/lib/knapsack_pro/runners/rspec_runner.rb +3 -0
- data/lib/knapsack_pro/runners/spinach_runner.rb +3 -0
- data/lib/knapsack_pro/runners/test_unit_runner.rb +3 -0
- data/lib/knapsack_pro/slow_test_file_determiner.rb +8 -4
- data/lib/knapsack_pro/test_case_detectors/rspec_test_example_detector.rb +9 -6
- data/lib/knapsack_pro/tracker.rb +56 -1
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/base_adapter_spec.rb +9 -7
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +20 -24
- data/spec/knapsack_pro/config/env_spec.rb +25 -0
- data/spec/knapsack_pro/config/temp_files_spec.rb +25 -0
- data/spec/knapsack_pro/report_spec.rb +11 -10
- data/spec/knapsack_pro/runners/cucumber_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/minitest_runner_spec.rb +6 -1
- data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +2 -0
- data/spec/knapsack_pro/runners/rspec_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +9 -1
- data/spec/knapsack_pro/runners/test_unit_runner_spec.rb +6 -1
- data/spec/knapsack_pro/slow_test_file_determiner_spec.rb +2 -2
- data/spec/knapsack_pro/test_case_detectors/rspec_test_example_detector_spec.rb +8 -6
- data/spec/knapsack_pro/tracker_spec.rb +67 -2
- data/spec/spec_helper.rb +5 -2
- metadata +6 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6b697b425c2b1d68ff8e6816703e3b49528483d85cf581b529a62161d3e9ad4
|
4
|
+
data.tar.gz: 39d542d0ecb1537ef711210d22bc79775d54d82e9dc033345dfa2b94495a3039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f1329d908f489309178bc989bac548a81fd8d3d53fa3a968d40eaa12d4fd67cef1788c177a4351e03ec65dd06c5785bc1ee15b9e8ade03648866519f5833f9c
|
7
|
+
data.tar.gz: 6162c988f814c28e764567bec7a5fdaa15056626f857eb8a59d0895ec0103837dfa0c2c8ea0f1cca68ff0eab430b69ab584b21b9f3ecc1df086028b783cb2871
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,38 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
### 3.1.0
|
4
|
+
|
5
|
+
* Use `.knapsack_pro` directory for temporary files instead of the `tmp` directory in the user's project directory
|
6
|
+
|
7
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/155
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.0.0...v3.1.0
|
10
|
+
|
11
|
+
### 3.0.0
|
12
|
+
|
13
|
+
* __(breaking change)__ Remove support for RSpec 2.x. This change was already done by accident in [the pull request](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/143) when we added the RSpec `context` hook, which is available only since RSpec 3.x.
|
14
|
+
* Use RSpec `example` block argument instead of the global `RSpec.current_example`. This allows to run tests with the `async-rspec` gem.
|
15
|
+
|
16
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/153
|
17
|
+
|
18
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.18.2...v3.0.0
|
19
|
+
|
20
|
+
### 2.18.2
|
21
|
+
|
22
|
+
* Track all test files assigned to a CI node in Regular Mode including pending test files in order to retry proper set of tests on the retried CI node
|
23
|
+
|
24
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/152
|
25
|
+
|
26
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.18.1...v2.18.2
|
27
|
+
|
28
|
+
### 2.18.1
|
29
|
+
|
30
|
+
* Ensure RSpec is loaded to check its version for RSpec split by test examples feature
|
31
|
+
|
32
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/151
|
33
|
+
|
34
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.18.0...v2.18.1
|
35
|
+
|
3
36
|
### 2.18.0
|
4
37
|
|
5
38
|
* Do not allow to use the RSpec tag option together with the RSpec split by test examples feature in knapsack_pro gem in Regular Mode
|
data/README.md
CHANGED
@@ -440,13 +440,13 @@ If your test suite is very long and the RSpec output is too long for your CI nod
|
|
440
440
|
### Additional info about queue mode
|
441
441
|
|
442
442
|
* You should use a separate API token for queue mode than for regular mode to avoid problems with test suite split (especially in case you would like to go back to regular mode).
|
443
|
-
There might be some cached test suite splits for git commits you have run in past for API token you used in queue mode because of the [flag `KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true` for regular mode which is default](#
|
443
|
+
There might be some cached test suite splits for git commits you have run in past for API token you used in queue mode because of the [flag `KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true` for regular mode which is default](#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed).
|
444
444
|
|
445
445
|
* If you are not using one of the [supported CI providers](#supported-ci-providers) then please note that the knapsack_pro gem doesn't have a CI build ID in order to generate a queue for each particular CI build. This may result in two different CI builds taking tests from the same queue when CI builds are running at the same time against the same git commit.
|
446
446
|
|
447
447
|
To avoid this you should specify a unique `KNAPSACK_PRO_CI_NODE_BUILD_ID` environment variable for each CI build. This mean that each CI node that is part of particular CI build should have the same value for `KNAPSACK_PRO_CI_NODE_BUILD_ID`.
|
448
448
|
|
449
|
-
* Note that in the Queue Mode by default you cannot retry the failed CI node with exactly the same subset of tests that were run on the CI node in the first place. It's possible in regular mode ([read more](#
|
449
|
+
* Note that in the Queue Mode by default you cannot retry the failed CI node with exactly the same subset of tests that were run on the CI node in the first place. It's possible in regular mode ([read more](#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed)). If you want to have similar behavior in Queue Mode you need to explicitly [enable it](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node).
|
450
450
|
|
451
451
|
By default the Queue Mode works this way:
|
452
452
|
|
@@ -626,7 +626,7 @@ This is only for maintainer of knapsack_pro gem. Not for the end users.
|
|
626
626
|
|
627
627
|
### Required CI configuration if you use retry single failed CI node feature on your CI server when KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true (in Queue Mode) or KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true (in Regular Mode)
|
628
628
|
|
629
|
-
Read below required configuration step if you use Queue Mode and you set [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node) or you use Regular Mode which has by default [`KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true`](#
|
629
|
+
Read below required configuration step if you use Queue Mode and you set [`KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`](#knapsack_pro_fixed_queue_split-remember-queue-split-on-retry-ci-node) or you use Regular Mode which has by default [`KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true`](#knapsack_pro_fixed_test_suite_split-test-suite-split-based-on-seed).
|
630
630
|
|
631
631
|
* __IMPORTANT:__ If you use __the feature to retry only a single failed CI node__ on your CI server (for instance you use Buildkite and you use [auto-retry](https://buildkite.com/docs/pipelines/command-step#retry-attributes) for the failed job) then you need to be aware of [a race condition that could happen](https://github.com/KnapsackPro/knapsack_pro-ruby/pull/100). knapsack_pro should not allow running tests in Fallback Mode in the case when the failed CI node was retried to prevent running the wrong set of tests.
|
632
632
|
|
data/knapsack_pro.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'rake', '>= 0'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '>= 1.6'
|
31
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
32
|
spec.add_development_dependency 'rspec-its', '~> 1.3'
|
33
33
|
spec.add_development_dependency 'cucumber', '>= 0'
|
34
34
|
spec.add_development_dependency 'spinach', '>= 0.8'
|
data/lib/knapsack_pro.rb
CHANGED
@@ -27,6 +27,7 @@ require_relative 'knapsack_pro/config/ci/github_actions'
|
|
27
27
|
require_relative 'knapsack_pro/config/ci/heroku'
|
28
28
|
require_relative 'knapsack_pro/config/env'
|
29
29
|
require_relative 'knapsack_pro/config/env_generator'
|
30
|
+
require_relative 'knapsack_pro/config/temp_files'
|
30
31
|
require_relative 'knapsack_pro/logger_wrapper'
|
31
32
|
require_relative 'knapsack_pro/client/api/action'
|
32
33
|
require_relative 'knapsack_pro/client/api/v1/base'
|
@@ -6,7 +6,7 @@ module KnapsackPro
|
|
6
6
|
|
7
7
|
def self.adapter_bind_method_called_file
|
8
8
|
adapter_name = self.to_s.gsub('::', '-')
|
9
|
-
"#{KnapsackPro::Config::
|
9
|
+
"#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/#{adapter_name}-bind_method_called_for_node_#{KnapsackPro::Config::Env.ci_node_index}.txt"
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.slow_test_file?(adapter_class, test_file_path)
|
@@ -33,20 +33,20 @@ module KnapsackPro
|
|
33
33
|
|
34
34
|
def self.verify_bind_method_called
|
35
35
|
::Kernel.at_exit do
|
36
|
-
if File.
|
36
|
+
if File.exist?(adapter_bind_method_called_file)
|
37
37
|
File.delete(adapter_bind_method_called_file)
|
38
38
|
else
|
39
39
|
puts "\n\n"
|
40
40
|
KnapsackPro.logger.error('-'*10 + ' Configuration error ' + '-'*50)
|
41
41
|
KnapsackPro.logger.error("You forgot to call #{self}.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://docs.knapsackpro.com/knapsack_pro-ruby/guide/")
|
42
|
-
KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must
|
42
|
+
KnapsackPro.logger.error("If you already have #{self}.bind method added and you still see this error then one of your tests must have deleted the .knapsack_pro directory from the disk accidentally. Please ensure you do not remove the .knapsack_pro directory: https://knapsackpro.com/faq/question/why-all-test-files-have-01s-time-execution-for-my-ci-build-in-user-dashboard")
|
43
43
|
Kernel.exit(1)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def bind
|
49
|
-
|
49
|
+
KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
|
50
50
|
File.write(self.class.adapter_bind_method_called_file, nil)
|
51
51
|
|
52
52
|
if KnapsackPro::Config::Env.recording_enabled?
|
@@ -24,8 +24,10 @@ module KnapsackPro
|
|
24
24
|
cli_args.any? { |arg| arg.start_with?('-f') || arg.start_with?('--format') }
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.test_path(
|
28
|
-
|
27
|
+
def self.test_path(example)
|
28
|
+
example_group = example.metadata[:example_group]
|
29
|
+
|
30
|
+
if defined?(::Turnip) && Gem::Version.new(::Turnip::VERSION) < Gem::Version.new('2.0.0')
|
29
31
|
unless example_group[:turnip]
|
30
32
|
until example_group[:parent_example_group].nil?
|
31
33
|
example_group = example_group[:parent_example_group]
|
@@ -51,14 +53,7 @@ module KnapsackPro
|
|
51
53
|
# this way we count time spend in runtime for the previous test example after around(:each) is already done
|
52
54
|
KnapsackPro.tracker.stop_timer
|
53
55
|
|
54
|
-
|
55
|
-
if ::RSpec.respond_to?(:current_example)
|
56
|
-
::RSpec.current_example.metadata[:example_group]
|
57
|
-
else
|
58
|
-
example.metadata
|
59
|
-
end
|
60
|
-
|
61
|
-
current_test_path = KnapsackPro::Adapters::RSpecAdapter.test_path(current_example_group)
|
56
|
+
current_test_path = KnapsackPro::Adapters::RSpecAdapter.test_path(example)
|
62
57
|
|
63
58
|
KnapsackPro.tracker.current_test_path =
|
64
59
|
if KnapsackPro::Config::Env.rspec_split_by_test_examples? && KnapsackPro::Adapters::RSpecAdapter.slow_test_file?(RSpecAdapter, current_test_path)
|
@@ -34,6 +34,7 @@ module KnapsackPro
|
|
34
34
|
test_files_to_run = all_test_files_to_run
|
35
35
|
|
36
36
|
if adapter_class == KnapsackPro::Adapters::RSpecAdapter && KnapsackPro::Config::Env.rspec_split_by_test_examples?
|
37
|
+
require 'rspec/core/version'
|
37
38
|
unless Gem::Version.new(::RSpec::Core::Version::STRING) >= Gem::Version.new('3.3.0')
|
38
39
|
raise 'RSpec >= 3.3.0 is required to split test files by test examples. Learn more: https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases'
|
39
40
|
end
|
@@ -8,7 +8,6 @@ module KnapsackPro
|
|
8
8
|
'info' => ::Logger::INFO,
|
9
9
|
'debug' => ::Logger::DEBUG,
|
10
10
|
}
|
11
|
-
TMP_DIR = 'tmp/knapsack_pro'
|
12
11
|
|
13
12
|
class << self
|
14
13
|
def ci_node_total
|
@@ -257,6 +256,14 @@ module KnapsackPro
|
|
257
256
|
ENV['KNAPSACK_PRO_LOG_DIR']
|
258
257
|
end
|
259
258
|
|
259
|
+
def test_runner_adapter
|
260
|
+
ENV['KNAPSACK_PRO_TEST_RUNNER_ADAPTER']
|
261
|
+
end
|
262
|
+
|
263
|
+
def set_test_runner_adapter(adapter_class)
|
264
|
+
ENV['KNAPSACK_PRO_TEST_RUNNER_ADAPTER'] = adapter_class.to_s.split('::').last
|
265
|
+
end
|
266
|
+
|
260
267
|
private
|
261
268
|
|
262
269
|
def required_env(env_name)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module KnapsackPro
|
2
|
+
module Config
|
3
|
+
class TempFiles
|
4
|
+
# relative to the directory where you run knapsack_pro gem (user's project)
|
5
|
+
TEMP_DIRECTORY_PATH = '.knapsack_pro'
|
6
|
+
|
7
|
+
def self.ensure_temp_directory_exists!
|
8
|
+
unless File.exist?(gitignore_file_path)
|
9
|
+
create_temp_directory!
|
10
|
+
create_gitignore_file!
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.create_temp_directory!
|
17
|
+
FileUtils.mkdir_p(TEMP_DIRECTORY_PATH)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.gitignore_file_path
|
21
|
+
File.join(TEMP_DIRECTORY_PATH, '.gitignore')
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.gitignore_file_content
|
25
|
+
"# This directory is used by knapsack_pro gem for storing temporary files during tests runtime.\n" <<
|
26
|
+
"# Ignore all files, and do not commit this directory into your repository.\n" <<
|
27
|
+
"# Learn more at https://knapsackpro.com\n" <<
|
28
|
+
"*"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.create_gitignore_file!
|
32
|
+
File.open(gitignore_file_path, 'w+') do |f|
|
33
|
+
f.write(gitignore_file_content)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/knapsack_pro/report.rb
CHANGED
@@ -5,7 +5,7 @@ module KnapsackPro
|
|
5
5
|
|
6
6
|
if test_files.empty?
|
7
7
|
KnapsackPro.logger.warn("No test files were executed on this CI node.")
|
8
|
-
KnapsackPro.logger.debug("When you use knapsack_pro
|
8
|
+
KnapsackPro.logger.debug("When you use knapsack_pro Regular Mode, the reason for no tests executing might be a very narrow tests list. Most likely, you run only tests with a specified tag, and there were fewer test files with the tag than parallel CI nodes.")
|
9
9
|
end
|
10
10
|
|
11
11
|
create_build_subset(test_files)
|
@@ -16,6 +16,7 @@ module KnapsackPro
|
|
16
16
|
|
17
17
|
subset_queue_id = KnapsackPro::Config::Env.subset_queue_id
|
18
18
|
|
19
|
+
KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
|
19
20
|
FileUtils.mkdir_p(queue_path)
|
20
21
|
|
21
22
|
subset_queue_file_name = "#{subset_queue_id}.json"
|
@@ -36,8 +37,7 @@ module KnapsackPro
|
|
36
37
|
|
37
38
|
if test_files.empty?
|
38
39
|
KnapsackPro.logger.warn("No test files were executed on this CI node.")
|
39
|
-
KnapsackPro.logger.debug("
|
40
|
-
KnapsackPro.logger.debug("Another reason might be when your CI node failed in a way that prevented knapsack_pro to save time execution data to Knapsack Pro API and you have just tried to retry failed CI node but instead you got no test files to execute. In that case knapsack_pro don't know what tests should be executed here.")
|
40
|
+
KnapsackPro.logger.debug("This CI node likely started work late after the test files were already executed by other CI nodes consuming the queue.")
|
41
41
|
end
|
42
42
|
|
43
43
|
measured_test_files = test_files
|
@@ -46,9 +46,9 @@ module KnapsackPro
|
|
46
46
|
|
47
47
|
if test_files.size > 0 && measured_test_files.size == 0
|
48
48
|
KnapsackPro.logger.warn("#{test_files.size} test files were executed on this CI node but the recorded time was lost due to:")
|
49
|
-
KnapsackPro.logger.warn("1.
|
50
|
-
KnapsackPro.logger.warn("2.
|
51
|
-
KnapsackPro.logger.warn("3.
|
49
|
+
KnapsackPro.logger.warn("1. Please ensure you do not remove the contents of the .knapsack_pro directory between tests run.")
|
50
|
+
KnapsackPro.logger.warn("2. Ensure you've added Knapsack::Adapters::RSpecAdapter.bind in your rails_helper.rb or spec_helper.rb. Please follow the installation guide again: https://docs.knapsackpro.com/integration/")
|
51
|
+
KnapsackPro.logger.warn("3. Another potential reason for this warning is that all your tests are empty test files, pending tests, or they have syntax errors, and the time execution was not recorded for them.")
|
52
52
|
end
|
53
53
|
|
54
54
|
create_build_subset(test_files)
|
@@ -79,8 +79,7 @@ module KnapsackPro
|
|
79
79
|
private
|
80
80
|
|
81
81
|
def self.queue_path
|
82
|
-
|
83
|
-
"#{KnapsackPro::Config::Env::TMP_DIR}/queue/#{queue_id}"
|
82
|
+
"#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/queue/#{KnapsackPro::Config::Env.queue_id}"
|
84
83
|
end
|
85
84
|
end
|
86
85
|
end
|
@@ -6,11 +6,14 @@ module KnapsackPro
|
|
6
6
|
ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true'
|
7
7
|
|
8
8
|
adapter_class = KnapsackPro::Adapters::CucumberAdapter
|
9
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
9
10
|
runner = new(adapter_class)
|
10
11
|
|
11
12
|
if runner.test_files_to_execute_exist?
|
12
13
|
adapter_class.verify_bind_method_called
|
13
14
|
|
15
|
+
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
16
|
+
|
14
17
|
require 'cucumber/rake/task'
|
15
18
|
|
16
19
|
task_name = 'knapsack_pro:cucumber_run'
|
@@ -6,11 +6,14 @@ module KnapsackPro
|
|
6
6
|
ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true'
|
7
7
|
|
8
8
|
adapter_class = KnapsackPro::Adapters::MinitestAdapter
|
9
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
9
10
|
runner = new(adapter_class)
|
10
11
|
|
11
12
|
if runner.test_files_to_execute_exist?
|
12
13
|
adapter_class.verify_bind_method_called
|
13
14
|
|
15
|
+
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
16
|
+
|
14
17
|
task_name = 'knapsack_pro:minitest_run'
|
15
18
|
|
16
19
|
if Rake::Task.task_defined?(task_name)
|
@@ -9,7 +9,9 @@ module KnapsackPro
|
|
9
9
|
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
|
10
10
|
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
|
11
11
|
|
12
|
-
|
12
|
+
adapter_class = KnapsackPro::Adapters::CucumberAdapter
|
13
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
14
|
+
runner = new(adapter_class)
|
13
15
|
|
14
16
|
accumulator = {
|
15
17
|
status: :next,
|
@@ -9,7 +9,9 @@ module KnapsackPro
|
|
9
9
|
ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
|
10
10
|
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
|
11
11
|
|
12
|
-
|
12
|
+
adapter_class = KnapsackPro::Adapters::MinitestAdapter
|
13
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
14
|
+
runner = new(adapter_class)
|
13
15
|
|
14
16
|
# Add test_dir to load path to make work:
|
15
17
|
# require 'test_helper'
|
@@ -12,6 +12,7 @@ module KnapsackPro
|
|
12
12
|
ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
|
13
13
|
|
14
14
|
adapter_class = KnapsackPro::Adapters::RSpecAdapter
|
15
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
15
16
|
runner = new(adapter_class)
|
16
17
|
|
17
18
|
cli_args = (args || '').split
|
@@ -6,6 +6,7 @@ module KnapsackPro
|
|
6
6
|
ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true'
|
7
7
|
|
8
8
|
adapter_class = KnapsackPro::Adapters::RSpecAdapter
|
9
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
9
10
|
runner = new(adapter_class)
|
10
11
|
|
11
12
|
if runner.test_files_to_execute_exist?
|
@@ -14,6 +15,8 @@ module KnapsackPro
|
|
14
15
|
cli_args = (args || '').split
|
15
16
|
adapter_class.ensure_no_tag_option_when_rspec_split_by_test_examples_enabled!(cli_args)
|
16
17
|
|
18
|
+
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
19
|
+
|
17
20
|
require 'rspec/core/rake_task'
|
18
21
|
|
19
22
|
task_name = 'knapsack_pro:rspec_run'
|
@@ -5,11 +5,14 @@ module KnapsackPro
|
|
5
5
|
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_spinach
|
6
6
|
|
7
7
|
adapter_class = KnapsackPro::Adapters::SpinachAdapter
|
8
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
8
9
|
runner = new(adapter_class)
|
9
10
|
|
10
11
|
if runner.test_files_to_execute_exist?
|
11
12
|
adapter_class.verify_bind_method_called
|
12
13
|
|
14
|
+
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
15
|
+
|
13
16
|
cmd = %Q[KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=#{ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN']} bundle exec spinach #{args} --features_path #{runner.test_dir} -- #{runner.stringify_test_file_paths}]
|
14
17
|
|
15
18
|
Kernel.system(cmd)
|
@@ -6,11 +6,14 @@ module KnapsackPro
|
|
6
6
|
ENV['KNAPSACK_PRO_RECORDING_ENABLED'] = 'true'
|
7
7
|
|
8
8
|
adapter_class = KnapsackPro::Adapters::TestUnitAdapter
|
9
|
+
KnapsackPro::Config::Env.set_test_runner_adapter(adapter_class)
|
9
10
|
runner = new(adapter_class)
|
10
11
|
|
11
12
|
if runner.test_files_to_execute_exist?
|
12
13
|
adapter_class.verify_bind_method_called
|
13
14
|
|
15
|
+
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
16
|
+
|
14
17
|
cli_args =
|
15
18
|
(args || '').split +
|
16
19
|
runner.test_file_paths.map do |f|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module KnapsackPro
|
2
2
|
class SlowTestFileDeterminer
|
3
3
|
TIME_THRESHOLD_PER_CI_NODE = 0.7 # 70%
|
4
|
-
REPORT_DIR = "#{KnapsackPro::Config::Env::TMP_DIR}/slow_test_file_determiner"
|
5
4
|
|
6
5
|
# test_files: { 'path' => 'a_spec.rb', 'time_execution' => 0.0 }
|
7
6
|
# time_execution: of build distribution (total time of CI build run)
|
@@ -14,12 +13,13 @@ module KnapsackPro
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.save_to_json_report(test_files)
|
17
|
-
|
16
|
+
KnapsackPro::Config::TempFiles.ensure_temp_directory_exists!
|
17
|
+
FileUtils.mkdir_p(report_dir)
|
18
18
|
File.write(report_path, test_files.to_json)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.read_from_json_report
|
22
|
-
raise '
|
22
|
+
raise 'The report with slow test files has not been generated yet. If you have enabled split by test cases https://github.com/KnapsackPro/knapsack_pro-ruby#split-test-files-by-test-cases and you see this error it means that your tests accidentally cleaned up the .knapsack_pro directory. Please do not remove this directory during tests runtime!' unless File.exist?(report_path)
|
23
23
|
slow_test_files_json_report = File.read(report_path)
|
24
24
|
JSON.parse(slow_test_files_json_report)
|
25
25
|
end
|
@@ -27,7 +27,11 @@ module KnapsackPro
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def self.report_path
|
30
|
-
"#{
|
30
|
+
"#{report_dir}/slow_test_files_node_#{KnapsackPro::Config::Env.ci_node_index}.json"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.report_dir
|
34
|
+
"#{KnapsackPro::Config::TempFiles::TEMP_DIRECTORY_PATH}/slow_test_file_determiner"
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|