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

fix: parallel timeout improvements #5859

Merged
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
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
timeout-minutes: 20
env:
RAILS_ENV: test
TEST_MAX_DURATION: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -37,7 +38,7 @@ jobs:
- name: compile assets
run: docker-compose exec -T web bundle exec rails assets:precompile
- name: Test
run: docker-compose exec -T web bundle exec rspec spec --format documentation
run: docker-compose exec -T web bundle exec rspec spec --fail-fast

- name: Archive selenium screenshots
if: ${{ failure() }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
timeout-minutes: 20
env:
RAILS_ENV: test
TEST_MAX_DURATION: 60

services:
db:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/rspec_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
rspec_parallel:
name: RSpec Groups ${{ inputs.groups }}
runs-on: ubuntu-latest
timeout-minutes: 4
env:
RAILS_ENV: test
TEST_MAX_DURATION: 45
BUNDLE_WITHOUT: "development"
CI_TOTAL_JOBS: ${{ inputs.group_count }}
CI_JOB_INDEX: ${{ inputs.groups }}
Expand Down Expand Up @@ -110,12 +110,10 @@ jobs:
RUBYOPT='-W:no-deprecated -W:no-experimental' bundle exec parallel_rspec \
-n "${CI_TOTAL_JOBS}" \
--only-group "${CI_JOB_INDEX}" \
--runtime-log old_parallel_runtime.log \
--verbose ./spec
--runtime-log old_parallel_runtime.log ./spec

# echo 'Tests completed. Uploading to Code Climate'
# ./cc-test-reporter after-build --exit-code $?
# cat tmp/spec_summary.log

- name: Compress reports
if: ${{ !cancelled() }}
Expand Down
3 changes: 1 addition & 2 deletions .rspec_parallel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
--format RspecJunitFormatter --out tmp/reports/rspec_<%= ENV["GROUPS_UNDERSCORE"] %>_<%= ENV["TEST_ENV_NUMBER"] %>.xml
--format ParallelTests::RSpec::VerboseLogger
--format ParallelTests::RSpec::SummaryLogger
--format ParallelTests::RSpec::RuntimeLogger --out tmp/parallel_runtime.log
--format ParallelTests::RSpec::SummaryLogger --out tmp/spec_summary.log
--format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log
3 changes: 3 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = false

# https://github.com/rails/rails/issues/48468
config.active_job.queue_adapter = :test
end
9 changes: 9 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@

config.disable_monkey_patching!

config.around :each do |example|
# If timeout is not set it will run without a timeout
Timeout.timeout(ENV["TEST_MAX_DURATION"].to_i) do
example.run
end
rescue Timeout::Error
raise StandardError.new "\"#{example.full_description}\" in #{example.location} timed out."
end

config.around :each, :disable_bullet do |example|
Bullet.raise = false
example.run
Expand Down