Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 62 additions & 71 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_8.0.gemfile
BUNDLE_GEMFILE: gemfiles/activerecord_8.1.gemfile
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
ruby-version: '3.4'
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@v7
uses: actions/github-script@v8
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,74 +51,65 @@ 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'
rails: '7.1'
- ruby: '3.2'
rails: '7.0'
- ruby: '3.1'
rails: '7.2'
- ruby: '3.1'
rails: '7.1'
- ruby: '3.1'
rails: '7.0'
- ruby: '3.1'
rails: '6.1'
- ruby: '3.0'
rails: '7.1'
- ruby: '3.0'
rails: '7.0'
- ruby: '3.0'
rails: '6.1'
- ruby: '2.7'
rails: '7.1'
- ruby: '2.7'
rails: '7.0'
- ruby: '2.7'
rails: '6.1'
- ruby: '2.7'
rails: '6.0'
- ruby: '2.6'
rails: '6.1'
- ruby: '2.6'
rails: '6.0'
- ruby: '2.5'
rails: '6.1'
- ruby: '2.5'
rails: '6.0'
- ruby: 'jruby'
rails: '7.0'
- ruby: 'jruby'
rails: '6.1'
- ruby: 'truffleruby'
rails: '8.0'
- ruby: 'truffleruby'
rails: '7.2'
- ruby: 'truffleruby'
rails: '7.1'
- ruby: 'truffleruby'
rails: '7.0'
- ruby: 'truffleruby'
rails: '6.1'
- ruby: 'truffleruby'
rails: '6.0'
# Rails 6.0 requires Ruby >= 2.5 and < 3.0
- {rails: '6.0', ruby: '2.5'}
- {rails: '6.0', ruby: '2.6'}
- {rails: '6.0', ruby: '2.7'}
- {rails: '6.0', ruby: 'truffleruby'}

# Rails 6.1 requires Ruby >= 2.5 and < 3.2
- {rails: '6.1', ruby: '2.5'}
- {rails: '6.1', ruby: '2.6'}
- {rails: '6.1', ruby: '2.7'}
- {rails: '6.1', ruby: '3.0'}
- {rails: '6.1', ruby: '3.1'}
- {rails: '6.1', ruby: 'jruby'}
- {rails: '6.1', ruby: 'truffleruby'}

# Rails 7.0 requires Ruby >= 2.7
- {rails: '7.0', ruby: '2.7'}
- {rails: '7.0', ruby: '3.0'}
- {rails: '7.0', ruby: '3.1'}
- {rails: '7.0', ruby: '3.2'}
- {rails: '7.0', ruby: '3.3'}
- {rails: '7.0', ruby: '3.4'}
- {rails: '7.0', ruby: 'jruby'}
- {rails: '7.0', ruby: 'truffleruby'}

# Rails 7.1 requires Ruby >= 2.7
- {rails: '7.1', ruby: '2.7'}
- {rails: '7.1', ruby: '3.0'}
- {rails: '7.1', ruby: '3.1'}
- {rails: '7.1', ruby: '3.2'}
- {rails: '7.1', ruby: '3.3'}
- {rails: '7.1', ruby: '3.4'}
- {rails: '7.1', ruby: 'truffleruby'}

# Rails 7.2 requires Ruby >= 3.1
- {rails: '7.2', ruby: '3.1'}
- {rails: '7.2', ruby: '3.2'}
- {rails: '7.2', ruby: '3.3'}
- {rails: '7.2', ruby: '3.4'}
- {rails: '7.2', ruby: 'truffleruby'}

# Rails 8.0 requires Ruby >= 3.2
- {rails: '8.0', ruby: '3.2'}
- {rails: '8.0', ruby: '3.3'}
- {rails: '8.0', ruby: '3.4'}
- {rails: '8.0', ruby: 'truffleruby'}

# Rails 8.1 requires Ruby >= 3.2
- {rails: '8.1', ruby: '3.2'}
- {rails: '8.1', ruby: '3.3'}
- {rails: '8.1', ruby: '3.4'}
- {rails: '8.1', ruby: 'truffleruby'}

