Skip to content

Commit

Permalink
Run different rails versions tests in parallel
Browse files Browse the repository at this point in the history
Ditch appraisals while we're at it
  • Loading branch information
Earlopain committed Oct 10, 2024
1 parent 644d541 commit 348594a
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 561 deletions.
64 changes: 26 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,39 @@ jobs:
path: demo/log

test:
name: Test
name: Test - Ruby ${{ matrix.ruby }} - Postgres ${{ matrix.pg }} - ${{ matrix.gemfile }}
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby: ["3.0", 3.1, 3.2, 3.3]
gemfile: [rails_6.1, rails_7.0, rails_7.1, rails_7.2, rails_8.0, rails_head]
pg: [17]
include:
- ruby: 3.3
gemfile: rails_7.2
pg: 10
exclude:
# Rails 7.2 is >= 3.1
- ruby: "3.0"
gemfile: rails_7.2
# Rails 8.0 is >= 3.2
- ruby: "3.0"
gemfile: rails_8.0
- ruby: 3.1
gemfile: rails_8.0
# Rails head is >= 3.2
- ruby: "3.0"
gemfile: rails_head
- ruby: 3.1
gemfile: rails_head

env:
PGHOST: localhost
PGUSER: good_job
RAILS_ENV: test
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
Expand All @@ -125,59 +142,30 @@ jobs:
uses: actions/checkout@v4
- name: Update .ruby-version with matrix value
run: echo "${{ matrix.ruby }}" >| .ruby-version
- name: Set Rubygems version
id: rubygems
run: |
if [[ "${{ matrix.ruby }}" == "2.6" || "${{ matrix.ruby }}" == "2.7" || "${{ matrix.ruby }}" == "jruby-9.3" ]]; then
echo "version=3.3.27" >> $GITHUB_OUTPUT
else
echo "version=latest" >> $GITHUB_OUTPUT
fi
# Dependencies
- name: Remove Gemfile.lock
run: rm Gemfile.lock
- name: Set up generic Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- name: Recreate Gemfile.lock
run: bundle lock --update && cat Gemfile.lock
- name: Set up Ruby and bundle install
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
rubygems: ${{ steps.rubygems.outputs.version }}
- name: Generate Appraisal Gemfile.lock files
run: |
bundle exec appraisal bundle lock --update
- name: Cache Appraisal gems
uses: actions/cache@v4
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
rubygems: latest

# Test
- name: Set up test database
run: bundle exec appraisal demo/bin/rails db:test:prepare
run: bundle exec demo/bin/rails db:test:prepare
- name: Run Unit tests
run: |
bundle exec appraisal rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \
bundle exec 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 \
bundle exec 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 \
bundle exec rspec --require ./spec/support/pre_documentation_formatter.rb \
--format PreDocumentationFormatter \
spec/generators
Expand All @@ -186,13 +174,13 @@ jobs:
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
name: screenshots-${{ matrix.pg }}-${{ matrix.gemfile }}-${{ matrix.ruby }}
path: |
demo/tmp/screenshots
demo/tmp/capybara
- name: Archive Rails logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: rails_logs
name: rails_logs-${{ matrix.pg }}-${{ matrix.gemfile }}-${{ matrix.ruby }}
path: demo/log
46 changes: 0 additions & 46 deletions Appraisals

This file was deleted.

12 changes: 10 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ gemspec
# your gem to rubygems.org.

gem 'activerecord-jdbcpostgresql-adapter', platforms: [:jruby]
gem 'appraisal'
gem 'pg', platforms: [:mri, :mingw, :x64_mingw]
gem 'rack', '~> 2.2'
gem 'rails'

rails_versions = {
"6.1" => "~> 6.1.0",
"7.0" => "~> 7.0.1", # Ruby 3.1 requires Rails 7.0.1+
"7.1" => "~> 7.1.0",
"7.2" => "~> 7.2.0",
"8.0" => "~> 8.0.0.a",
"head" => { github: "rails/rails", branch: "main" },
}
gem 'rails', rails_versions[ENV.fetch("RAILS_VERSION", nil)]

platforms :ruby do
gem "bootsnap"
Expand Down
5 changes: 0 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
ast (2.4.2)
async (2.14.2)
console (~> 1.25, >= 1.25.2)
Expand Down Expand Up @@ -505,7 +501,6 @@ PLATFORMS
DEPENDENCIES
activerecord-explain-analyze
activerecord-jdbcpostgresql-adapter
appraisal
benchmark-ips
bootsnap
brakeman
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1715,14 +1715,14 @@ Environment variables that may help with debugging:
- `LOUD=1`: display all stdout/stderr output from all sources. This is helpful because GoodJob wraps some tests with `quiet { }` for cleaner test output, but it can hinder debugging.
- `SHOW_BROWSER=1`: Run system tests headfully with Chrome/Chromedriver. Use `binding.irb` in the system tests to pause.
Appraisal can be used to run a test matrix of multiple versions of Rails:
The gemfiles in `gemfiles/` can be used to run tests against different rails versions:
```bash
# Install Appraisal matrix of gemfiles
bin/appraisal
# Install dependencies
BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bundle install
# Run tests against matrix
bin/appraisal bin/rspec
# Run the tests
BUNDLE_GEMFILE=gemfiles/rails_6.1.gemfile bin/rspec
```
### Release
Expand Down
3 changes: 0 additions & 3 deletions bin/appraisal

This file was deleted.

109 changes: 0 additions & 109 deletions gemfiles/bin/bundle

This file was deleted.

Loading

0 comments on commit 348594a

Please sign in to comment.