knapsack_pro 0.40.0 → 0.41.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
  SHA1:
3
- metadata.gz: 2b643c8be1b319ebbee7eba6e71a1c9006086129
4
- data.tar.gz: b75182aa4e028e1192fdaf3562ff77ecef0c38d7
3
+ metadata.gz: 13b0f54f8e0ffa8fa8a1dafac285ccdad9ee4559
4
+ data.tar.gz: e7208a544178784df5dcfc4d00032f4333e22408
5
5
  SHA512:
6
- metadata.gz: be387a13a2f6e29459ad46a46a8c8ff3d350e50d3ea3b3e6672214d2c00832797e8b3aabae7bca7629fe072573e51f4a5c25440d2c9de9106cefb938482dd229
7
- data.tar.gz: 22d8a26c14cb995c3399e3a5ab438d1c08e247f72d88412ad5853df903ded0cfa055fdc582f231b53dacf7f5ae29c6185c78b9e3673f609a28b85ec419f1fba5
6
+ metadata.gz: 91ceb897da7ec79de2c86a8dc76298d4f9d3a091fe90a66657c3cb6a81b9188e613fcc65e3376309742922f3f0513e0b5f7a9d3b7ac0055febec6c31fb500994
7
+ data.tar.gz: 0a7f9b2160f50e6423f2a58afb4fdf774e779524ab5f2a8efb6a6a8b0cee6ff9e97b859916ce27427eda5de6faf806bce2294a58f7ad19d57ebae7f166cdb1a4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.41.0
6
+
7
+ * Add after subset queue hook and example how to use JUnit formatter in Queue Mode.
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/41
10
+
11
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.40.0...v0.41.0
12
+
5
13
  ### 0.40.0
6
14
 
7
15
  * Replace rake task installer `knapsack_pro:install` with online installation guide. Remove `tty-prompt` gem dependency.
data/README.md CHANGED
@@ -41,7 +41,7 @@ For instance when you will run tests with `rake knapsack_pro:rspec` then:
41
41
  * knapsack_pro will run test files which got from API
42
42
  * after tests finished knapsack_pro will send information about time execution of each file to API http://docs.knapsackpro.com/api/v1/#build_subsets_post so data can be used for future test runs
43
43
 
