Skip to content

Commit

Permalink
Test multiple Rails versions
Browse files Browse the repository at this point in the history
- Support for multiple Rails version in CI via appraisal
- Fix tests to work with multiple Rails versions
  • Loading branch information
intrip committed Nov 16, 2023
1 parent c69ab54 commit 6dae126
Show file tree
Hide file tree
Showing 15 changed files with 936 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
fail-fast: false
matrix:
ruby-version: [3.2.2]
gemfile: [ rails_7, rails_7_1, rails_main ]
database: [sqlite, postgres, mysql]
services:
redis:
Expand All @@ -43,6 +44,7 @@ jobs:
options: --health-cmd "mysql -h localhost -e \"select now()\"" --health-interval 1s --health-timeout 5s --health-retries 30
env:
TARGET_DB: ${{ matrix.database }}
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
11 changes: 11 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
appraise "rails-7" do
gem "rails", github: "rails/rails", branch: "7-0-stable"
end

appraise "rails-7-1" do
gem "rails", github: "rails/rails", branch: "7-1-stable"
end

appraise "rails-main" do
gem "rails", github: "rails/rails", branch: "main"
end
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ gem "pg"
gem "sprockets-rails"

gem "rubocop-37signals", github: "basecamp/house-style", require: false
gem "appraisal"

# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"
48 changes: 29 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,19 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
ast (2.4.2)
base64 (0.1.1)
base64 (0.2.0)
bigdecimal (3.1.4)
builder (3.2.4)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6)
date (3.3.4)
debug (1.7.0)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
drb (2.2.0)
Expand All @@ -109,9 +113,10 @@ GEM
activesupport (>= 6.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.5.11)
irb (1.6.0)
reline (>= 0.3.0)
io-console (0.6.0)
irb (1.9.0)
rdoc
reline (>= 0.3.8)
json (2.6.3)
language_server-protocol (3.17.0.3)
loofah (2.22.0)
Expand All @@ -129,7 +134,7 @@ GEM
mocha (2.1.0)
ruby2_keywords (>= 0.0.5)
mutex_m (0.2.0)
mysql2 (0.5.4)
mysql2 (0.5.5)
net-imap (0.4.5)
date
net-protocol
Expand All @@ -144,10 +149,12 @@ GEM
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.4.5)
pg (1.5.4)
psych (5.1.1.1)
stringio
racc (1.7.3)
rack (3.0.8)
rack-session (2.0.0)
Expand Down Expand Up @@ -188,49 +195,51 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.8.1)
reline (0.3.1)
rdoc (6.6.0)
psych (>= 4.0.0)
regexp_parser (2.8.2)
reline (0.4.0)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.56.3)
base64 (~> 0.1.1)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-minitest (0.32.1)
rubocop-minitest (0.33.0)
rubocop (>= 1.39, < 2.0)
rubocop-performance (1.19.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.21.1)
rubocop-rails (2.22.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sprockets (4.2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.6)
sqlite3 (1.6.8)
mini_portile2 (~> 2.8.0)
stringio (3.0.9)
thor (1.3.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
Expand All @@ -245,6 +254,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
appraisal
debug
mocha
mysql2
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,25 @@ $ TARGET_DB=mysql bin/rails test
$ TARGET_DB=postgres bin/rails test
```

### Testing with multiple Rails version

Solid Cache relies on [appraisal](https://github.com/thoughtbot/appraisal/tree/main) to test
multiple Rails version.

To run a test for a specific version run:

```shell
bundle exec appraisal rails-7-1 bin/rails test
```

After updating the dependencies in then `Gemfile` please run:

```shell
$ bundle
$ appraisal update
```

This ensures that all the Rails versions dependencies are updated.

## License
Solid Cache is licensed under MIT.
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
13 changes: 13 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sqlite3"
gem "mysql2"
gem "pg"
gem "sprockets-rails"
gem "rubocop-37signals", require: false, git: "https://github.com/basecamp/house-style.git"
gem "appraisal"
gem "rails", branch: "7-0-stable", git: "https://github.com/rails/rails.git"

gemspec path: "../"
Loading

0 comments on commit 6dae126

Please sign in to comment.