diff --git a/.circleci/config.yml b/.circleci/config.yml index e4d323db..df793581 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,12 +25,16 @@ commands: type: string rspec: type: string + default: "" steps: - run: working_directory: << parameters.path >> command: | git clone --depth 1 --branch $CIRCLE_BRANCH --single-branch git@github.com:KnapsackPro/rails-app-with-knapsack_pro.git ./ || git clone --depth 1 git@github.com:KnapsackPro/rails-app-with-knapsack_pro.git ./ - sed -i 's/.*gem.*rspec-core.*/gem "rspec-core", "<< parameters.rspec >>"/g' ./Gemfile + 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-rails-{{ checksum "Gemfile.lock" }}-<< parameters.ruby >> @@ -59,8 +63,8 @@ jobs: - run: bundle exec rspec spec - run: bundle exec ruby spec/knapsack_pro/formatters/time_tracker_specs.rb - integration-regular: - parallelism: 4 + integration-regular-rspec: + parallelism: 2 working_directory: ~/knapsack_pro-ruby parameters: ruby: @@ -75,7 +79,7 @@ jobs: RAILS_ENV: test RACK_ENV: test KNAPSACK_PRO_ENDPOINT: https://api-staging.knapsackpro.com - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 3fa64859337f6e56409d49f865d13fd7 + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: $KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC EXTRA_TEST_FILES_DELAY: 10 - image: cimg/postgres:14.7 environment: @@ -119,13 +123,13 @@ jobs: export KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true bundle exec rake knapsack_pro:rspec - integration-queue: + integration-queue-rspec: parameters: ruby: type: string rspec: type: string - parallelism: 4 + parallelism: 2 working_directory: ~/knapsack_pro-ruby docker: - image: cimg/ruby:<< parameters.ruby >>-browsers @@ -135,7 +139,7 @@ jobs: RAILS_ENV: test RACK_ENV: test KNAPSACK_PRO_ENDPOINT: https://api-staging.knapsackpro.com - KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: 3fa64859337f6e56409d49f865d13fd7 + KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: $KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC EXTRA_TEST_FILES_DELAY: 10 - image: cimg/postgres:14.7 environment: @@ -212,19 +216,116 @@ jobs: export KNAPSACK_PRO_TEST_FILE_PATTERN="turnip/**/*.feature" bundle exec rake "knapsack_pro:queue:rspec[-r turnip/rspec]" + integration-regular-minitest: + parallelism: 2 + working_directory: ~/knapsack_pro-ruby + parameters: + ruby: + type: string + docker: + - image: cimg/ruby:<< parameters.ruby >>-browsers + environment: + PGHOST: 127.0.0.1 + PGUSER: rails-app-with-knapsack_pro + RAILS_ENV: test + RACK_ENV: test + KNAPSACK_PRO_ENDPOINT: https://api-staging.knapsackpro.com + KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST: $KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST + EXTRA_TEST_FILES_DELAY: 10 + - image: cimg/postgres:14.7 + environment: + POSTGRES_DB: rails-app-with-knapsack_pro_test + POSTGRES_PASSWORD: password + POSTGRES_USER: rails-app-with-knapsack_pro + steps: + - setup_knapsack_pro_ruby + - setup_rails_app_with_knapsack_pro: + path: ~/rails-app-with-knapsack_pro + ruby: << parameters.ruby >> + - run: dockerize -wait tcp://localhost:5432 -timeout 1m + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: ruby --version + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: bin/rails db:setup + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: | + export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--regular" + bundle exec rake knapsack_pro:minitest[--verbose] + + integration-queue-minitest: + parameters: + ruby: + type: string + parallelism: 2 + working_directory: ~/knapsack_pro-ruby + docker: + - image: cimg/ruby:<< parameters.ruby >>-browsers + environment: + PGHOST: 127.0.0.1 + PGUSER: rails-app-with-knapsack_pro + RAILS_ENV: test + RACK_ENV: test + KNAPSACK_PRO_ENDPOINT: https://api-staging.knapsackpro.com + KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST: $KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST + EXTRA_TEST_FILES_DELAY: 10 + - image: cimg/postgres:14.7 + environment: + POSTGRES_DB: rails-app-with-knapsack_pro_test + POSTGRES_PASSWORD: password + POSTGRES_USER: rails-app-with-knapsack_pro + steps: + - setup_knapsack_pro_ruby + - setup_rails_app_with_knapsack_pro: + path: ~/rails-app-with-knapsack_pro + ruby: << parameters.ruby >> + - run: dockerize -wait tcp://localhost:5432 -timeout 1m + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: ruby --version + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: bin/rails db:setup + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: | + # minitest || + export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--queue--minitest" + export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true + bundle exec rake knapsack_pro:queue:minitest[--verbose] + - run: + working_directory: ~/rails-app-with-knapsack_pro + command: | + # minitest retry || + export KNAPSACK_PRO_BRANCH="$CIRCLE_BRANCH--$CIRCLE_BUILD_NUM--queue--minitest" + export KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true + bundle exec rake knapsack_pro:queue:minitest[--verbose] + workflows: tests: jobs: - unit - - integration-regular: + - integration-regular-rspec: name: integration-regular__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >> matrix: parameters: ruby: ["3.0", "3.1", "3.2"] rspec: ["3.10.2", "3.11.0", "3.12.2"] - - integration-queue: + - integration-queue-rspec: name: integration-queue__ruby-<< matrix.ruby >>__rspec-<< matrix.rspec >> matrix: parameters: ruby: ["3.0", "3.1", "3.2"] rspec: ["3.10.2", "3.11.0", "3.12.2"] + - integration-regular-minitest: + name: integration-regular__ruby-<< matrix.ruby >>__minitest + matrix: + parameters: + ruby: ["3.0", "3.1", "3.2"] + - integration-queue-minitest: + name: integration-queue__ruby-<< matrix.ruby >>__minitest + matrix: + parameters: + ruby: ["3.0", "3.1", "3.2"] diff --git a/CHANGELOG.md b/CHANGELOG.md index a21d9010..4c4985d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### Unreleased (patch) + +* fix(minitest): avoid installing `at_exit` (that would result in an empty run of Minitest after Knapsack Pro is finished in Queue Mode) + ### 6.0.3 * fix(Turnip): make sure `.feature` files are recorded diff --git a/lib/knapsack_pro/runners/queue/minitest_runner.rb b/lib/knapsack_pro/runners/queue/minitest_runner.rb index bee7e370..cf66db52 100644 --- a/lib/knapsack_pro/runners/queue/minitest_runner.rb +++ b/lib/knapsack_pro/runners/queue/minitest_runner.rb @@ -7,6 +7,10 @@ class MinitestRunner < BaseRunner def self.run(args) require 'minitest' + # Avoid installing `at_exit` since we are calling `Minitest.run` ourselves. + # Without this, Minitest would run again (autorun) after `Minitest.run`. + ::Minitest.class_variable_set('@@installed_at_exit', true) + ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_minitest ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true' ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id