diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 782f6fe510..7749d2fa3e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,6 +23,7 @@ jobs: timeout-minutes: 20 env: RAILS_ENV: test + TEST_MAX_DURATION: 60 steps: - name: Checkout repository uses: actions/checkout@v4 @@ -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 - name: Archive selenium screenshots if: ${{ failure() }} diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 35099a5682..bd42a4d0a6 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -20,6 +20,7 @@ jobs: timeout-minutes: 20 env: RAILS_ENV: test + TEST_MAX_DURATION: 60 services: db: diff --git a/.github/workflows/rspec_parallel.yml b/.github/workflows/rspec_parallel.yml index 22d6f9d140..582daba9b2 100644 --- a/.github/workflows/rspec_parallel.yml +++ b/.github/workflows/rspec_parallel.yml @@ -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 }} @@ -110,12 +110,11 @@ 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 + cat tmp/spec_summary.log - name: Compress reports if: ${{ !cancelled() }} diff --git a/.rspec_parallel b/.rspec_parallel index 976d0c8900..d36b40d843 100644 --- a/.rspec_parallel +++ b/.rspec_parallel @@ -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::RuntimeLogger --out tmp/parallel_runtime.log --format ParallelTests::RSpec::SummaryLogger --out tmp/spec_summary.log --format ParallelTests::RSpec::FailuresLogger --out tmp/failing_specs.log diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4c05cf8fe3..fdbe22e146 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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 "\nTimout Error: example #{example.full_description} timed out.\n" + end + config.around :each, :disable_bullet do |example| Bullet.raise = false example.run