Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
119 changes: 110 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 >>
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You are adding Minitest steps to the jobs that are supposed to be testing the matrix of Ruby & RSpec versions.

I think we could make it cleaner. You could add new jobs to the workflow for testing the matrix of Ruby & Minitest versions. Thanks to that:

  • we have the option to test different Minitest versions in the future.
  • we would avoid testing the matrix of different Minitest & RSpec versions because it does not make sense. The testing frameworks are independent.

You could create a new story for that to not hold off on the release of this fix.

workflows:
  tests:
    jobs:
      - unit
      - 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-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.minitest >>
          matrix:
            parameters:
              ruby: ["3.0", "3.1", "3.2"]
              minitest: ["x.x.x", ...]
      - integration-queue-minitest:
          name: integration-queue__ruby-<< matrix.ruby >>__minitest-<< matrix.minitest >>
          matrix:
            parameters:
              ruby: ["3.0", "3.1", "3.2"]
              minitest: ["x.x.x", ...]

Copy link
Copy Markdown
Contributor Author

@3v0k4 3v0k4 Jan 9, 2024

Choose a reason for hiding this comment

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

✅ (I had to reduce the parallelism to avoid jobs being queued)

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"]
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/knapsack_pro/runners/queue/minitest_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down