knapsack_pro 6.0.4 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +80 -19
  3. data/.github/pull_request_template.md +22 -0
  4. data/.gitignore +4 -0
  5. data/CHANGELOG.md +87 -0
  6. data/Gemfile +9 -0
  7. data/README.md +0 -4
  8. data/knapsack_pro.gemspec +2 -1
  9. data/lib/knapsack_pro/adapters/base_adapter.rb +7 -2
  10. data/lib/knapsack_pro/adapters/cucumber_adapter.rb +1 -3
  11. data/lib/knapsack_pro/adapters/rspec_adapter.rb +16 -9
  12. data/lib/knapsack_pro/config/env.rb +1 -9
  13. data/lib/knapsack_pro/extensions/rspec_extension.rb +137 -0
  14. data/lib/knapsack_pro/formatters/time_tracker.rb +10 -26
  15. data/lib/knapsack_pro/formatters/time_tracker_fetcher.rb +6 -0
  16. data/lib/knapsack_pro/presenter.rb +1 -1
  17. data/lib/knapsack_pro/pure/queue/rspec_pure.rb +92 -0
  18. data/lib/knapsack_pro/runners/queue/base_runner.rb +6 -1
  19. data/lib/knapsack_pro/runners/queue/cucumber_runner.rb +6 -6
  20. data/lib/knapsack_pro/runners/queue/minitest_runner.rb +6 -6
  21. data/lib/knapsack_pro/runners/queue/rspec_runner.rb +124 -173
  22. data/lib/knapsack_pro/urls.rb +2 -0
  23. data/lib/knapsack_pro/version.rb +1 -1
  24. data/lib/knapsack_pro.rb +1 -0
  25. data/spec/integration/runners/queue/rspec_runner.rb +80 -0
  26. data/spec/integration/runners/queue/rspec_runner_spec.rb +2232 -0
  27. data/spec/knapsack_pro/adapters/base_adapter_spec.rb +17 -11
  28. data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +2 -5
  29. data/spec/knapsack_pro/adapters/rspec_adapter_spec.rb +2 -24
  30. data/spec/knapsack_pro/config/env_spec.rb +1 -35
  31. data/spec/knapsack_pro/formatters/time_tracker_specs.rb +8 -37
  32. data/spec/knapsack_pro/hooks/queue_spec.rb +2 -2
  33. data/spec/knapsack_pro/presenter_spec.rb +1 -1
  34. data/spec/knapsack_pro/pure/queue/rspec_pure_spec.rb +224 -0
  35. data/spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb +16 -16
  36. data/spec/knapsack_pro/runners/queue/minitest_runner_spec.rb +14 -14
  37. data/spec/knapsack_pro_spec.rb +3 -3
  38. metadata +17 -12
  39. data/lib/knapsack_pro/formatters/rspec_queue_profile_formatter_extension.rb +0 -58
  40. data/lib/knapsack_pro/formatters/rspec_queue_summary_formatter.rb +0 -145
  41. data/spec/knapsack_pro/runners/queue/rspec_runner_spec.rb +0 -536
@@ -28,6 +28,8 @@ module KnapsackPro
28
28
 
29
29
  REGULAR_MODE__CONNECTION_ERROR_WITH_FALLBACK_ENABLED_TRUE_AND_POSITIVE_RETRY_COUNT = "#{HOST}/perma/ruby/regular-mode-connection-error-with-fallback-enabled-true-and-positive-retry-count"
30
30
 
31
+ RSPEC__DEPRECATED_RUN_ALL_WHEN_EVERYTHING_FILTERED = "#{HOST}/perma/ruby/rspec-deprecated-run-all-when-everything-filtered"
32
+
31
33
  RSPEC__SKIPS_TESTS = "#{HOST}/perma/ruby/rspec-skips-tests"
32
34
 
33
35
  RSPEC__SPLIT_BY_TEST_EXAMPLES__TAG = "#{HOST}/perma/ruby/rspec-split-by-test-examples-tag"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '6.0.4'
