Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop calling RSpec::Core::Runner#run multiple times in Queue Mode #237

Merged
merged 405 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
405 commits
Select commit Hold shift + click to select a range
f852836
update(CI): rename integration tests on CI to e2e tests
ArturT Jan 26, 2024
74785b1
fix(time tracker): when RSpec crashes and @time_all is nil
ArturT Jan 29, 2024
0775e61
[wip] queue rspec runner integration test
ArturT Jan 29, 2024
5736b44
refactor(rspec integration tests): run queue mode integration tests f…
ArturT Jan 29, 2024
9d8df3f
refactor: log command
ArturT Jan 29, 2024
9b2f938
fix: batch tests
ArturT Jan 29, 2024
ac1801c
refactor: let specify the spec path name
ArturT Jan 29, 2024
d65b7dd
Update rspec_runner_spec.rb
ArturT Jan 29, 2024
7ff341d
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
3e1ba77
Update queue_runner.rb
ArturT Jan 30, 2024
a65850c
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
97c90cb
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
a82afd8
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
7ad07e0
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
0fa7e18
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
1557a60
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
0bbd561
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
afd7dad
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
1a36178
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
58662da
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
bf898fa
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
2dd2170
move a test up
ArturT Jan 30, 2024
1927806
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
3189b23
fix(bug): returns 1 as exit code because RSpec wants to quit and exit…
ArturT Jan 30, 2024
91015fc
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
eb7748d
Update rspec_runner_spec.rb
ArturT Jan 30, 2024
bfd3e5f
fix(flaky spec): when spec_helper.rb has a missing KnapsackPro::Adapt…
ArturT Jan 30, 2024
5de2e0c
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
bc610c7
Update rspec_runner.rb
ArturT Jan 31, 2024
0ce9d99
Update rspec_runner.rb
ArturT Jan 31, 2024
1d8b5ac
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
f3aab29
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
0abd0ea
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
fd4b85e
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
e450710
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
71a62ec
Update CHANGELOG.md
ArturT Jan 31, 2024
46ffaf3
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
5c43940
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
afd42bf
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
27ee506
feat: does not log copy&paste command when no test file paths returne…
ArturT Jan 31, 2024
cf101bf
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
d0ce1ec
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
7fe320d
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
8198180
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
b3fc00f
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
eab8c29
Update rspec_runner_spec.rb
ArturT Jan 31, 2024
b081a72
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
3c5ef82
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
7281394
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
24f0973
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
7732a66
wip: mock build_distributions#last API endpoint
ArturT Feb 1, 2024
590129a
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
e372532
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
7d0981e
Update queue_runner.rb
ArturT Feb 1, 2024
043de31
update(CI): split custom files by examples to ensure the rake task to…
ArturT Feb 1, 2024
4f85f5a
add spec for the RSpec split by test examples
ArturT Feb 1, 2024
f8666b7
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
2552d2f
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
7c5791f
detects test execution times correctly before sending it to API
ArturT Feb 1, 2024
1823b15
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
0974d8d
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
220771a
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
8600be7
add junit xml test
ArturT Feb 1, 2024
5e5c7c0
Update Gemfile
ArturT Feb 1, 2024
fa47cf6
test when the RSpec split by examples is enabled AND simplecov is used
ArturT Feb 1, 2024
c4e2094
Update rspec_runner_spec.rb
ArturT Feb 1, 2024
348f563
remove MOCK_QUEUE_API_RESPONSE
ArturT Feb 1, 2024
885241b
call call_after_subset_queue after tests and before we log info about…
ArturT Feb 2, 2024
bc2c9d7
calls hooks defined with when_first_matching_example_defined only onc…
ArturT Feb 2, 2024
40a4eba
Update rspec_runner_spec.rb
ArturT Feb 2, 2024
34500b2
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
dfab644
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
1fee46e
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
ae4211e
Create .gitignore
ArturT Feb 5, 2024
8bba777
ignore dynamically generated specs for time tracker
ArturT Feb 5, 2024
b774375
Update CHANGELOG.md
ArturT Feb 5, 2024
8d1e02f
Update CHANGELOG.md
ArturT Feb 5, 2024
3f4b100
Update CHANGELOG.md
ArturT Feb 5, 2024
ba8e756
Update CHANGELOG.md
ArturT Feb 5, 2024
a6ec3d5
Update .gitignore
ArturT Feb 5, 2024
f3a85ea
fix(bug): add support for the example_status_persistence_file_path op…
ArturT Feb 5, 2024
1b2675a
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
3f64a7a
Update rspec_adapter.rb
ArturT Feb 5, 2024
5937e9a
Update rspec_extension.rb
ArturT Feb 5, 2024
eb78cdb
Update rspec_extension.rb
ArturT Feb 5, 2024
b9df226
Update rspec_extension.rb
ArturT Feb 5, 2024
c83d2bf
Update rspec_extension.rb
ArturT Feb 5, 2024
fdb1258
Update rspec_extension.rb
ArturT Feb 5, 2024
15e12ae
Update rspec_extension.rb
ArturT Feb 5, 2024
4796be1
Update rspec_runner.rb
ArturT Feb 5, 2024
4771d8c
Update rspec_runner.rb
ArturT Feb 5, 2024
997deec
rename method to set_error_exit_code
ArturT Feb 5, 2024
070c72d
typo
ArturT Feb 5, 2024
667ef03
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
ebf15fc
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
e362390
rename method ensure_args_have_a_formatter
ArturT Feb 5, 2024
3778a34
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
d616591
move KNAPSACK_PRO_TEST_FILE_PATTERN where it belongs
ArturT Feb 5, 2024
b887b6d
Update queue_runner.rb
ArturT Feb 5, 2024
394baff
Update queue_runner.rb
ArturT Feb 5, 2024
e759675
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
73f04a5
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
a88e761
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
bfcab69
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
a2ba136
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
f245738
Update rspec_runner_spec.rb
ArturT Feb 5, 2024
06a1f9d
Update spec_integration/queue_runner.rb
ArturT Feb 6, 2024
7c782a8
refactor: use the same order of blocks as in the original RSpec code
ArturT Feb 6, 2024
448861c
remove unused exit_status
ArturT Feb 6, 2024
488b096
shows summary of tests (pending + failures) for terminated process as…
ArturT Feb 6, 2024
9543f64
make it alphabetically ordered
ArturT Feb 6, 2024
6f63619
Update lib/knapsack_pro/extensions/rspec_extension.rb
ArturT Feb 6, 2024
03b542c
Update lib/knapsack_pro/extensions/rspec_extension.rb
ArturT Feb 6, 2024
d462898
refactor: inline to_cli_args and remove spec
ArturT Feb 6, 2024
f7e2550
Merge branch 'refactor-queue-rspec-runner' of github.com:KnapsackPro/…
ArturT Feb 6, 2024
cee9bb7
Update spec/knapsack_pro/runners/queue/cucumber_runner_spec.rb
ArturT Feb 6, 2024
5ad48f8
Update spec_integration/queue_runner.rb
ArturT Feb 9, 2024
ad26e2c
remove bind hooks tests that are tested in integration tests
ArturT Feb 9, 2024
75e5dc8
fix(time_tracker)
3v0k4 Feb 7, 2024
0b7f72d
test(time_tracker): let ruby remove files
3v0k4 Feb 7, 2024
dcb6afb
fix(flaky spec): when time_tracker is nil then do not print global ti…
ArturT Feb 9, 2024
de611f7
fix(flaky spec): when TimeTracker calls the after_subset_queue hook t…
ArturT Feb 9, 2024
ca22567
update(spec): remove KNAPSACK_PRO_LOG_LEVEL=info when it's not needed…
ArturT Feb 9, 2024
37c3213
Revert "update(spec): remove KNAPSACK_PRO_LOG_LEVEL=info when it's no…
ArturT Feb 9, 2024
86aa4c4
Update spec_integration/queue_runner.rb
ArturT Feb 9, 2024
b993c8c
refactor: ivar @batch_index
ArturT Feb 9, 2024
7a3aee1
refactor: add [INTEGRATION TEST] prefix to logs from mocked methods
ArturT Feb 9, 2024
78e52a2
refactor: api token does not have a meaning in tests
ArturT Feb 9, 2024
b72542f
refactor: remove ivar @knapsack__setup_done and related code
ArturT Feb 9, 2024
e9066df
update required_ruby_version in gemspec and update readme
ArturT Feb 9, 2024
133bd18
remove comment for `rspec_is_quitting` was added in RSpec 3.11.0
ArturT Feb 9, 2024
278638a
refactor: remove _default = nil and add comment
ArturT Feb 9, 2024
fa5949a
refactor: rename node_assigned_test_file_paths to node_test_file_paths
ArturT Feb 9, 2024
eb83d07
ignore dynamically generated time tracker specs
ArturT Feb 9, 2024
0a9d6b8
keep gitignore entries in one file
ArturT Feb 9, 2024
642d661
refactor(spec): not to raise error
ArturT Feb 9, 2024
661f86e
update(spec): returns no spec_opts
ArturT Feb 9, 2024
32d7766
use spec_opts name
ArturT Feb 9, 2024
1b331ee
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 9, 2024
b78d53b
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 9, 2024
3932a7a
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 9, 2024
50ea747
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 9, 2024
0152020
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 9, 2024
a3fcfdb
remove copy & paste term
ArturT Feb 9, 2024
f3b6a94
update(gemspec description): be precise about test execution times
ArturT Feb 12, 2024
f480c96
Update lib/knapsack_pro/runners/queue/rspec_runner.rb
ArturT Feb 12, 2024
2340dc1
Update lib/knapsack_pro/runners/queue/rspec_runner.rb
ArturT Feb 12, 2024
682c400
refactor: move side effect outside of set_error_exit_code and rename …
ArturT Feb 12, 2024
05398b7
refactor: inject adapter_class
ArturT Feb 12, 2024
1cacb88
remove comments for args_with_seed_option_added_when_viable
ArturT Feb 12, 2024
e426099
rename wrapped_test_file_paths to test_file_paths
ArturT Feb 12, 2024
ccfa75f
fix typo function_core => functional_core
ArturT Feb 12, 2024
424eebf
update(comment): add why in comments
ArturT Feb 13, 2024
9e73e09
refactor: extract knapsack__announce_filters
ArturT Feb 13, 2024
07ef604
refactor: rename with_batched_tests_from_queue to with_batch
ArturT Feb 13, 2024
c0e8745
refactor: remove with_queue_hooks and extract log_batch_rspec_command…
ArturT Feb 14, 2024
8c155fa
refactor: inject KnapsackPro::Adapters::RSpecAdapter in test
ArturT Feb 14, 2024
eef6ea8
refactor: log rspec batch and queue commands
ArturT Feb 14, 2024
76a3774
Update spec/knapsack_pro/runners/queue/rspec_runner_spec.rb
ArturT Feb 14, 2024
b49a49a
refactor(spec): inject KnapsackPro::Formatters::TimeTrackerFetcher
ArturT Feb 14, 2024
f041ebe
update(text): Global test execution duration
ArturT Feb 14, 2024
1267eb1
refactor: log tests duration only once at the very end of the queue
ArturT Feb 14, 2024
50e94af
refactor: extract bind_after_queue_hook to base adapter
ArturT Feb 14, 2024
5cd2dd4
update(log message): show queue/regular mode name and improve english
ArturT Feb 14, 2024
a4ccd51
refactor: ensure_no_deprecated_run_all_when_everything_filtered_option!
ArturT Feb 14, 2024
934e682
refactor: move logger outside of log_rspec_command
ArturT Feb 14, 2024
bf44952
refactor: log_fail_fast_limit_met is already tested in integration te…
ArturT Feb 14, 2024
a56d634
refactor: rspec_command
ArturT Feb 14, 2024
8538cff
refactor: extract logger from exit_summary
ArturT Feb 14, 2024
6ff45b6
refactor: remove unneeded return. Kernel.exit will terminate immediat…
ArturT Feb 14, 2024
fcf9899
refactor: add_knapsack_pro_formatters_to
ArturT Feb 15, 2024
e3041ba
refactor: args_with_at_least_one_formatter
ArturT Feb 15, 2024
9819647
refactor: extract prepare_cli_args to core
ArturT Feb 15, 2024
4e75264
refactor: extract seed (remove data clump)
ArturT Feb 15, 2024
0b01bf1
Update rspec_extension.rb
ArturT Feb 15, 2024
ffd5fa5
fix: use injected time_tracker_fetcher
ArturT Feb 15, 2024
71381ac
Create pull_request_template.md
ArturT Feb 15, 2024
912d194
refactor: extract queue rspec pure functions
ArturT Feb 15, 2024
3346349
Update pull_request_template.md
ArturT Feb 15, 2024
60a26f6
refactor: move spec_integration/queue_runner.rb to spec directory
ArturT Feb 15, 2024
307c5f7
refactor: clean up the spec_integration directory after tests execution
ArturT Feb 15, 2024
2aa2013
refactor: move queue runner to integration directory
ArturT Feb 15, 2024
7e98eee
refactor: use actual instead of result in tests
ArturT Feb 15, 2024
38a02c2
refactor: spec item in less lines
ArturT Feb 16, 2024
c657eac
refactor(spec): mock batched tests only when needed for test cases
ArturT Feb 16, 2024
8b2bcc1
Update rspec_runner_spec.rb
ArturT Feb 16, 2024
b715296
add(spec): when the .rspec file has RSpec options
ArturT Feb 16, 2024
18b11c9
add(spec): when --options is set
ArturT Feb 16, 2024
903536a
Update rspec_runner.rb
ArturT Feb 19, 2024
f34a2a1
feat: The default for `KNAPSACK_PRO_LOG_LEVEL` is `info` instead of `…
ArturT Feb 19, 2024
3a15925
update(CI): do not reinstall gems and cache when rspec version change…
ArturT Feb 19, 2024
0f2ef6e
update(CI): cache gems separately for different rspec versions
ArturT Feb 19, 2024
7dac15e
Just empty commit
ArturT Feb 19, 2024
79957bb
update(CI): add integration-rspec tests on CI for different versions …
ArturT Feb 19, 2024
9942459
update(Gemfile): add an example rspec-core line in Gemfile so that we…
ArturT Feb 19, 2024
f002c64
fix(tests): fix tests that have different error messages depending on…
ArturT Feb 19, 2024
3c01fd6
fix(spec): fix spec for different ruby version on CI
ArturT Feb 19, 2024
49de3c6
fix(spec): fix a flaky tests when spec integration directory is not c…
ArturT Feb 19, 2024
a5638d2
skip test that is not supported by RSpec 3.10.2
ArturT Feb 19, 2024
90ff153
remove world.respond_to?(:rspec_is_quitting) - will CI tests detect t…
ArturT Feb 19, 2024
c35b19e
Revert "remove world.respond_to?(:rspec_is_quitting) - will CI tests …
ArturT Feb 19, 2024
229869b
try to reproduce the issue: https://github.com/KnapsackPro/knapsack_p…
ArturT Feb 19, 2024
003a57e
Revert "try to reproduce the issue: https://github.com/KnapsackPro/kn…
ArturT Feb 19, 2024
30381bd
Update .github/pull_request_template.md
ArturT Feb 22, 2024
9b15817
Update .github/pull_request_template.md
ArturT Feb 22, 2024
e8bd38d
Update knapsack_pro.gemspec
ArturT Feb 22, 2024
3e57cce
Update CHANGELOG.md
ArturT Feb 22, 2024
12ca719
Update CHANGELOG.md
ArturT Feb 22, 2024
3c628d3
Update lib/knapsack_pro/extensions/rspec_extension.rb
ArturT Feb 22, 2024
526e965
Update CHANGELOG.md
ArturT Feb 22, 2024
cb15413
Update CHANGELOG.md
ArturT Feb 22, 2024
03d633f
Update CHANGELOG.md
ArturT Feb 22, 2024
8dfa7a7
Update spec/integration/runners/queue/rspec_runner.rb
ArturT Feb 22, 2024
7de6567
Update lib/knapsack_pro/pure/queue/rspec_pure.rb
ArturT Feb 22, 2024
6f48966
Update spec/knapsack_pro/hooks/queue_spec.rb
ArturT Feb 22, 2024
f231aa9
require at the top and add parenthesis
ArturT Feb 22, 2024
381164c
refactor: rename SpecItem to Spec
ArturT Feb 22, 2024
53b680a
rename spec_helper_content to spec_helper
ArturT Feb 22, 2024
0b3a0ee
refactor: use spec_batches and TEST__SPEC_BATCHES
ArturT Feb 22, 2024
ebe95b8
Update spec/integration/runners/queue/rspec_runner_spec.rb
ArturT Feb 22, 2024
7d1df77
refactor: stub_spec_batches
ArturT Feb 22, 2024
855c304
Update CHANGELOG.md
ArturT Feb 22, 2024
37c67f5
Update CHANGELOG.md
ArturT Feb 22, 2024
7a42ad3
Update CHANGELOG.md
ArturT Feb 22, 2024
41c0f32
is
ArturT Feb 22, 2024
03220b0
Update CHANGELOG.md
ArturT Feb 22, 2024
00f9ce0
Update CHANGELOG.md
ArturT Feb 22, 2024
dcea7c0
update(comment): Facade to abstract calls to internal RSpec methods.
ArturT Feb 22, 2024
a85d795
Merge branch 'refactor-queue-rspec-runner' of github.com:KnapsackPro/…
ArturT Feb 22, 2024
257e2cf
Update CHANGELOG.md
ArturT Feb 22, 2024
1df2375
Update CHANGELOG.md
ArturT Feb 22, 2024
b4a1b9b
Update CHANGELOG.md
ArturT Feb 22, 2024
b41daf5
Update CHANGELOG.md
ArturT Feb 22, 2024
5341b89
Update CHANGELOG.md
ArturT Feb 22, 2024
6bddc5e
Update CHANGELOG.md
ArturT Feb 22, 2024
f17699c
update(changelog): add link to KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORM…
ArturT Feb 22, 2024
d31a4ff
Update CHANGELOG.md
ArturT Feb 22, 2024
e797f1c
Update CHANGELOG.md
ArturT Feb 22, 2024
3eeaa1f
refactor: define only seed in spec
ArturT Feb 22, 2024
986fc02
Merge branch 'refactor-queue-rspec-runner' of github.com:KnapsackPro/…
ArturT Feb 22, 2024
77db883
Update queue_spec.rb
ArturT Feb 22, 2024
150bb1f
refactor: remove the indentation and yield
ArturT Feb 22, 2024
64ddfab
refactor: change a logger message when a given mode is enabled
ArturT Feb 22, 2024
94442e0
Update rspec_runner.rb
ArturT Feb 22, 2024
027b5c9
Update rspec_pure_spec.rb
ArturT Feb 22, 2024
9f4814e
refactor: remove adapter class dependency from RSpecPure
ArturT Feb 22, 2024
0dfc8e8
refactor: remove time tracker as RSpecPure dependency
ArturT Feb 22, 2024
1689bfa
refactor: extract unexecuted_test_files
ArturT Feb 22, 2024
1482a5f
refactor: add test for unexecuted_test_files to ensure we cover case …
ArturT Feb 22, 2024
1ccadf5
Update lib/knapsack_pro/extensions/rspec_extension.rb
ArturT Feb 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 75 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ commands:
fi
- restore_cache:
keys:
- v1-bundler-rails-{{ checksum "Gemfile.lock" }}-<< parameters.ruby >>
- v1-bundler-rails-{{ checksum "Gemfile.lock" }}-ruby-<< parameters.ruby >>-rspec-<< parameters.rspec >>
- v1-bundler-rails-{{ checksum "Gemfile.lock" }}-ruby-<< parameters.ruby >>-
- v1-bundler-rails-{{ checksum "Gemfile.lock" }}-
- v1-bundler-rails-
- run:
Expand All @@ -48,12 +49,13 @@ commands:
- save_cache:
paths:
- << parameters.path >>/vendor/bundle
key: v1-bundler-rails-{{ checksum "Gemfile.lock" }}-<< parameters.ruby >>
key: v1-bundler-rails-{{ checksum "Gemfile.lock" }}-ruby-<< parameters.ruby >>-rspec-<< parameters.rspec >>

jobs:
unit:
parallelism: 1
working_directory: ~/knapsack_pro-ruby
resource_class: small
docker:
- image: cimg/ruby:3.2
steps:
Expand All @@ -63,9 +65,51 @@ jobs:
- run: bundle exec rspec spec
- run: bundle exec ruby spec/knapsack_pro/formatters/time_tracker_specs.rb

integration-regular-rspec:
integration-rspec:
parallelism: 1
working_directory: ~/knapsack_pro-ruby
resource_class: small
parameters:
ruby:
type: string
rspec:
type: string
docker:
- image: cimg/ruby:<< parameters.ruby >>
steps:
- checkout
- run:
command: |
if [[ "<< parameters.rspec >>" != "" ]]; then
sed -i 's/.*gem.*rspec-core.*/gem "rspec-core", "<< parameters.rspec >>"/g' ./Gemfile
echo "Updated RSpec version in Gemfile"
fi
- restore_cache:
keys:
- v1-bundler-gem-{{ checksum "knapsack_pro.gemspec" }}-ruby-<< parameters.ruby >>-rspec-<< parameters.rspec >>
- v1-bundler-gem-{{ checksum "knapsack_pro.gemspec" }}-ruby-<< parameters.ruby >>-
- v1-bundler-gem-{{ checksum "knapsack_pro.gemspec" }}-
- v1-bundler-gem-
- run:
command: |
bundle config set --local path './vendor/bundle'
bundle install --jobs=4 --retry=3
- save_cache:
paths:
- ./vendor/bundle
key: v1-bundler-gem-{{ checksum "knapsack_pro.gemspec" }}-ruby-<< parameters.ruby >>-rspec-<< parameters.rspec >>
- run:
command: |
ruby --version
bundle exec rspec --version
RSPEC=$(bundle exec rspec --version | grep rspec-core | head -n1 | cut -d " " -f5)
[ $RSPEC != << parameters.rspec >> ] && exit 1 || echo "Correct version of RSpec installed: $RSPEC"
- run: bundle exec rspec spec/integration/runners/queue/rspec_runner_spec.rb

e2e-regular-rspec:
parallelism: 2
working_directory: ~/knapsack_pro-ruby
resource_class: small
parameters:
ruby:
type: string
Expand Down Expand Up @@ -122,15 +166,24 @@ jobs:
export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--regular--split"
export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
bundle exec rake knapsack_pro:rspec
- run:
working_directory: ~/rails-app-with-knapsack_pro
command: |
# split custom files by test examples ||
export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--regular--split-custom-files"
export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true
export KNAPSACK_PRO_SLOW_TEST_FILE_PATTERN="spec/features/calculator_spec.rb"
bundle exec rake knapsack_pro:rspec

integration-queue-rspec:
e2e-queue-rspec:
parameters:
ruby:
type: string
rspec:
type: string
parallelism: 2
working_directory: ~/knapsack_pro-ruby
resource_class: small
docker:
- image: cimg/ruby:<< parameters.ruby >>-browsers
environment:
Expand Down Expand Up @@ -216,9 +269,10 @@ jobs:
export KNAPSACK_PRO_TEST_FILE_PATTERN="turnip/**/*.feature"
bundle exec rake "knapsack_pro:queue:rspec[-r turnip/rspec]"

integration-regular-minitest:
e2e-regular-minitest:
parallelism: 2
working_directory: ~/knapsack_pro-ruby
resource_class: small
parameters:
ruby:
type: string
Expand Down Expand Up @@ -255,12 +309,13 @@ jobs:
export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--regular"
bundle exec rake knapsack_pro:minitest[--verbose]

integration-queue-minitest:
e2e-queue-minitest:
parameters:
ruby:
type: string
parallelism: 2
working_directory: ~/knapsack_pro-ruby
resource_class: small
docker:
- image: cimg/ruby:<< parameters.ruby >>-browsers
environment:
Expand Down Expand Up @@ -307,25 +362,31 @@ workflows:
tests:
jobs:
- unit
- integration-regular-rspec:
name: integration-regular__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
- integration-rspec:
name: integration__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
matrix:
parameters:
ruby: ["3.0", "3.1", "3.2", "3.3"]
rspec: ["3.10.2", "3.11.0", "3.12.2"]
- e2e-regular-rspec:
name: e2e-regular__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
matrix:
parameters:
ruby: ["3.0", "3.1", "3.2", "3.3"]
rspec: ["3.10.2", "3.11.0", "3.12.2"]
- integration-queue-rspec:
name: integration-queue__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
- e2e-queue-rspec:
name: e2e-queue__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >>
matrix:
parameters:
ruby: ["3.0", "3.1", "3.2", "3.3"]
rspec: ["3.10.2", "3.11.0", "3.12.2"]
- integration-regular-minitest:
name: integration-regular__ruby-<< matrix.ruby >>__minitest
- e2e-regular-minitest:
name: e2e-regular__ruby-<< matrix.ruby >>__minitest
matrix:
parameters:
ruby: ["3.0", "3.1", "3.2", "3.3"]
- integration-queue-minitest:
name: integration-queue__ruby-<< matrix.ruby >>__minitest
- e2e-queue-minitest:
name: e2e-queue__ruby-<< matrix.ruby >>__minitest
matrix:
parameters:
ruby: ["3.0", "3.1", "3.2", "3.3"]
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Story

TODO: link to the internal story

## Related

TODO: links to related PRs or issues

# Description

TODO

# Changes

TODO: changes introduced by this PR

# Checklist reminder

- [ ] You follow the architecture outlined below for RSpec in Queue Mode, which is a work in progress (feel free to propose changes):
- Pure: `lib/knapsack_pro/pure/queue/rspec_pure.rb` contains pure functions that are unit tested.
- Extension: `lib/knapsack_pro/extensions/rspec_extension.rb` encapsulates calls to RSpec internals and is integration and e2e tested.
- Runner: `lib/knapsack_pro/runners/queue/rspec_runner.rb` invokes the pure code and the extension to produce side effects, which are integration and e2e tested.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Gemfile.lock

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# dynamically generated specs
spec/knapsack_pro/formatters/time_tracker*_spec.rb
spec_integration/
87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,92 @@
# Changelog

### 7.0.0

* __(breaking change)__ RSpec in Queue Mode:
* The default for `KNAPSACK_PRO_LOG_LEVEL` is `info` instead of `debug`.
* The RSpec `before(:suite)` and `after(:suite)` hooks changed:

__Before:__<br>
The `before(:suite)` and `after(:suite)` hooks were executed multiple times. Each time for a batch of tests fetched from Knapsack Pro Queue API.

__After:__<br>
The `before(:suite)` and `after(:suite)` hooks are executed only once: `before(:suite)` is executed before starting tests, `after(:suite)` is executed after all tests are completed. (It is what you would expect from RSpec).

* The `KnapsackPro::Hooks::Queue.after_queue` hook change:

__Before:__<br>
The `KnapsackPro::Hooks::Queue.after_queue` hook is executed outside of the `after(:suite)` hook.

__After:__<br>
The `KnapsackPro::Hooks::Queue.after_queue` hook is executed __inside__ of the `after(:suite)` hook.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the consequences? Do we want to document them here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the past, I really wanted to call KnapsackPro::Hooks::Queue.after_queue inside of the after(:suite) hook, but it was impossible to know which batch is the final one. You know that after you execute the previous batch. So it is too late to run a hook if all tests are already executed. It must have been called outside of the after(:suite) context.

Now, there is no problem like that, and we can do what should be working from the very beginning. The KnapsackPro::Hooks::Queue.after_queue hook should be run within the after(:suite) context.

I don't think we can add anything useful here. Users simply get now access to the RSpec context within the KnapsackPro::Hooks::Queue.after_queue hook, which was not possible before.


* Recommended RSpec changes in your project:
* Remove the following code if you use Queue Mode and the `rspec_junit_formatter` gem to generate JUnit XML or JSON reports:

```ruby
# REMOVE THE FOLLOWING CODE
ArturT marked this conversation as resolved.
Show resolved Hide resolved

