Skip to content

Commit

Permalink
Support Rails 8.0 (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuravel authored Nov 15, 2024
1 parent be751b3 commit 13f93c2
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 79 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
name: Run StandardRB linter
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/activerecord_7.1.gemfile
BUNDLE_GEMFILE: gemfiles/activerecord_8.0.gemfile
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
ruby-version: '3.3'
bundler-cache: true
- name: Run StandardRB
id: offenses
Expand All @@ -40,7 +40,7 @@ jobs:
echo '${{ steps.offenses.outputs.LINTER_OFFENSES }}'
- name: Fail if StandardRB offenses found
if: steps.offenses.outputs.LINTER_OFFENSES
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: "core.setFailed('StandardRB linter offenses found. Please inspect the details \
of the previous step in the job for more info.')"
Expand All @@ -51,6 +51,16 @@ jobs:
fail-fast: false
matrix:
include:
- ruby: '3.3'
rails: '8.0'
- ruby: '3.3'
rails: '7.2'
- ruby: '3.3'
rails: '7.1'
- ruby: '3.3'
rails: '7.0'
- ruby: '3.2'
rails: '8.0'
- ruby: '3.2'
rails: '7.2'
- ruby: '3.2'
Expand Down Expand Up @@ -91,6 +101,8 @@ jobs:
rails: '7.0'
- ruby: 'jruby'
rails: '6.1'
- ruby: 'truffleruby'
rails: '8.0'
- ruby: 'truffleruby'
rails: '7.2'
- ruby: 'truffleruby'
Expand All @@ -106,7 +118,7 @@ jobs:
SKIPPED_ADAPTERS: ${{ matrix.skipped_adapters }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup MySQL and PostgreSQL via Docker Compose
run: docker compose up -d --wait
- name: Install Ruby
Expand All @@ -117,36 +129,38 @@ jobs:
- name: Run tests
run: bundle exec rake spec
- name: Upload code coverage results as artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-ruby-${{ matrix.ruby }}-rails-${{ matrix.rails }}
include-hidden-files: true
path: coverage/.resultset.json
coverage:
name: Calculate test coverage
needs: tests
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/activerecord_7.1.gemfile
BUNDLE_GEMFILE: gemfiles/activerecord_8.0.gemfile
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: coverage-resultsets
- name: Display structure of downloaded files
run: ls -Rla
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
ruby-version: '3.3'
bundler-cache: true
- name: Collate coverage reports
run: ${{ matrix.env }} bundle exec rake ci:coverage:collate
- name: Upload total code coverage result as an artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-total
include-hidden-files: true
path: coverage/.last_run.json
- name: Fetch total coverage values from simplecov files
id: coverage
Expand All @@ -159,7 +173,7 @@ jobs:
echo "Total branch test coverage: ${{ steps.coverage.outputs.COVERAGE_BRANCH }}%"
- name: Fail if coverage is less than 100%
if: steps.coverage.outputs.COVERAGE_LINE != 100 || steps.coverage.outputs.COVERAGE_BRANCH != 100
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: "core.setFailed('Please make sure test coverage is 100%. \
Currently: ${{ steps.coverage.outputs.COVERAGE_LINE }}% (line), \
Expand Down
32 changes: 22 additions & 10 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
appraise "activerecord-6.0" do
gem "activerecord", "~> 6.0.6"
gem "activesupport", "~> 6.0.6"
gem "activerecord", "~> 6.0.0"
gem "activesupport", "~> 6.0.0"
gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
end

appraise "activerecord-6.1" do
gem "activerecord", "~> 6.1.7"
gem "activesupport", "~> 6.1.7"
gem "activerecord", "~> 6.1.0"
gem "activesupport", "~> 6.1.0"
gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
end

appraise "activerecord-7.0" do
gem "activerecord", "~> 7.0.8"
gem "activesupport", "~> 7.0.8"
gem "activerecord", "~> 7.0.0"
gem "activesupport", "~> 7.0.0"
gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end

appraise "activerecord-7.1" do
gem "activerecord", "~> 7.1.3"
gem "activesupport", "~> 7.1.3"
gem "activerecord", "~> 7.1.0"
gem "activesupport", "~> 7.1.0"
gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end

appraise "activerecord-7.2" do
gem "activerecord", "~> 7.2"
gem "activesupport", "~> 7.2"
gem "activerecord", "~> 7.2.0"
gem "activesupport", "~> 7.2.0"
gem "sqlite3", "~> 2.0", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end

appraise "activerecord-8.0" do
gem "activerecord", "~> 8.0.0"
gem "activesupport", "~> 8.0.0"
gem "sqlite3", "~> 2.1", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ActiveRecord version. This is done with the help of
For example:

```shell
$ BUNDLE_GEMFILE=gemfiles/activerecord_6.1.gemfile rake
$ BUNDLE_GEMFILE=gemfiles/activerecord_8.0.gemfile rake
```

The configuration used to access the databases is stored in
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Code Climate](https://codeclimate.com/github/jpignata/temping.png)](https://codeclimate.com/github/jpignata/temping)
[![Build Status](https://github.com/jpignata/temping/workflows/checks/badge.svg?branch=master)](https://github.com/jpignata/temping/actions)
[![Gem Version](https://badge.fury.io/rb/temping.png)](http://badge.fury.io/rb/temping)
[![Gem Version](https://badge.fury.io/rb/temping.png)](https://badge.fury.io/rb/temping)

Temping allows you to create arbitrary ActiveRecord models backed by a temporary
SQL table for use in tests. You may need to do something like this if you're
Expand Down Expand Up @@ -222,7 +222,7 @@ Temping.create("continents/countries/cities/streets/buildings")

## Foreign Keys

Temporary tables in [MySQL](https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html)
Temporary tables in [MySQL](https://dev.mysql.com/doc/refman/9.1/en/create-table-foreign-keys.html)
cannot have foreign keys. PostgreSQL doesn't have this limitation.

If you want to use foreign keys with Temping in MySQL you might want to consider
Expand All @@ -244,20 +244,21 @@ is about using **temporary** tables.

The latest version of this gem is tested with the following setups:

* MRI 3.2 with ActiveRecord 7.2, 7.1, 7.0
* MRI 3.3 with ActiveRecord 8.0, 7.2, 7.1, 7.0
* MRI 3.2 with ActiveRecord 8.0, 7.2, 7.1, 7.0
* MRI 3.1 with ActiveRecord 7.2, 7.1, 7.0, 6.1
* MRI 3.0 with ActiveRecord 7.1, 7.0, 6.1
* MRI 2.7 with ActiveRecord 7.1, 7.0, 6.1, 6.0
* MRI 2.6 with ActiveRecord 6.1, 6.0
* MRI 2.5 with ActiveRecord 6.1, 6.0
* JRuby with ActiveRecord 7.0, 6.1 (with activerecord-jdbc-adapter)
* TruffleRuby with ActiveRecord 7.2, 7.1, 7.0, 6.1, 6.0
* TruffleRuby with ActiveRecord 8.0, 7.2, 7.1, 7.0, 6.1, 6.0

with the following database systems:

* SQLite3
* MySQL (versions 5.5-9.0)
* PostgreSQL (versions 10-16)
* MySQL (versions 5.6-9.1)
* PostgreSQL (versions 10-17)

If you need to support older versions of Ruby or ActiveRecord you might have to use
the older versions of this gem (4.0.0 or below).
Expand Down
51 changes: 31 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
version: "3.8"
services:
mysql9.1:
image: "mysql:9.1"
ports:
- "13316:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
test: mysqladmin -u root -h 127.0.0.1 -P 3306 ping
interval: 1s
timeout: 5s
retries: 60
mysql9.0:
image: "mysql:9.0"
ports:
- "13316:3306"
- "13317:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -14,7 +25,7 @@ services:
mysql8.4:
image: "mysql:8.4"
ports:
- "13317:3306"
- "13318:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -25,7 +36,7 @@ services:
mysql8.3:
image: "mysql:8.3"
ports:
- "13318:3306"
- "13319:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -36,7 +47,7 @@ services:
mysql8.2:
image: "mysql:8.2"
ports:
- "13319:3306"
- "13320:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -47,7 +58,7 @@ services:
mysql8.1:
image: "mysql:8.1"
ports:
- "13320:3306"
- "13321:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -58,7 +69,7 @@ services:
mysql8.0:
image: "mysql:8.0.31"
ports:
- "13321:3306"
- "13322:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -69,7 +80,7 @@ services:
mysql5.7:
image: "mysql:5.7.40"
ports:
- "13322:3306"
- "13323:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
Expand All @@ -80,29 +91,29 @@ services:
mysql5.6:
image: "mysql:5.6.51"
ports:
- "13323:3306"
- "13324:3306"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
healthcheck:
test: mysqladmin -u root -h 127.0.0.1 -P 3306 ping
interval: 1s
timeout: 5s
retries: 60
mysql5.5:
image: "mysql:5.5.62"
postgresql17:
image: "postgres:17"
ports:
- "13324:3306"
- "15442:5432"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
POSTGRES_PASSWORD: password
healthcheck:
test: mysqladmin -u root -h 127.0.0.1 -P 3306 ping
test: pg_isready -U postgres -h 127.0.0.1 -p 5432
interval: 1s
timeout: 5s
retries: 60
postgresql16:
image: "postgres:16"
ports:
- "15442:5432"
- "15443:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -113,7 +124,7 @@ services:
postgresql15:
image: "postgres:15"
ports:
- "15443:5432"
- "15444:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -124,7 +135,7 @@ services:
postgresql14:
image: "postgres:14"
ports:
- "15444:5432"
- "15445:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -135,7 +146,7 @@ services:
postgresql13:
image: "postgres:13"
ports:
- "15445:5432"
- "15446:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -146,7 +157,7 @@ services:
postgresql12:
image: "postgres:12"
ports:
- "15446:5432"
- "15447:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -157,7 +168,7 @@ services:
postgresql11:
image: "postgres:11"
ports:
- "15447:5432"
- "15448:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand All @@ -168,7 +179,7 @@ services:
postgresql10:
image: "postgres:10"
ports:
- "15448:5432"
- "15449:5432"
environment:
POSTGRES_PASSWORD: password
healthcheck:
Expand Down
5 changes: 3 additions & 2 deletions gemfiles/activerecord_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

source "https://rubygems.org"

gem "activerecord", "~> 6.0.6"
gem "activesupport", "~> 6.0.6"
gem "activerecord", "~> 6.0.0"
gem "activesupport", "~> 6.0.0"
gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]

gemspec path: "../"
Loading

0 comments on commit 13f93c2

Please sign in to comment.