knapsack_pro 7.5.0 → 7.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cea03959b8de66cd8cbb686deb3ac76129f9cce7ee24b1da2a0ef9e57dd790df
4
- data.tar.gz: ec12a1f99f57207e967846df739a5dfea4a1423e6823431ee9cf26f1d2f9a473
3
+ metadata.gz: 4c20774d9ffe521fc4a3a137558b47c79cc27b085e96f2b00d3a61711e43f0c9
4
+ data.tar.gz: af712f88ca12cf15de791d3b755fc75d6a527e938034d835ddaa0e07b77a5fd2
5
5
  SHA512:
6
- metadata.gz: cd53605f0d47ce2a3bc83410eb56d459a65aa1b75b169c420f5a11e3693b2aa7abee8e5b984eff35ab876de53809a2c113abb38b253e1e1b42726c817bccae6b
7
- data.tar.gz: 93eaec09e20ba573cfb69b0f1ad2e8a04f5db2ab95637767a1abed0d8640cf131447b1adae67196998d73165232ea1a23e2c1fe547ab01b14436ace7d422edc5
6
+ metadata.gz: ad574926a94e992932fbc8538d15040535624631c22f3679ca3c39d4d304f2e87b0efa30c536eb2695698b419b3f9e58708f1e4e5afc83d6df565e4eae6c3e7b
7
+ data.tar.gz: 21365b7b89c96193c3ad9ae45657d6916760745b584f1552a7e85ac686b2de6e12d6b7203c8847e2cd09997b456462f742490cc4d140d42cf135ddbd5cc23865
@@ -16,6 +16,7 @@ TODO: changes introduced by this PR
16
16
 
17
17
  # Checklist reminder
18
18
 
19
+ - [ ] You added the changes to the `UNRELEASED` section of the `CHANGELOG.md`, including the needed bump (ie, patch, minor, major)
19
20
  - [ ] You follow the architecture outlined below for RSpec in Queue Mode, which is a work in progress (feel free to propose changes):
20
21
  - Pure: `lib/knapsack_pro/pure/queue/rspec_pure.rb` contains pure functions that are unit tested.
21
22
  - Extension: `lib/knapsack_pro/extensions/rspec_extension.rb` encapsulates calls to RSpec internals and is integration and e2e tested.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ### UNRELEASED
4
+
5
+ ### 7.6.0
6
+
7
+ * Avoid starting an unnecessary process in Queue Mode.
8
+ * Fix: the terminal is returned to the user correctly (output looks good) when you use CTRL+C
9
+ * Improvement: the backtrace looks better when something fails (for example, the gem handles an OS signal)
10
+
11
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/260
12
+
13
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.5.1...v7.6.0
14
+
15
+ ### 7.5.1
16
+
17
+ * Revert to 7.4.0.
18
+
19
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.5.0...v7.5.1
20
+
3
21
  ### 7.5.0
22
+
4
23
  * Raise when `KNAPSACK_PRO_CI_NODE_TOTAL` or `KNAPSACK_PRO_CI_NODE_INDEX` is missing and can't be determined from supported CI environments, instead of defaulting to arbitrary numbers.
5
24
 
6
25
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/256
@@ -8,6 +27,7 @@
8
27
  https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.4.0...v7.5.0
9
28
 
10
29
  ### 7.4.0
30
+
11
31
  * Warn when `KNAPSACK_PRO_*` environment variables are set manually if their values could be automatically determined from supported CI environments.
12
32
 
13
33
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/254
@@ -225,6 +245,34 @@ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v6.0.4...v7.0.0
225
245
 
226
246
  https://github.com/KnapsackPro/knapsack_pro-ruby/pull/236
227
247
 
248
+ __(breaking change)__ for SimpleCov and Minitest in Knapsack Pro Queue Mode users.
249
+
250
+ Please add the following to your configuration:
251
+
252
+ ```ruby
253
+ KnapsackPro::Hooks::Queue.after_queue do
254
+ SimpleCov.result.format!
255
+ end
256
+ ```
257
+
258
+ The full example:
259
+
260
+ ```ruby
261
+ # test/test_helper.rb
262
+ require 'knapsack_pro'
263
+ require 'simplecov'
264
+
265
+ SimpleCov.start
266
+
267
+ KnapsackPro::Hooks::Queue.before_queue do |queue_id|
268
+ SimpleCov.command_name("minitest_ci_node_#{KnapsackPro::Config::Env.ci_node_index}")
269
+ end
270
+
271
+ KnapsackPro::Hooks::Queue.after_queue do
272
+ SimpleCov.result.format!
273
+ end
274
+ ```
275
+
228
276
  https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v6.0.3...v6.0.4
229
277
 
230
278
  ### 6.0.3