44
- The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test suite split.
44
+ The knapsack_pro has also [queue mode](#queue-mode) to get optimal test suite split.
45
45
 
46
46
  # Requirements
47
47
 
@@ -121,6 +121,8 @@ The knapsack_pro has also [queue mode](#queue-mode) to get most optimal test sui
121
121
  - [B. Use tags to mark set of tests in particular test file](#b-use-tags-to-mark-set-of-tests-in-particular-test-file)
122
122
  - [How to make knapsack_pro works for forked repositories of my project?](#how-to-make-knapsack_pro-works-for-forked-repositories-of-my-project)
123
123
  - [How to use junit formatter?](#how-to-use-junit-formatter)
124
+ - [How to use junit formatter with knapsack_pro regular mode?](#how-to-use-junit-formatter-with-knapsack_pro-regular-mode)
125
+ - [How to use junit formatter with knapsack_pro queue mode?](#how-to-use-junit-formatter-with-knapsack_pro-queue-mode)
124
126
  - [How many API keys I need?](#how-many-api-keys-i-need)
125
127
  - [What is optimal order of test commands?](#what-is-optimal-order-of-test-commands)
126
128
  - [How to set `before(:suite)` and `after(:suite)` RSpec hooks in Queue Mode (Percy.io example)?](#how-to-set-beforesuite-and-aftersuite-rspec-hooks-in-queue-mode-percyio-example)
@@ -395,7 +397,7 @@ There might be some cached test suite splits for git commits you run in past for
395
397
 
396
398
  * `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=false` (default)
397
399
 
398
- By default, the fixed queue split is off. It means when you will run tests for the same commit hash and a total number of nodes and for the same branch, and the CI build ID is different with second tests run then the queue will be generated dynamically and CI nodes will fetch from Knapsack Pro API the test files in a dynamic way. This is default because it gives the most optimal test suite split for the whole test build across all CI nodes.
400
+ By default, the fixed queue split is off. It means when you will run tests for the same commit hash and a total number of nodes and for the same branch, and the CI build ID is different with second tests run then the queue will be generated dynamically and CI nodes will fetch from Knapsack Pro API the test files in a dynamic way. This is default because it gives the optimal test suite split for the whole test build across all CI nodes.
399
401
 
400
402
  * `KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true`
401
403
 
@@ -889,7 +891,7 @@ Please use fixed version of capybara-screenshot.
889
891
  ```
890
892
  # Gemfile
891
893
  group :test do
892
- gem 'capybara-screenshot', github: 'ArturT/capybara-screenshot', branch: 'fix-reporter_module-loaded-twice'
894
+ gem 'capybara-screenshot', github: 'mattheworiordan/capybara-screenshot', branch: 'master'
893
895
  end
894
896
  ```
895
897
 
@@ -1075,16 +1077,32 @@ Remember to follow other steps required for your CI provider.
1075
1077
 
1076
1078
  #### How to use junit formatter?
1077
1079
 
1080
+ ##### How to use junit formatter with knapsack_pro regular mode?
1081
+
1078
1082
  You can use junit formatter for rspec thanks to gem [rspec_junit_formatter](https://github.com/sj26/rspec_junit_formatter).
1079
1083
  Here you can find example how to generate `rspec.xml` file with junit format and at the same time show normal documentation format output for RSpec.
1080
1084
 
1081
1085
  # Regular Mode
1082
1086
  bundle exec rake "knapsack_pro:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
1083
1087
 
1088
+ ##### How to use junit formatter with knapsack_pro queue mode?
1089
+
1090
+ You can use junit formatter for rspec thanks to gem [rspec_junit_formatter](https://github.com/sj26/rspec_junit_formatter).
1091
+
1084
1092
  # Queue Mode
1085
- # The xml report will contain all tests executed across intermediate test subset runs based on queue
1086
1093
  bundle exec rake "knapsack_pro:queue:rspec[--format documentation --format RspecJunitFormatter --out tmp/rspec.xml]"
1087
1094
 
1095
+ The xml report will contain all tests executed across intermediate test subset runs based on work queue. You need to add after subset queue hook to rename `rspec.xml` to `rspec_final_results.xml` thanks to that the final results file will contain only single xml tag with all tests executed on the CI node. This is related to the way how queue mode works. Detailed explanation is in the [issue](https://github.com/KnapsackPro/knapsack_pro-ruby/issues/40).
1096
+
1097
+ # spec_helper.rb or rails_helper.rb
1098
+ KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
1099
+ # TODO This must be the same path as value for rspec --out argument
1100
+ old_xml_file = 'tmp/rspec.xml'
1101
+ # move results to new_xml_file so the results won't accumulate with duplicated xml tags in old_xml_file
1102
+ new_xml_file = 'tmp/rspec_final_results.xml'
1103
+ FileUtils.mv(old_xml_file, new_xml_file) if File.exists?(old_xml_file)
1104
+ end
1105
+
1088
1106
  #### How many API keys I need?
1089
1107
 
1090
1108
  Basically you need as many API keys as you have steps in your build.
data/lib/knapsack_pro.rb CHANGED
@@ -8,6 +8,7 @@ require 'digest'
8
8
  require 'securerandom'
9
9
  require_relative 'knapsack_pro/version'
10
10
  require_relative 'knapsack_pro/extensions/time'
11
+ require_relative 'knapsack_pro/hooks/queue'
11
12
  require_relative 'knapsack_pro/utils'
12
13
  require_relative 'knapsack_pro/logger_wrapper'
13
14
  require_relative 'knapsack_pro/config/ci/base'
@@ -0,0 +1,25 @@
1
+ module KnapsackPro
2
+ module Hooks
3
+ class Queue
4
+ class << self
5
+ attr_reader :after_subset_queue
6
+
7
+ def reset_after_subset_queue
8
+ @after_subset_queue = nil
9
+ end
10
+
11
+ def after_subset_queue(&block)
12
+ @after_subset_queue ||= block
13
+ end
14
+
15
+ def call_after_subset_queue
16
+ return unless after_subset_queue
17
+ after_subset_queue.call(
18
+ KnapsackPro::Config::Env.queue_id,
19
+ KnapsackPro::Config::Env.subset_queue_id
20
+ )
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -51,6 +51,8 @@ module KnapsackPro
51
51
  exitstatus = exit_code if exit_code != 0
52
52
  RSpec.world.example_groups.clear
53
53
 
54
+ KnapsackPro::Hooks::Queue.call_after_subset_queue
55
+
54
56
  run_tests(runner, false, args, exitstatus, all_test_file_paths)
55
57
  end
56
58
  end
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '0.40.0'
2
+ VERSION = '0.41.0'
3
3
  end
@@ -0,0 +1,29 @@
1
+ describe KnapsackPro::Hooks::Queue do
2
+ describe '.call_after_subset_queue' do
3
+ subject { described_class.call_after_subset_queue }
4
+
5
+ context 'when callback is not set' do
6
+ before do
7
+ described_class.reset_after_subset_queue
8
+ end
9
+
10
+ it { should be_nil }
11
+ end
12
+
13
+ context 'when callback is set' do
14
+ let(:queue_id) { double }
15
+ let(:subset_queue_id) { double }
16
+
17
+ before do
18
+ expect(KnapsackPro::Config::Env).to receive(:queue_id).and_return(queue_id)
19
+ expect(KnapsackPro::Config::Env).to receive(:subset_queue_id).and_return(subset_queue_id)
20
+
21
+ described_class.after_subset_queue do |q_id, subset_q_id|
22
+ [:fake_value, q_id, subset_q_id]
23
+ end
24
+ end
25
+
26
+ it { should eq [:fake_value, queue_id, subset_queue_id] }
27
+ end
28
+ end
29
+ end
@@ -1,4 +1,3 @@
1
-
2
1
  describe KnapsackPro::Runners::Queue::RSpecRunner do
3
2
  before do
4
3
  # we don't want to modify rspec formatters because we want to see tests summary at the end
@@ -100,6 +99,8 @@ describe KnapsackPro::Runners::Queue::RSpecRunner do
100
99
 
101
100
  expect(RSpec).to receive_message_chain(:world, :example_groups, :clear)
102
101
 
102
+ expect(KnapsackPro::Hooks::Queue).to receive(:call_after_subset_queue)
103
+
103
104
  # second call of run_tests because of recursion
104
105
  expect(runner).to receive(:test_file_paths).with(can_initialize_queue: false).and_return([])
105
106
  end
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: 0.40.0
4
+ version: 0.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-14 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -234,6 +234,7 @@ files:
234
234
  - lib/knapsack_pro/extensions/time.rb
235
235
  - lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb
236
236
  - lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb
237
+ - lib/knapsack_pro/hooks/queue.rb
237
238
  - lib/knapsack_pro/logger_wrapper.rb
238
239
  - lib/knapsack_pro/presenter.rb
239
240
  - lib/knapsack_pro/queue_allocator.rb
@@ -301,6 +302,7 @@ files:
301
302
  - spec/knapsack_pro/crypto/digestor_spec.rb
302
303
  - spec/knapsack_pro/crypto/encryptor_spec.rb
303
304
  - spec/knapsack_pro/extensions/time_spec.rb
305
+ - spec/knapsack_pro/hooks/queue_spec.rb
304
306
  - spec/knapsack_pro/logger_wrapper_spec.rb
305
307
  - spec/knapsack_pro/presenter_spec.rb
306
308
  - spec/knapsack_pro/queue_allocator_builder_spec.rb
@@ -397,6 +399,7 @@ test_files:
397
399
  - spec/knapsack_pro/crypto/digestor_spec.rb
398
400
  - spec/knapsack_pro/crypto/encryptor_spec.rb
399
401
  - spec/knapsack_pro/extensions/time_spec.rb
402
+ - spec/knapsack_pro/hooks/queue_spec.rb
400
403
  - spec/knapsack_pro/logger_wrapper_spec.rb
401
404
  - spec/knapsack_pro/presenter_spec.rb
402
405
  - spec/knapsack_pro/queue_allocator_builder_spec.rb