# spec_helper.rb or rails_helper.rb
TMP_REPORT = "tmp/rspec_#{ENV['KNAPSACK_PRO_CI_NODE_INDEX']}.xml"
FINAL_REPORT = "tmp/final_rspec_#{ENV['KNAPSACK_PRO_CI_NODE_INDEX']}.xml"

KnapsackPro::Hooks::Queue.after_subset_queue do |queue_id, subset_queue_id|
if File.exist?(TMP_REPORT)
FileUtils.mv(TMP_REPORT, FINAL_REPORT)
end
end
```

Learn more about [using Knapsack Pro with RSpec formatters](https://docs.knapsackpro.com/ruby/rspec/#formatters-rspec_junit_formatter-json) and [using Knapsack Pro with CircleCI](https://docs.knapsackpro.com/ruby/circleci/) in the docs.

* Replace the following code if you are using Queue Mode and the `percy-capybara` gem on a version older than 4:

Before:

```ruby
KnapsackPro::Hooks::Queue.before_queue { |queue_id| Percy::Capybara.initialize_build }
KnapsackPro::Hooks::Queue.after_queue { |queue_id| Percy::Capybara.finalize_build }
```

After:

```ruby
# recommended
before(:suite) { Percy::Capybara.initialize_build }
after(:suite) { Percy::Capybara.finalize_build }
```

Learn more about [using Knapsack Pro with Percy](https://docs.knapsackpro.com/ruby/hooks/#percy-capybara) in the docs.

* We are no longer modifying the default RSpec formatters in Queue Mode. You can remove the [`KNAPSACK_PRO_MODIFY_DEFAULT_RSPEC_FORMATTERS`](https://docs.knapsackpro.com/ruby/reference/#knapsack_pro_modify_default_rspec_formatters-removed-rspec) environment variable from your CI config if you are using it.

* RSpec improvements in Queue Mode:
* Termination signals (`HUP`, `INT`, `TERM`, `ABRT`, `QUIT`, `USR1`, and `USR2`) are handled earlier: the process will terminate before the next top-level example group (`describe` or `context`) instead of waiting for the next Knapsack Pro batch of tests.

* Respect the `--error-exit-code` option. It sets a custom exit code (instead of `1`) when RSpec fails outside an example (e.g. lack of memory, termination signal).

```bash
bundle exec rake "knapsack_pro:queue:rspec[--error-exit-code 3]"
```

* Respect the `--failure-exit-code` option. It sets a custom exit code for when any examples fail.

```bash
bundle exec rake "knapsack_pro:queue:rspec[--failure-exit-code 2]"
```

* Respect the `--fail-fast` option and show a warning in the Knapsack Pro log.

* Ignore the `fail_if_no_examples` option in Queue Mode:
* A late CI node, started after all tests were executed by other nodes, is expected to receive an empty batch.
* A batch could contain tests with no examples (e.g. commented out)

* Raise an exception if the [deprecated `run_all_when_everything_filtered`](https://docs.knapsackpro.com/ruby/rspec/#some-of-my-test-files-are-not-executed) option is detected.

PR with the above changes: https://github.com/KnapsackPro/knapsack_pro-ruby/pull/237

https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v6.0.4...v7.0.0

### 6.0.4

* fix(minitest): avoid installing `at_exit` (that would result in an empty run of Minitest after Knapsack Pro is finished in Queue Mode)
Expand Down
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,12 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in knapsack.gemspec
gemspec

group :test do
gem 'rspec_junit_formatter', require: false
gem 'nokogiri', require: false
gem 'simplecov', require: false

# This line is going to be replaced on CI to test different RSpec versions.
# gem 'rspec-core', 'x.x.x'
end
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ The `knapsack_pro` gem supports all CIs and the following test runners:
- Spinach
- Turnip

## Requirements

`>= Ruby 2.1.0`

## Installation

The [Installation Guide](https://docs.knapsackpro.com/knapsack_pro-ruby/guide/?utm_source=github&utm_medium=readme&utm_campaign=knapsack_pro-ruby_gem&utm_content=installation_guide) will ask you a few questions and generate instruction steps for your project:
Expand Down
3 changes: 2 additions & 1 deletion knapsack_pro.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ require 'knapsack_pro/version'
Gem::Specification.new do |spec|
spec.name = 'knapsack_pro'
spec.version = KnapsackPro::VERSION
spec.required_ruby_version = '>= 2.7.0'
spec.authors = ['ArturT']
spec.email = ['support@knapsackpro.com']
spec.summary = %q{Knapsack Pro splits tests across parallel CI nodes and ensures each parallel job finish work at a similar time.}
spec.description = %q{Run tests in parallel across CI server nodes based on tests execution time. Split tests in a dynamic way to ensure parallel jobs are done at a similar time. Thanks to that your CI build time is as fast as possible. It works with many CI providers.}
spec.description = %q{Knapsack Pro wraps your current test runner(s) and works with your existing CI infrastructure to parallelize tests optimally. It dynamically splits your tests based on up-to-date test execution data. It's designed from the ground up for CI and supports all of them.}
spec.homepage = 'https://knapsackpro.com'
spec.license = 'MIT'
spec.metadata = {
Expand Down
1 change: 1 addition & 0 deletions lib/knapsack_pro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
require_relative 'knapsack_pro/crypto/branch_encryptor'
require_relative 'knapsack_pro/crypto/decryptor'
require_relative 'knapsack_pro/crypto/digestor'
require_relative 'knapsack_pro/pure/queue/rspec_pure'

require 'knapsack_pro/railtie' if defined?(Rails::Railtie)

Expand Down
9 changes: 7 additions & 2 deletions lib/knapsack_pro/adapters/base_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ def bind
File.write(self.class.adapter_bind_method_called_file, nil)

if KnapsackPro::Config::Env.recording_enabled?
KnapsackPro.logger.debug('Test suite time execution recording enabled.')
KnapsackPro.logger.debug('Regular Mode enabled.')
bind_time_tracker
bind_save_report
end

if KnapsackPro::Config::Env.queue_recording_enabled?
KnapsackPro.logger.debug('Test suite time execution queue recording enabled.')
KnapsackPro.logger.debug('Queue Mode enabled.')
bind_queue_mode
end
end
Expand All @@ -83,8 +83,13 @@ def bind_before_queue_hook
raise NotImplementedError
end

def bind_after_queue_hook
raise NotImplementedError
end

def bind_queue_mode
bind_before_queue_hook
bind_after_queue_hook
bind_time_tracker
end
end
Expand Down
4 changes: 1 addition & 3 deletions lib/knapsack_pro/adapters/cucumber_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def bind_before_queue_hook
end
end

def bind_queue_mode
super

def bind_after_queue_hook
::Kernel.at_exit do
KnapsackPro::Hooks::Queue.call_after_subset_queue
KnapsackPro::Report.save_subset_queue_to_file
Expand Down
Loading