knapsack_pro 8.2.0 → 8.3.1
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/CHANGELOG.md +18 -1
- data/README.md +0 -36
- data/lib/knapsack_pro/adapters/rspec_adapter.rb +5 -5
- data/lib/knapsack_pro/formatters/time_tracker.rb +24 -9
- data/lib/knapsack_pro/repository_adapters/git_adapter.rb +6 -21
- data/lib/knapsack_pro/runners/spinach_runner.rb +2 -5
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/tasks/queue/cucumber.rake +1 -1
- data/lib/tasks/queue/minitest.rake +1 -1
- data/lib/tasks/queue/rspec.rake +1 -1
- data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +11 -30
- data/spec/knapsack_pro/formatters/time_tracker_specs.rb +119 -0
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +2 -6
- metadata +3 -4
- data/distroless/Dockerfile +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c6268ccfd0e07224b6fbae963baa01c2f6344b924b7b3b1097a42474c57e3b7
|
4
|
+
data.tar.gz: 909d3632bcede5ecd49e075edc62b4c8a602b31cd1e059c99097a92bd6b21c75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94cd957dcb04b6157e0aa6902cf6576e67857099b7c4db232742d7a420d08cc588e0dead4bb1d9ec7103024de0b2fe9edbeddacc0575d00533e530cd4c125465
|
7
|
+
data.tar.gz: cf30d4fddcab85d7ce32b589ef624bf08e78eb7d2ad236410c0d162538f3eee457311a7ff9a3ac08fb25440490574d707bf171d252e8dda4b9457138feced4b5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### UNRELEASED
|
3
|
+
### UNRELEASED (patch)
|
4
|
+
|
5
|
+
### 8.3.1
|
6
|
+
|
7
|
+
* Fix RSpec TimeTracker to properly track `before(:all)/after(:all)`.
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/303
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.3.0...v8.3.1
|
12
|
+
|
13
|
+
|
14
|
+
### 8.3.0
|
15
|
+
|
16
|
+
* Revert to 8.1.3 because of [the issue #301](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/301)
|
17
|
+
|
18
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/302
|
19
|
+
|
20
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v8.2.0...v8.3.0
|
4
21
|
|
5
22
|
### 8.2.0
|
6
23
|
|
data/README.md
CHANGED
@@ -72,42 +72,6 @@ bin/test
|
|
72
72
|
|
73
73
|
Scripted tests can be found in the [Rails App With Knapsack Pro repository](https://github.com/KnapsackPro/rails-app-with-knapsack_pro/blob/master/bin/knapsack_pro_all.rb).
|
74
74
|
|
75
|
-
### Distroless Container Images
|
76
|
-
|
77
|
-
Ensure that Knapsack Pro is written in a way that supports Distroless Container Images. Avoid using a shell when calling methods like [`Kernel.system`](https://rubyapi.org/3.4/o/kernel#method-i-system) or [`Kernel.exec`](https://rubyapi.org/3.4/o/kernel#method-i-exec).
|
78
|
-
|
79
|
-
✅ Good - shell is not required
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
cmd = 'bundle exec rake knapsack_pro:something'
|
83
|
-
Kernel.system({ 'RAILS_ENV' => 'test' }, cmd)
|
84
|
-
|
85
|
-
cmd = ['bundle', 'exec', 'rake', 'knapsack_pro:example']
|
86
|
-
Kernel.system({ 'RAILS_ENV' => 'test' }, *cmd)
|
87
|
-
```
|
88
|
-
|
89
|
-
⛔️ Bad - shell is required
|
90
|
-
|
91
|
-
```ruby
|
92
|
-
# Avoid embedding environment variables in the command string
|
93
|
-
cmd = 'RAILS_ENV=test bundle exec rake knapsack_pro:something'
|
94
|
-
Kernel.system(cmd)
|
95
|
-
|
96
|
-
# Avoid output redirection
|
97
|
-
cmd = 'program 2>/dev/null'
|
98
|
-
Kernel.system(cmd)
|
99
|
-
|
100
|
-
# Avoid using the pipe operator
|
101
|
-
cmd = 'program1 | program2'
|
102
|
-
Kernel.system(cmd)
|
103
|
-
```
|
104
|
-
|
105
|
-
Use [Dockerfile](distroless/Dockerfile) to test if the code requires a shell:
|
106
|
-
|
107
|
-
```bash
|
108
|
-
docker build -t test -f distroless/Dockerfile . && docker run --rm -it test
|
109
|
-
```
|
110
|
-
|
111
75
|
### Publishing
|
112
76
|
|
113
77
|
1. Move the changes listed in the `UNRELEASED` section of the `CHANGELOG.md` to the proper version
|
@@ -24,14 +24,14 @@ module KnapsackPro
|
|
24
24
|
KnapsackPro.logger.info("Generating RSpec test examples JSON report for slow test files to prepare it to be split by test examples (by individual test cases). Thanks to that, a single slow test file can be split across parallel CI nodes. Analyzing #{slow_test_files.size} slow test files.")
|
25
25
|
|
26
26
|
# generate the RSpec JSON report in a separate process to not pollute the RSpec state
|
27
|
-
envs = {'RACK_ENV' => 'test', 'RAILS_ENV' => 'test'}
|
28
27
|
cmd = [
|
28
|
+
'RACK_ENV=test',
|
29
|
+
'RAILS_ENV=test',
|
29
30
|
KnapsackPro::Config::Env.rspec_test_example_detector_prefix,
|
30
|
-
'rake knapsack_pro:rspec_test_example_detector'
|
31
|
+
'rake knapsack_pro:rspec_test_example_detector',
|
31
32
|
].join(' ')
|
32
|
-
unless Kernel.system(
|
33
|
-
|
34
|
-
raise "Could not generate JSON report for RSpec. Rake task failed when running #{inline_cmd}"
|
33
|
+
unless Kernel.system(cmd)
|
34
|
+
raise "Could not generate JSON report for RSpec. Rake task failed when running #{cmd}"
|
35
35
|
end
|
36
36
|
|
37
37
|
# read the JSON report
|
@@ -19,7 +19,7 @@ module KnapsackPro
|
|
19
19
|
@output = StringIO.new
|
20
20
|
@time_each = nil
|
21
21
|
@time_all = nil
|
22
|
-
@
|
22
|
+
@time_all_by_group_id_path = Hash.new(0)
|
23
23
|
@group = {}
|
24
24
|
@paths = {}
|
25
25
|
@suite_started = now
|
@@ -38,12 +38,12 @@ module KnapsackPro
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def example_group_started(notification)
|
41
|
-
|
41
|
+
record_time_all(notification.group.parent_groups[1], @time_all_by_group_id_path, @time_all)
|
42
42
|
@time_all = now
|
43
43
|
end
|
44
44
|
|
45
|
-
def example_started(
|
46
|
-
@
|
45
|
+
def example_started(notification)
|
46
|
+
record_time_all(notification.example.example_group, @time_all_by_group_id_path, @time_all)
|
47
47
|
@time_each = now
|
48
48
|
end
|
49
49
|
|
@@ -53,11 +53,12 @@ module KnapsackPro
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def example_group_finished(notification)
|
56
|
+
record_time_all(notification.group, @time_all_by_group_id_path, @time_all)
|
57
|
+
@time_all = now
|
56
58
|
return unless top_level_group?(notification.group)
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
@before_all = 0.0
|
60
|
+
add_hooks_time(@group, @time_all_by_group_id_path)
|
61
|
+
@time_all_by_group_id_path = Hash.new(0)
|
61
62
|
@paths = merge(@paths, @group)
|
62
63
|
@group = {}
|
63
64
|
end
|
@@ -104,10 +105,17 @@ module KnapsackPro
|
|
104
105
|
group.metadata[:parent_example_group].nil?
|
105
106
|
end
|
106
107
|
|
107
|
-
def add_hooks_time(group,
|
108
|
+
def add_hooks_time(group, time_all_by_group_id_path)
|
108
109
|
group.each do |_, example|
|
109
110
|
next if example[:time_execution] == 0.0
|
110
|
-
|
111
|
+
|
112
|
+
example[:time_execution] += time_all_by_group_id_path.sum do |group_id_path, time|
|
113
|
+
# :path is a file path (a_spec.rb), sum any before/after(:all) in the file
|
114
|
+
next time if group_id_path.start_with?(example[:path])
|
115
|
+
# :path is an id path (a_spec.rb[1:1]), sum any before/after(:all) above it
|
116
|
+
next time if example[:path].start_with?(group_id_path[0..-2])
|
117
|
+
0
|
118
|
+
end
|
111
119
|
end
|
112
120
|
end
|
113
121
|
|
@@ -123,6 +131,13 @@ module KnapsackPro
|
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|
134
|
+
def record_time_all(group, time_all_by_group_id_path, time_all)
|
135
|
+
return unless group # above top level group
|
136
|
+
|
137
|
+
group_id_path = KnapsackPro::TestFileCleaner.clean(group.id)
|
138
|
+
time_all_by_group_id_path[group_id_path] += now - time_all
|
139
|
+
end
|
140
|
+
|
126
141
|
def path_for(example)
|
127
142
|
file_path = file_path_for(example)
|
128
143
|
return nil if file_path == ""
|
@@ -44,41 +44,26 @@ module KnapsackPro
|
|
44
44
|
|
45
45
|
def git_commit_authors
|
46
46
|
if KnapsackPro::Config::Env.ci? && shallow_repository?
|
47
|
-
command = 'git fetch --shallow-since "one month ago" --quiet'
|
47
|
+
command = 'git fetch --shallow-since "one month ago" --quiet 2>/dev/null'
|
48
48
|
begin
|
49
49
|
Timeout.timeout(5) do
|
50
|
-
|
50
|
+
`#{command}`
|
51
51
|
end
|
52
52
|
rescue Timeout::Error
|
53
53
|
KnapsackPro.logger.debug("Skip the `#{command}` command because it took too long.")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
Kernel.system('git log --since "one month ago"', out: log_w, err: File::NULL)
|
59
|
-
log_w.close
|
60
|
-
IO.pipe do |shortlog_r, shortlog_w|
|
61
|
-
Kernel.system('git shortlog --summary --email', in: log_r, out: shortlog_w, err: File::NULL)
|
62
|
-
shortlog_w.close
|
63
|
-
shortlog_r.read
|
64
|
-
end
|
65
|
-
end
|
57
|
+
`git log --since "one month ago" 2>/dev/null | git shortlog --summary --email 2>/dev/null`
|
66
58
|
end
|
67
59
|
|
68
60
|
def git_build_author
|
69
|
-
|
70
|
-
Kernel.system('git log --format="%aN <%aE>" -1', out: w, err: File::NULL)
|
71
|
-
w.close
|
72
|
-
r.read
|
73
|
-
end
|
61
|
+
`git log --format="%aN <%aE>" -1 2>/dev/null`
|
74
62
|
end
|
75
63
|
|
76
64
|
def shallow_repository?
|
77
|
-
|
78
|
-
|
79
|
-
w.close
|
80
|
-
r.read.strip == 'true'
|
81
|
-
end
|
65
|
+
result = `git rev-parse --is-shallow-repository 2>/dev/null`
|
66
|
+
result.strip == 'true'
|
82
67
|
end
|
83
68
|
|
84
69
|
def working_dir
|
@@ -15,12 +15,9 @@ module KnapsackPro
|
|
15
15
|
|
16
16
|
KnapsackPro.tracker.set_prerun_tests(runner.test_file_paths)
|
17
17
|
|
18
|
-
cmd = %Q[bundle exec spinach #{args} --features_path #{runner.test_dir} -- #{runner.stringify_test_file_paths}]
|
18
|
+
cmd = %Q[KNAPSACK_PRO_REGULAR_MODE_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}]
|
19
19
|
|
20
|
-
Kernel.exec(
|
21
|
-
'KNAPSACK_PRO_REGULAR_MODE_ENABLED' => 'true',
|
22
|
-
'KNAPSACK_PRO_TEST_SUITE_TOKEN' => ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN']
|
23
|
-
}, cmd)
|
20
|
+
Kernel.exec(cmd)
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -5,7 +5,7 @@ require 'knapsack_pro'
|
|
5
5
|
namespace :knapsack_pro do
|
6
6
|
namespace :queue do
|
7
7
|
task :cucumber, [:cucumber_args] do |_, args|
|
8
|
-
Kernel.exec(
|
8
|
+
Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:cucumber_go[#{args[:cucumber_args]}]'")
|
9
9
|
end
|
10
10
|
|
11
11
|
task :cucumber_go, [:cucumber_args] do |_, args|
|
@@ -5,7 +5,7 @@ require 'knapsack_pro'
|
|
5
5
|
namespace :knapsack_pro do
|
6
6
|
namespace :queue do
|
7
7
|
task :minitest, [:minitest_args] do |_, args|
|
8
|
-
Kernel.exec(
|
8
|
+
Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:minitest_go[#{args[:minitest_args]}]'")
|
9
9
|
end
|
10
10
|
|
11
11
|
task :minitest_go, [:minitest_args] do |_, args|
|
data/lib/tasks/queue/rspec.rake
CHANGED
@@ -5,7 +5,7 @@ require 'knapsack_pro'
|
|
5
5
|
namespace :knapsack_pro do
|
6
6
|
namespace :queue do
|
7
7
|
task :rspec, [:rspec_args] do |_, args|
|
8
|
-
Kernel.exec(
|
8
|
+
Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:rspec_go[#{args[:rspec_args]}]'")
|
9
9
|
end
|
10
10
|
|
11
11
|
task :rspec_go, [:rspec_args] do |_, args|
|
@@ -57,36 +57,19 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
57
57
|
|
58
58
|
subject { described_class.test_file_cases_for(slow_test_files) }
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
allow(logger).to receive(:info)
|
65
|
-
|
66
|
-
cmd = 'bundle exec rake knapsack_pro:rspec_test_example_detector'
|
67
|
-
env = { 'RACK_ENV' => 'test', 'RAILS_ENV' => 'test' }
|
68
|
-
expect(Kernel).to receive(:system).with(env, cmd).and_return(true)
|
69
|
-
|
70
|
-
rspec_test_example_detector = instance_double(KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector)
|
71
|
-
expect(KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector).to receive(:new).and_return(rspec_test_example_detector)
|
72
|
-
|
73
|
-
test_file_example_paths = double
|
74
|
-
expect(rspec_test_example_detector).to receive(:test_file_example_paths).and_return(test_file_example_paths)
|
75
|
-
|
76
|
-
expect(subject).to eq test_file_example_paths
|
60
|
+
before do
|
61
|
+
logger = instance_double(Logger)
|
62
|
+
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
63
|
+
expect(logger).to receive(:info).with("Generating RSpec test examples JSON report for slow test files to prepare it to be split by test examples (by individual test cases). Thanks to that, a single slow test file can be split across parallel CI nodes. Analyzing 5 slow test files.")
|
77
64
|
|
78
|
-
|
79
|
-
|
65
|
+
cmd = 'RACK_ENV=test RAILS_ENV=test bundle exec rake knapsack_pro:rspec_test_example_detector'
|
66
|
+
expect(Kernel).to receive(:system).with(cmd).and_return(cmd_result)
|
80
67
|
end
|
81
68
|
|
82
|
-
context 'when
|
83
|
-
|
84
|
-
stub_const('ENV', { 'KNAPSACK_PRO_RSPEC_TEST_EXAMPLE_DETECTOR_PREFIX' => 'CUSTOM_ENV_VAR=123 bundle exec' })
|
85
|
-
|
86
|
-
cmd = 'CUSTOM_ENV_VAR=123 bundle exec rake knapsack_pro:rspec_test_example_detector'
|
87
|
-
env = { 'RACK_ENV' => 'test', 'RAILS_ENV' => 'test' }
|
88
|
-
expect(Kernel).to receive(:system).with(env, cmd).and_return(true)
|
69
|
+
context 'when the rake task to detect RSpec test examples succeeded' do
|
70
|
+
let(:cmd_result) { true }
|
89
71
|
|
72
|
+
it 'returns test example paths for slow test files' do
|
90
73
|
rspec_test_example_detector = instance_double(KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector)
|
91
74
|
expect(KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector).to receive(:new).and_return(rspec_test_example_detector)
|
92
75
|
|
@@ -98,11 +81,9 @@ describe KnapsackPro::Adapters::RSpecAdapter do
|
|
98
81
|
end
|
99
82
|
|
100
83
|
context 'when the rake task to detect RSpec test examples failed' do
|
101
|
-
|
102
|
-
cmd = 'bundle exec rake knapsack_pro:rspec_test_example_detector'
|
103
|
-
env = { 'RACK_ENV' => 'test', 'RAILS_ENV' => 'test' }
|
104
|
-
expect(Kernel).to receive(:system).with(env, cmd).and_return(false)
|
84
|
+
let(:cmd_result) { false }
|
105
85
|
|
86
|
+
it do
|
106
87
|
expect { subject }.to raise_error(RuntimeError, 'Could not generate JSON report for RSpec. Rake task failed when running RACK_ENV=test RAILS_ENV=test bundle exec rake knapsack_pro:rspec_test_example_detector')
|
107
88
|
end
|
108
89
|
end
|
@@ -220,6 +220,63 @@ class TestTimeTracker
|
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
+
def test_nested_hooks
|
224
|
+
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
225
|
+
false
|
226
|
+
end
|
227
|
+
|
228
|
+
spec = <<~SPEC
|
229
|
+
describe "KnapsackPro::Formatters::TimeTracker" do
|
230
|
+
before(:all) do
|
231
|
+
sleep 0.1
|
232
|
+
end
|
233
|
+
|
234
|
+
after(:all) do
|
235
|
+
sleep 0.1
|
236
|
+
end
|
237
|
+
|
238
|
+
it do
|
239
|
+
expect(1).to eq 1
|
240
|
+
end
|
241
|
+
|
242
|
+
describe do
|
243
|
+
before(:all) do
|
244
|
+
sleep 0.1
|
245
|
+
end
|
246
|
+
|
247
|
+
after(:all) do
|
248
|
+
sleep 0.1
|
249
|
+
end
|
250
|
+
|
251
|
+
it do
|
252
|
+
expect(1).to eq 1
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
describe do
|
257
|
+
before(:all) do
|
258
|
+
sleep 0.1
|
259
|
+
end
|
260
|
+
|
261
|
+
after(:all) do
|
262
|
+
sleep 0.1
|
263
|
+
end
|
264
|
+
|
265
|
+
it do
|
266
|
+
expect(1).to eq 1
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
SPEC
|
271
|
+
|
272
|
+
run_specs(spec) do |spec_paths, times|
|
273
|
+
raise unless times.size == 1
|
274
|
+
raise unless times[0]["path"] == spec_paths.first
|
275
|
+
raise unless times[0]["time_execution"] > 0.60
|
276
|
+
raise unless times[0]["time_execution"] < 0.65
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
223
280
|
def test_hooks_with_rspec_split_by_test_example
|
224
281
|
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
225
282
|
true
|
@@ -263,6 +320,68 @@ class TestTimeTracker
|
|
263
320
|
end
|
264
321
|
end
|
265
322
|
|
323
|
+
def test_nested_hooks_with_rspec_split_by_test_example
|
324
|
+
KnapsackPro::Formatters::TimeTracker.define_method(:rspec_split_by_test_example?) do |_file|
|
325
|
+
true
|
326
|
+
end
|
327
|
+
|
328
|
+
spec = <<~SPEC
|
329
|
+
describe "KnapsackPro::Formatters::TimeTracker" do
|
330
|
+
before(:all) do
|
331
|
+
sleep 0.1
|
332
|
+
end
|
333
|
+
|
334
|
+
after(:all) do
|
335
|
+
sleep 0.1
|
336
|
+
end
|
337
|
+
|
338
|
+
it do
|
339
|
+
expect(1).to eq 1
|
340
|
+
end
|
341
|
+
|
342
|
+
describe do
|
343
|
+
before(:all) do
|
344
|
+
sleep 0.1
|
345
|
+
end
|
346
|
+
|
347
|
+
after(:all) do
|
348
|
+
sleep 0.1
|
349
|
+
end
|
350
|
+
|
351
|
+
it do
|
352
|
+
expect(1).to eq 1
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
describe do
|
357
|
+
before(:all) do
|
358
|
+
sleep 0.1
|
359
|
+
end
|
360
|
+
|
361
|
+
after(:all) do
|
362
|
+
sleep 0.1
|
363
|
+
end
|
364
|
+
|
365
|
+
it do
|
366
|
+
expect(1).to eq 1
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
SPEC
|
371
|
+
|
372
|
+
run_specs(spec) do |spec_paths, times|
|
373
|
+
raise unless times.size == 3
|
374
|
+
spec_path = spec_paths.first
|
375
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:1]" }["time_execution"] > 0.20
|
376
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:1]" }["time_execution"] < 0.25
|
377
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:2:1]" }["time_execution"] > 0.40
|
378
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:2:1]" }["time_execution"] < 0.45
|
379
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:3:1]" }["time_execution"] > 0.40
|
380
|
+
raise unless times.find { |time| time["path"] == "#{spec_path}[1:3:1]" }["time_execution"] < 0.45
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
|
266
385
|
def test_unknown_path
|
267
386
|
KnapsackPro::Formatters::TimeTracker.class_eval do
|
268
387
|
alias_method :original_file_path_for, :file_path_for
|
@@ -19,8 +19,8 @@ describe KnapsackPro::Runners::SpinachRunner do
|
|
19
19
|
|
20
20
|
context 'when test files were returned by Knapsack Pro API' do
|
21
21
|
let(:test_file_paths) { ['features/a.feature', 'features/b.feature'] }
|
22
|
-
let(:test_dir) { 'fake-test-dir' }
|
23
22
|
let(:stringify_test_file_paths) { test_file_paths.join(' ') }
|
23
|
+
let(:test_dir) { 'fake-test-dir' }
|
24
24
|
let(:runner) do
|
25
25
|
instance_double(described_class,
|
26
26
|
test_dir: test_dir,
|
@@ -28,7 +28,6 @@ describe KnapsackPro::Runners::SpinachRunner do
|
|
28
28
|
stringify_test_file_paths: stringify_test_file_paths,
|
29
29
|
test_files_to_execute_exist?: true)
|
30
30
|
end
|
31
|
-
let(:child_status) { double }
|
32
31
|
|
33
32
|
it do
|
34
33
|
expect(KnapsackPro::Adapters::SpinachAdapter).to receive(:verify_bind_method_called)
|
@@ -37,10 +36,7 @@ describe KnapsackPro::Runners::SpinachRunner do
|
|
37
36
|
expect(KnapsackPro).to receive(:tracker).and_return(tracker)
|
38
37
|
expect(tracker).to receive(:set_prerun_tests).with(test_file_paths)
|
39
38
|
|
40
|
-
expect(Kernel).to receive(:exec).with(
|
41
|
-
{ 'KNAPSACK_PRO_REGULAR_MODE_ENABLED' => 'true', 'KNAPSACK_PRO_TEST_SUITE_TOKEN' => 'spinach-token' },
|
42
|
-
'bundle exec spinach --custom-arg --features_path fake-test-dir -- features/a.feature features/b.feature'
|
43
|
-
)
|
39
|
+
expect(Kernel).to receive(:exec).with('KNAPSACK_PRO_REGULAR_MODE_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=spinach-token bundle exec spinach --custom-arg --features_path fake-test-dir -- features/a.feature features/b.feature')
|
44
40
|
|
45
41
|
subject
|
46
42
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rake
|
@@ -216,7 +216,6 @@ files:
|
|
216
216
|
- Rakefile
|
217
217
|
- bin/knapsack_pro
|
218
218
|
- bin/test
|
219
|
-
- distroless/Dockerfile
|
220
219
|
- knapsack_pro.gemspec
|
221
220
|
- lib/knapsack_pro.rb
|
222
221
|
- lib/knapsack_pro/adapters/base_adapter.rb
|
@@ -429,7 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
429
428
|
- !ruby/object:Gem::Version
|
430
429
|
version: '0'
|
431
430
|
requirements: []
|
432
|
-
rubygems_version: 3.6.
|
431
|
+
rubygems_version: 3.6.7
|
433
432
|
specification_version: 4
|
434
433
|
summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel
|
435
434
|
job finish work at a similar time.
|
data/distroless/Dockerfile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
FROM cgr.dev/chainguard/ruby:latest-dev AS builder
|
2
|
-
|
3
|
-
WORKDIR /build
|
4
|
-
RUN <<RUN
|
5
|
-
cat <<GEMFILE > Gemfile
|
6
|
-
source "https://rubygems.org"
|
7
|
-
GEMFILE
|
8
|
-
|
9
|
-
gem install bundler
|
10
|
-
bundle config set --local path vendor/bundle
|
11
|
-
bundle install
|
12
|
-
RUN
|
13
|
-
|
14
|
-
RUN <<RUN
|
15
|
-
cat <<RAKEFILE > Rakefile
|
16
|
-
RAKEFILE
|
17
|
-
|
18
|
-
mkdir bin
|
19
|
-
cat <<CI > bin/ci
|
20
|
-
ENV['PATH'] =+ "#{Gem.user_dir}/bin"
|
21
|
-
require 'bundler/setup'
|
22
|
-
|
23
|
-
success = Kernel.system({ 'RAILS_ENV' => 'test' }, 'bundle --version') # ✅
|
24
|
-
raise "The command failed!" unless success
|
25
|
-
|
26
|
-
success = Kernel.system({ 'RAILS_ENV' => 'test' }, 'bundle --version 2>/dev/null') # ⛔️
|
27
|
-
raise "The command failed!" unless success
|
28
|
-
|
29
|
-
CI
|
30
|
-
RUN
|
31
|
-
|
32
|
-
FROM cgr.dev/chainguard/ruby:latest
|
33
|
-
|
34
|
-
WORKDIR /app
|
35
|
-
COPY --from=builder /home/nonroot/.local /home/nonroot/.local
|
36
|
-
COPY --from=builder /build /app
|
37
|
-
CMD ["bin/ci"]
|