4
+ VERSION = '7.0.0'
5
5
  end
data/lib/knapsack_pro.rb CHANGED
@@ -82,6 +82,7 @@ require_relative 'knapsack_pro/crypto/encryptor'
82
82
  require_relative 'knapsack_pro/crypto/branch_encryptor'
83
83
  require_relative 'knapsack_pro/crypto/decryptor'
84
84
  require_relative 'knapsack_pro/crypto/digestor'
85
+ require_relative 'knapsack_pro/pure/queue/rspec_pure'
85
86
 
86
87
  require 'knapsack_pro/railtie' if defined?(Rails::Railtie)
87
88
 
@@ -0,0 +1,80 @@
1
+ require 'knapsack_pro'
2
+ require 'json'
3
+
4
+ ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC'] = SecureRandom.hex
5
+ ENV['KNAPSACK_PRO_CI_NODE_BUILD_ID'] = SecureRandom.uuid
6
+ ENV['KNAPSACK_PRO_TEST_DIR'] = 'spec_integration'
7
+ ENV['KNAPSACK_PRO_TEST_FILE_PATTERN'] = "spec_integration/**{,/*/**}/*_spec.rb"
8
+
9
+ RSPEC_OPTIONS = ENV.fetch('TEST__RSPEC_OPTIONS')
10
+ SHOW_DEBUG_LOG = ENV['TEST__SHOW_DEBUG_LOG'] == 'true'
11
+ SPEC_BATCHES = JSON.load(ENV.fetch('TEST__SPEC_BATCHES'))
12
+
13
+ class IntegrationTestLogger
14
+ def self.log(message)
15
+ puts "[INTEGRATION TEST] #{message}"
16
+ end
17
+ end
18
+
19
+ module KnapsackProExtensions
20
+ module QueueAllocatorExtension
21
+ def test_file_paths(can_initialize_queue, executed_test_files)
22
+ @batch_index ||= 0
23
+ last_batch = []
24
+ batches = [*SPEC_BATCHES, last_batch]
25
+ tests = batches[@batch_index]
26
+ @batch_index += 1
27
+
28
+ if SHOW_DEBUG_LOG
29
+ IntegrationTestLogger.log("Mocked tests from the Queue API: #{tests.inspect}")
30
+ end
31
+
32
+ tests
33
+ end
34
+ end
35
+
36
+ module Report
37
+ def create_build_subset(test_files)
38
+ if ENV['TEST__LOG_EXECUTION_TIMES']
39
+ have_execution_time = test_files.all? { _1.fetch('time_execution') > 0 }
40
+ IntegrationTestLogger.log("test_files: #{test_files.size}, test files have execution time: #{have_execution_time}")
41
+ end
42
+
43
+ return unless SHOW_DEBUG_LOG
44
+ IntegrationTestLogger.log("Mocked the #{__method__} method")
45
+ end
46
+ end
47
+
48
+ module RSpecAdapter
49
+ def test_file_cases_for(slow_test_files)
50
+ IntegrationTestLogger.log("Mocked test file cases for slow test files: #{slow_test_files}")
51
+
52
+ test_file_paths = JSON.load(ENV.fetch('TEST__TEST_FILE_CASES_FOR_SLOW_TEST_FILES'))
53
+ test_file_paths.map do |path|
54
+ { 'path' => path }
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ KnapsackPro::QueueAllocator.prepend(KnapsackProExtensions::QueueAllocatorExtension)
61
+
62
+ module KnapsackPro
63
+ class Report
64
+ class << self
65
+ prepend KnapsackProExtensions::Report
66
+ end
67
+ end
68
+ end
69
+
70
+ module KnapsackPro
71
+ module Adapters
72
+ class RSpecAdapter
73
+ class << self
74
+ prepend KnapsackProExtensions::RSpecAdapter
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ KnapsackPro::Runners::Queue::RSpecRunner.run(RSPEC_OPTIONS)