File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,9 +200,12 @@ jobs:
200200 - name : Prepare database
201201 run : |
202202 bundle exec rake alchemy:spec:prepare
203+ cd spec/dummy
204+ bin/rails parallel:setup
205+ cd -
203206 - name : Run tests
204207 run : |
205- bundle exec rspec
208+ bin/parallel_rspec
206209 - name : Upload coverage reports to Codecov
207210 uses : codecov/codecov-action@v5
208211 if : matrix.rails == '8.0' && matrix.ruby == '3.4'
Original file line number Diff line number Diff line change 2323
2424group :development , :test do
2525 gem "execjs" , "~> 2.10.0"
26+ gem "parallel_tests" , "~> 5.5"
2627 gem "rubocop" , require : false
2728 gem "standard" , "~> 1.25" , require : false
2829
Original file line number Diff line number Diff line change @@ -336,6 +336,34 @@ $ bundle exec rake
336336
337337* ) This default task executes the database preparations and runs all defined test cases.
338338
339+ ### Run specs in parallel
340+
341+ Using https://github.com/grosser/parallel_tests
342+
343+ #### Once before running
344+
345+ ```
346+ bundle exec rake alchemy:spec:prepare
347+ cd spec/dummy
348+ bin/rails parallel:setup
349+ cd -
350+ ```
351+
352+ #### Start a parallel test run
353+
354+ ```
355+ bin/parallel_rspec
356+ ```
357+
358+ #### After adding a new migration
359+
360+ ```
361+ cd spec/dummy
362+ bin/rails alchemy:install:migrations
363+ bin/rails parallel:migrate
364+ cd -
365+ ```
366+
339367### Start the dummy app
340368
341369You can even start the dummy app and use it to manually test your changes with:
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+ require "bundler/setup"
3+ load Gem . bin_path ( "parallel_tests" , "parallel_rspec" )
Original file line number Diff line number Diff line change 11sqlite : &sqlite
22 adapter : sqlite3
3- database : db/<%= Rails.env %>.sqlite3
3+ database : db/<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %> .sqlite3
44
55mysql : &mysql
66 adapter : mysql2
77 encoding : utf8mb4
88 username : <%= ENV['DB_USER'] %>
99 password : <%= ENV['DB_PASSWORD'] %>
10- database : alchemy_cms_dummy_<%= Rails.env %>
10+ database : alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>
1111
1212mariadb : &mariadb
1313 adapter : mysql2
1414 encoding : utf8mb4
1515 port : 3307
1616 username : <%= ENV['DB_USER'] %>
1717 password : <%= ENV['DB_PASSWORD'] %>
18- database : alchemy_cms_dummy_<%= Rails.env %>
18+ database : alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>
1919
2020postgresql : &postgresql
2121 adapter : postgresql
2222 <% if ENV['DB_USER'] % >
2323 username : <%= ENV['DB_USER'] %>
2424 password : <%= ENV['DB_PASSWORD'] %>
2525 <% end % >
26- database : alchemy_cms_dummy_<%= Rails.env %>
26+ database : alchemy_cms_dummy_<%= Rails.env %><%= ENV['TEST_ENV_NUMBER'] %>
2727 min_messages : ERROR
2828
2929defaults : &defaults
Original file line number Diff line number Diff line change 1212 add_filter "/lib/generators"
1313end
1414
15+ if ENV [ "TEST_ENV_NUMBER" ] # parallel specs
16+ SimpleCov . at_exit do
17+ result = SimpleCov . result
18+ result . format! if ParallelTests . number_of_running_processes <= 1
19+ end
20+ end
21+
1522require "rspec/core"
1623
1724RSpec . configure do |config |
1825 config . raise_errors_for_deprecations!
1926 config . run_all_when_everything_filtered = true
2027 config . pattern = "**/*_spec.rb"
2128 config . filter_run :focus
29+ config . silence_filter_announcements = true if ENV [ "TEST_ENV_NUMBER" ]
2230end
You can’t perform that action at this time.
0 commit comments