Skip to content

Commit

Permalink
Update testing matrix
Browse files Browse the repository at this point in the history
* Add Rails 6.1 which has been out a long while
* Remove Rails 5.2 which is nearing end of life
* Remove Ruby 2.4 which is past end of life
* Stop allowing failure on Rails master

When first adding 6.1 to the matrix, some of the tests failed with
aborted transactions. Inspecting the postgres log I was able to see that
Rails was trying to query a non-existent `schema_migrations` table. It
seems that in Rails 6.1, the `schema_migrations` table is created
differently from previous versions -- perhaps on demand when the
database is first accessed?

This is important because we wrap our tests that use the database in
DatabaseCleaner using the transaction strategy. When DB cleaner
rolls back the transaction at the end of the test, it was also rolling
back the creation of the `schema_migrations` table.

To get around this, I call `SchemaMigration.create_table` before every
DB-dependent test.

I've stopped allowing failure on Rails master because it hid this error
(which is only an issue in tests, really) from us for too long.
Additionally, I wanted to add Ruby 3 as part of this change, but there
were some build failures so I will handle that separately.
  • Loading branch information
derekprior committed Dec 14, 2021
1 parent e50b663 commit f9e0837
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,9 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["2.7","2.4"]
rails: ["5.2", "6.0", "master"]
exclude:
- ruby: "2.4"
rails: "6.0"
- ruby: "2.4"
rails: "master"
include:
- rails: "master"
continue-on-error: true
ruby: ["2.7"]
rails: ["6.0", "6.1", "master"]
continue-on-error: [false]

runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
# Specify your gem's dependencies in scenic.gemspec
gemspec

rails_version = ENV.fetch("RAILS_VERSION", "6.0")
rails_version = ENV.fetch("RAILS_VERSION", "6.1")

if rails_version == "master"
rails_constraint = { github: "rails/rails" }
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
DatabaseCleaner.strategy = :transaction

config.around(:each, db: true) do |example|
ActiveRecord::SchemaMigration.create_table

DatabaseCleaner.start
example.run
DatabaseCleaner.clean
Expand Down

0 comments on commit f9e0837

Please sign in to comment.