env:
BUNDLE_GEMFILE: gemfiles/activerecord_${{ matrix.rails }}.gemfile
SKIPPED_ADAPTERS: ${{ matrix.skipped_adapters }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Setup MySQL and PostgreSQL via Docker Compose
run: docker compose up -d --wait
- name: Install Ruby
Expand All @@ -139,10 +130,10 @@ jobs:
needs: tests
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/activerecord_8.0.gemfile
BUNDLE_GEMFILE: gemfiles/activerecord_8.1.gemfile
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Download artifacts
uses: actions/download-artifact@v4
with:
Expand All @@ -152,7 +143,7 @@ jobs:
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
ruby-version: '3.4'
bundler-cache: true
- name: Collate coverage reports
run: ${{ matrix.env }} bundle exec rake ci:coverage:collate
Expand All @@ -173,7 +164,7 @@ jobs:
echo "Total branch test coverage: ${{ steps.coverage.outputs.COVERAGE_BRANCH }}%"
- name: Fail if coverage is low
if: steps.coverage.outputs.COVERAGE_LINE != 100 || steps.coverage.outputs.COVERAGE_BRANCH < 95
uses: actions/github-script@v7
uses: actions/github-script@v8
with:
script: "core.setFailed('Please make sure line test coverage is 100% and branch test coverage is > 95%. \
Currently: ${{ steps.coverage.outputs.COVERAGE_LINE }}% (line), \
Expand Down
14 changes: 14 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@ appraise "activerecord-6.0" do
gem "activerecord", "~> 6.0.0"
gem "activesupport", "~> 6.0.0"
gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
gem "concurrent-ruby", "1.3.4" # https://stackoverflow.com/a/79361034
end

appraise "activerecord-6.1" do
gem "activerecord", "~> 6.1.0"
gem "activesupport", "~> 6.1.0"
gem "sqlite3", "~> 1.4", platforms: [:ruby, :truffleruby]
gem "concurrent-ruby", "1.3.4" # https://stackoverflow.com/a/79361034
end

appraise "activerecord-7.0" do
gem "activerecord", "~> 7.0.0"
gem "activesupport", "~> 7.0.0"
gem "sqlite3", "~> 1.6", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
gem "concurrent-ruby", "1.3.4" # https://stackoverflow.com/a/79361034

install_if '-> { RUBY_VERSION >= "3.4.0" }' do
gem "mutex_m" # mutex_m is no longer a part of the default gems
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's only needed for ActiveRecord 7.0 but not for later versions? What happens without it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — it’s only needed for Rails 7.0 when running on Ruby 3.4.
Earlier Ruby versions bundled mutex_m in the standard library, but Ruby 3.4 removed it, which causes ActiveRecord 7.0 to fail to load without the gem.

Rails 7.0 explicitly requires mutex_m here:
https://github.com/rails/rails/blob/7-0-stable/activesupport/lib/active_support/notifications/fanout.rb#L3

Newer ActiveSupport versions already include mutex_m as a dependency (see rails/rails#48907), so they work fine without adding anything manually.

CleanShot 2025-10-23 at 20 27 58@2x

end
end

appraise "activerecord-7.1" do
Expand All @@ -37,3 +44,10 @@ appraise "activerecord-8.0" do
gem "sqlite3", "~> 2.1", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end

appraise "activerecord-8.1" do
gem "activerecord", "~> 8.1.0"
gem "activesupport", "~> 8.1.0"
gem "sqlite3", "~> 2.1", platforms: [:ruby, :truffleruby]
gem "standard", "~> 1.31"
end
34 changes: 17 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@ Want to contribute to the development of temping? Great!

Here's what you can do:

* suggest a feature or submit a bug at https://github.com/jpignata/temping/issues
* contribute code or documentation by submitting a pull request at https://github.com/jpignata/temping/pulls
* suggest a feature or submit a bug at <https://github.com/jpignata/temping/issues>
* contribute code or documentation by submitting a pull request at <https://github.com/jpignata/temping/pulls>

If you submit code make sure that the test suite is still green by either manually running
the tests or making use of the CI, which starts upon every pull request.
If you submit code make sure that the test suite is still green by either manually running
the tests or making use of the CI, which starts upon every pull request.

The code is currently tested against several versions of SQLite3, PostgreSQL and MySQL.
If you want to run the tests manually please first make sure you have Docker
The code is currently tested against several versions of SQLite3, PostgreSQL and MySQL.
If you want to run the tests manually please first make sure you have Docker
installed and then run

```shell
$ docker compose up -d --wait
docker compose up -d --wait
```

to start the container. Once the container is up and running you can run
to start the container. Once the container is up and running you can run

```shell
$ rake
```
rake
```

to run the whole test suite including StandardRB linter.
to run the whole test suite including StandardRB linter.

If you want to test a particular database adapter version run
`rake spec:<adapter version>`, e.g. `rake spec:mysql8.0`
`rake spec:<adapter version>`, e.g. `rake spec:mysql8.4`
(the name should correspond to keys in `spec/config.default.yml`).

You can prepend the call with a specific gemfile
(located in `gemfiles` directory) to test against a particular
ActiveRecord version. This is done with the help of
[Appraisal gem](https://github.com/thoughtbot/appraisal).
You can prepend the call with a specific gemfile
(located in `gemfiles` directory) to test against a particular
ActiveRecord version. This is done with the help of
[Appraisal gem](https://github.com/thoughtbot/appraisal).
For example:

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

The configuration used to access the databases is stored in
Expand Down
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ codey.quack
# => "arf!"
```

All attributes you pass to `create_table` are evaluated too.
All attributes you pass to `create_table` are evaluated too.
For example you can create a dog with a primary key of the type uuid
(assuming you use PostgreSQL with uuid-ossp extension enabled):

Expand Down Expand Up @@ -169,7 +169,7 @@ my_car.navigate_to(:home)

## Namespaces

Temping supports creating models within namespaces.
Temping supports creating models within namespaces.
You can do this either by just including the full namespace in the name:

```ruby
Expand All @@ -195,11 +195,11 @@ Engineers::Developer.table_name # => "hard_working_developers"
Engineers::Developer # => Engineers::Developer(id: integer)
```

Please note that if you create the modules yourself, Temping will NOT attempt
to undefine them when you call `Temping.teardown`, it will only undefine the modules/models
Please note that if you create the modules yourself, Temping will NOT attempt
to undefine them when you call `Temping.teardown`, it will only undefine the modules/models
created by itself:

```ruby
```ruby
module Engineers; end
Temping.create("engineers/developers")
Temping.create("animal/cat")
Expand All @@ -214,18 +214,18 @@ Object.const_defined?("Animal::Cat") # => false

Deep namespaces are supported as well:

```ruby
```ruby
Temping.create("continents/countries/cities/streets/buildings")

# => Continents::Countries::Cities::Streets::Building(id: integer)
```

## Foreign Keys

Temporary tables in [MySQL](https://dev.mysql.com/doc/refman/9.1/en/create-table-foreign-keys.html)
Temporary tables in [MySQL](https://dev.mysql.com/doc/refman/9.5/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
If you want to use foreign keys with Temping in MySQL you might want to consider
making tables permanent by overwriting `temporary` option when you set up a model:

```ruby
Expand All @@ -237,34 +237,35 @@ Temping.create(:post, temporary: false) do
end
```

This however is not a recommended approach because the whole idea of Temping
This however is not a recommended approach because the whole idea of Temping
is about using **temporary** tables.

## Tested Environments

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

* 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 8.0, 7.2, 7.1, 7.0, 6.1, 6.0
- MRI 3.4 with ActiveRecord 8.1, 8.0, 7.2, 7.1, 7.0
- MRI 3.3 with ActiveRecord 8.1, 8.0, 7.2, 7.1, 7.0
- MRI 3.2 with ActiveRecord 8.1, 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 8.1, 8.0, 7.2, 7.1, 7.0, 6.1, 6.0

with the following database systems:

* SQLite3
* MySQL (versions 5.6-9.1)
* PostgreSQL (versions 10-17)
- SQLite3
- MySQL (versions 5.6-9.5)
- PostgreSQL (versions 10-18)

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).

## Contributing

All contributions are welcome!
All contributions are welcome!

Please take a look at `CONTRIBUTING.md` for some tips.
Loading