Skip to content

Wrap all test background threads in Rails executors; better test logg… #2282

Wrap all test background threads in Rails executors; better test logg…

Wrap all test background threads in Rails executors; better test logg… #2282

Workflow file for this run

name: Test
on:
push:
branches:
- main
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
steps:
- name: Checkout code
uses: actions/checkout@v4
# Dependencies
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: latest
# Lint
- name: Run linter
run: bin/lint --nofix
development_environment:
name: Development Environment
runs-on: ubuntu-latest
timeout-minutes: 10
env:
PGHOST: localhost
PGUSER: good_job
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
DISABLE_SPRING: 1
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: good_job
POSTGRES_DB: good_job_test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
ports: [ "5432:5432" ]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
# Dependencies
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: latest
# Validate Development Environment
- name: bin/setup
run: bin/rails db:test:prepare
- name: bin/rspec
run: bin/rspec --require ./spec/support/pre_documentation_formatter.rb --format PreDocumentationFormatter
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
ruby: [2.6, 2.7, "3.0", 3.1, 3.2, jruby-9.3, jruby-9.4]
pg: [15]
include:
- ruby: 3.2
pg: 11
- ruby: 3.2
pg: 12
- ruby: 3.2
pg: 13
- ruby: 3.2
pg: 14
- ruby: jruby-9.4
pg: 11
- ruby: jruby-9.4
pg: 12
- ruby: jruby-9.4
pg: 13
- ruby: jruby-9.4
pg: 14
env:
PGHOST: localhost
PGUSER: good_job
RAILS_ENV: test
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
BUNDLE_WITHOUT: debug:lint:demo:production
RAILS_LOG_TO_STDOUT: false
services:
postgres:
image: postgres:${{ matrix.pg }}
env:
POSTGRES_USER: good_job
POSTGRES_DB: good_job_test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- name: Checkout code
uses: actions/checkout@v4
- name: Update .ruby-version with matrix value
run: echo "${{ matrix.ruby }}" >| .ruby-version
# Dependencies
- name: Set up generic Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- name: Delete and recreate Gemfile.lock
run: |
rm Gemfile.lock && bundle lock && cat Gemfile.lock
- name: Set up Ruby and bundle install
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: latest
- name: Cache Appraisal gems
uses: actions/cache@v3
with:
path: gemfiles/vendor/bundle
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock', 'gemfiles/*.gemfile.lock') }}
restore-keys: |
v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-
- name: Install Appraisal gems
run: bundle exec appraisal install
# Test
- name: Set up test database
run: bundle exec appraisal spec/test_app/bin/rails db:test:prepare
- name: Run Unit tests
run: |
bundle exec appraisal rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \
--require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter
- name: Run System tests
if: ${{ !contains(matrix.ruby, 'jruby') }}
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/system
- name: Run Generators tests
run: |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/generators
# Archive
- name: Archive system spec screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: screenshots
path: |
spec/test_app/tmp/screenshots
spec/test_app/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: rails_logs
path: spec/test_app/log