data/README.md CHANGED
@@ -74,28 +74,13 @@ Scripted tests can be found in the [Rails App With Knapsack Pro repository](http
74
74
 
75
75
  ### Publishing
76
76
 
77
- 1. Update the `CHANGELOG.md` as part of your PR.
77
+ 1. Move the changes listed in the `UNRELEASED` section of the `CHANGELOG.md` to the proper version
78
78
 
79
- 2. After your PR has been merged, update the gem version in `lib/knapsack_pro/version.rb` directly on the `master` branch:
79
+ 2. Update the gem version in `lib/knapsack_pro/version.rb`
80
80
 
81
- ```bash
82
- git commit -m "Bump version X.X.X"
83
- git push origin master
84
- ```
85
-
86
- 3. Create a git tag for the release:
81
+ 3. `git commit -am "chore: prepare release"`
87
82
 
88
- ```bash
89
- git tag -a vX.X.X -m "Release vX.X.X"
90
- git push --tags
91
- ```
92
-
93
- 4. Build the gem and publish it to RubyGems:
94
-
95
- ```bash
96
- gem build knapsack_pro.gemspec
97
- gem push knapsack_pro-X.X.X.gem
98
- ```
83
+ 4. Build, tag, push, release: `bundle exec rake release`
99
84
 
100
85
  5. Update the latest available gem version in `TestSuiteClientVersionChecker` for the Knapsack Pro API repository.
101
86
 
@@ -13,17 +13,11 @@ module KnapsackPro
13
13
 
14
14
  class << self
15
15
  def ci_node_total
16
- env_name = 'KNAPSACK_PRO_CI_NODE_TOTAL'
17
- env_value = env_for(env_name, :node_total)
18
-
19
- env_value ? env_value.to_i : raise_missing_env_for(env_name)
16
+ (env_for('KNAPSACK_PRO_CI_NODE_TOTAL', :node_total) || 1).to_i
20
17
  end
21
18
 
22
19
  def ci_node_index
23
- env_name = 'KNAPSACK_PRO_CI_NODE_INDEX'
24
- env_value = env_for(env_name, :node_index)
25
-
26
- env_value ? env_value.to_i : raise_missing_env_for(env_name)
20
+ (env_for('KNAPSACK_PRO_CI_NODE_INDEX', :node_index) || 0).to_i
27
21
  end
28
22
 
29
23
  def ci_node_build_id
@@ -280,7 +274,7 @@ module KnapsackPro
280
274
  private
281
275
 
282
276
  def required_env(env_name)
283
- ENV[env_name] || raise_missing_env_for(env_name)
277
+ ENV[env_name] || raise("Missing environment variable #{env_name}")
284
278
  end
285
279
 
286
280
  def env_for(knapsack_env_name, ci_env_method)
@@ -297,10 +291,6 @@ module KnapsackPro
297
291
  def ci_env_for(env_name)
298
292
  detected_ci.new.send(env_name)
299
293
  end
300
-
301
- def raise_missing_env_for(env_name)
302
- raise("Missing environment variable #{env_name}")
303
- end
304
294
  end
305
295
  end
306
296
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '7.5.0'
4
+ VERSION = '7.6.0'
5
5
  end
@@ -5,14 +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.system("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:cucumber_go[#{args[:cucumber_args]}]'")
9
- exitstatus = $?.exitstatus
10
- if exitstatus.nil?
11
- puts 'Something went wrong. Most likely, the process has been killed. Knapsack Pro has been terminated.'
12
- Kernel.exit(1)
13
- else
14
- Kernel.exit(exitstatus)
15
- end
8
+ Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:cucumber_go[#{args[:cucumber_args]}]'")
16
9
  end
17
10
 
18
11
  task :cucumber_go, [:cucumber_args] do |_, args|
@@ -5,14 +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.system("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:minitest_go[#{args[:minitest_args]}]'")
9
- exitstatus = $?.exitstatus
10
- if exitstatus.nil?
11
- puts 'Something went wrong. Most likely, the process has been killed. Knapsack Pro has been terminated.'
12
- Kernel.exit(1)
13
- else
14
- Kernel.exit(exitstatus)
15
- end
8
+ Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:minitest_go[#{args[:minitest_args]}]'")
16
9
  end
17
10
 
18
11
  task :minitest_go, [:minitest_args] do |_, args|
@@ -5,14 +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.system("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:rspec_go[#{args[:rspec_args]}]'")
9
- exitstatus = $?.exitstatus
10
- if exitstatus.nil?
11
- puts 'Something went wrong. Most likely, the process has been killed. Knapsack Pro has been terminated.'
12
- Kernel.exit(1)
13
- else
14
- Kernel.exit(exitstatus)
15
- end
8
+ Kernel.exec("RAILS_ENV=test RACK_ENV=test #{$PROGRAM_NAME} 'knapsack_pro:queue:rspec_go[#{args[:rspec_args]}]'")
16
9
  end
17
10
 
18
11
  task :rspec_go, [:rspec_args] do |_, args|
@@ -18,18 +18,23 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
18
18
  # @param spec_batches Array[Array[String]]
19
19
  def generate_specs(spec_helper, rspec_options, spec_batches)
20
20
  ENV['TEST__RSPEC_OPTIONS'] = rspec_options
21
+ generate_spec_helper(spec_helper)
22
+ paths = generate_spec_files(spec_batches.flatten)
23
+ stub_spec_batches(
24
+ spec_batches.map { _1.map(&:path) }
25
+ )
26
+ end
21
27
 
28
+ def generate_spec_helper(spec_helper)
22
29
  spec_helper_path = "#{SPEC_DIRECTORY}/spec_helper.rb"
23
30
  File.open(spec_helper_path, 'w') { |file| file.write(spec_helper) }
31
+ end
24
32
 
25
- paths = spec_batches.flatten.map do |spec_item|
33
+ def generate_spec_files(specs)
34
+ specs.map do |spec_item|
26
35
  File.open(spec_item.path, 'w') { |file| file.write(spec_item.content) }
27
36
  spec_item.path
28
37
  end
29
-
30
- stub_spec_batches(
31
- spec_batches.map { _1.map(&:path) }
32
- )
33
38
  end
34
39
 
35
40
  def create_rails_helper_file(rails_helper)
@@ -73,8 +78,9 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
73
78
  SPEC
74
79
  end
75
80
 
81
+ let(:command) { 'ruby spec/integration/runners/queue/rspec_runner.rb' }
82
+
76
83
  subject do
77
- command = 'ruby spec/integration/runners/queue/rspec_runner.rb'
78
84
  stdout, stderr, status = Open3.capture3(command)
79
85
  log_command_result(stdout, stderr, status)
80
86
  OpenStruct.new(stdout: stdout, stderr: stderr, exit_code: status.exitstatus)
@@ -2537,4 +2543,28 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
2537
2543
  expect(actual.exit_code).to eq 0
2538
2544
  end
2539
2545
  end
2546
+
2547
+ context 'when rspec is run without knapsack_pro' do
2548
+ let(:spec) { Spec.new('a_spec.rb', <<~SPEC) }
2549
+ require_relative "spec_helper.rb"
2550
+
2551
+ describe 'A_describe' do
2552
+ it 'A1 test example' do
2553
+ expect(1).to eq 1
2554
+ end
2555
+ end
2556
+ SPEC
2557
+
2558
+ let(:command) { "bundle exec rspec #{spec.path}" }
2559
+
2560
+ it 'runs successfully' do
2561
+ generate_spec_helper(spec_helper_with_knapsack)
2562
+ generate_spec_files([spec])
2563
+
2564
+ actual = subject
2565
+
2566
+ expect(actual.stdout).to include('1 example, 0 failures')
2567
+ expect(actual.exit_code).to eq 0
2568
+ end
2569
+ end
2540
2570
  end
@@ -54,9 +54,7 @@ describe KnapsackPro::Config::Env do
54
54
  end
55
55
 
56
56
  context "when ENV doesn't exist" do
57
- it 'raises' do
58
- expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_TOTAL/)
59
- end
57
+ it { should eq 1 }
60
58
  end
61
59
  end
62
60
 
@@ -120,9 +118,7 @@ describe KnapsackPro::Config::Env do
120
118
  end
121
119
 
122
120
  context "when ENV doesn't exist" do
123
- it 'raises' do
124
- expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_INDEX/)
125
- end
121
+ it { should eq 0 }
126
122
  end
127
123
  end
128
124
 
@@ -36,11 +36,13 @@ describe KnapsackPro do
36
36
  stub_const('ENV', {
37
37
  'KNAPSACK_PRO_LOG_DIR' => 'log',
38
38
  })
39
- end
40
39
 
41
- it 'raises' do
42
- expect { subject }.to raise_error(/Missing environment variable KNAPSACK_PRO_CI_NODE_INDEX/)
40
+ expect(Logger).to receive(:new).with('log/knapsack_pro_node_0.log').and_return(logger)
41
+ expect(logger).to receive(:level=).with(Logger::INFO)
42
+ expect(KnapsackPro::LoggerWrapper).to receive(:new).with(logger).and_return(logger_wrapper)
43
43
  end
44
+
45
+ it { should eql logger_wrapper }
44
46
  end
45
47
  end
46
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.5.0
4
+ version: 7.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-27 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -415,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
415
  - !ruby/object:Gem::Version
416
416
  version: '0'
417
417
  requirements: []
418
- rubygems_version: 3.4.10
418
+ rubygems_version: 3.5.9
419
419
  signing_key:
420
420
  specification_version: 4
421
421
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel