From a3ada1316c82c79ee877d7c56708f8b583bb023a Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 7 Jan 2025 13:06:13 +0100 Subject: [PATCH] Update CI matrix to make sure recent Ruby and ActiveRecord versions are supported (#65) * Update Ruby and Rails versions in CI matrix * Rails 8 needs Ruby 3.2 or higher * Rails 7.1 seems to wrap the error * Add Ruby 3.4 to the matrix * Comment on the proper line * Add comment why we want to continue on error * Include gems with older Rails versions This is actually only required for Ruby 3.4 compatibility. * Remove references about Rails 5, that's not supported anymore * Update local Ruby version to most recent one --- .github/workflows/ci.yml | 13 ++++++------- .ruby-version | 2 +- README.md | 6 ------ test/gemfiles/rails-5.2.gemfile | 3 --- test/gemfiles/rails-6.0.gemfile | 3 --- test/gemfiles/rails-6.1.gemfile | 4 ++++ test/gemfiles/rails-7.0.gemfile | 4 ++++ .../{rails-5.0.gemfile => rails-7.1.gemfile} | 2 +- .../{rails-5.1.gemfile => rails-8.0.gemfile} | 2 +- test/integration/mysql_integration_test.rb | 8 +++----- 10 files changed, 20 insertions(+), 27 deletions(-) delete mode 100644 test/gemfiles/rails-5.2.gemfile delete mode 100644 test/gemfiles/rails-6.0.gemfile rename test/gemfiles/{rails-5.0.gemfile => rails-7.1.gemfile} (62%) rename test/gemfiles/{rails-5.1.gemfile => rails-8.0.gemfile} (62%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4307f11..2ca1033 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,16 +8,15 @@ concurrency: jobs: tests: + # Continue on error so that we see the results of all tests in the matrix. continue-on-error: true strategy: matrix: - ruby: [ "3.3", "3.2", "3.1", "3.0" ] - rails: [ "7.0", "6.1"] - include: - - { ruby: "2.7", rails: "6.0" } - - { ruby: "2.7", rails: "5.2" } - - { ruby: "2.7", rails: "5.1" } - - { ruby: "2.7", rails: "5.0" } + ruby: [ "3.4", "3.3", "3.2", "3.1" ] + rails: [ "8.0", "7.1", "7.0", "6.1" ] + exclude: + # Rails 8 needs Ruby 3.2 or higher + - { ruby: "3.1", rails: "8.0" } name: "tests (Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.rails }})" runs-on: ubuntu-latest env: diff --git a/.ruby-version b/.ruby-version index ef538c2..47b322c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.4.1 diff --git a/README.md b/README.md index ea03e70..c10d6ca 100644 --- a/README.md +++ b/README.md @@ -134,12 +134,6 @@ by default. But it's good to be aware of this in case you're running into weirdness. -# Known issues - * With Rails 5.0 in combination with uniqueness validations, ActiveRecord - generates a wrong query. The `x` in front of the queried value, which casts - the value to the proper data type, is missing. - - # Contributing To start coding on `mysql-binuuid-rails`, fork the project, clone it locally and then run `bin/setup` to get up and running. If you want to fool around in diff --git a/test/gemfiles/rails-5.2.gemfile b/test/gemfiles/rails-5.2.gemfile deleted file mode 100644 index d2f0191..0000000 --- a/test/gemfiles/rails-5.2.gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" -gemspec path: "../.." -gem "activerecord", "~> 5.2.0" diff --git a/test/gemfiles/rails-6.0.gemfile b/test/gemfiles/rails-6.0.gemfile deleted file mode 100644 index 445644b..0000000 --- a/test/gemfiles/rails-6.0.gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "https://rubygems.org" -gemspec path: "../.." -gem "activerecord", "~> 6.0.0" diff --git a/test/gemfiles/rails-6.1.gemfile b/test/gemfiles/rails-6.1.gemfile index 53669da..e1039a9 100644 --- a/test/gemfiles/rails-6.1.gemfile +++ b/test/gemfiles/rails-6.1.gemfile @@ -1,3 +1,7 @@ source "https://rubygems.org" gemspec path: "../.." gem "activerecord", "~> 6.1.0" + +gem "bigdecimal" +gem "drb" +gem "mutex_m" diff --git a/test/gemfiles/rails-7.0.gemfile b/test/gemfiles/rails-7.0.gemfile index aa81086..275a411 100644 --- a/test/gemfiles/rails-7.0.gemfile +++ b/test/gemfiles/rails-7.0.gemfile @@ -1,3 +1,7 @@ source "https://rubygems.org" gemspec path: "../.." gem "activerecord", "~> 7.0.0" + +gem "bigdecimal" +gem "drb" +gem "mutex_m" diff --git a/test/gemfiles/rails-5.0.gemfile b/test/gemfiles/rails-7.1.gemfile similarity index 62% rename from test/gemfiles/rails-5.0.gemfile rename to test/gemfiles/rails-7.1.gemfile index 2d7d4f0..f43c417 100644 --- a/test/gemfiles/rails-5.0.gemfile +++ b/test/gemfiles/rails-7.1.gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" gemspec path: "../.." -gem "activerecord", "~> 5.0.0" +gem "activerecord", "~> 7.1.0" diff --git a/test/gemfiles/rails-5.1.gemfile b/test/gemfiles/rails-8.0.gemfile similarity index 62% rename from test/gemfiles/rails-5.1.gemfile rename to test/gemfiles/rails-8.0.gemfile index 4dda832..4a9f4e9 100644 --- a/test/gemfiles/rails-5.1.gemfile +++ b/test/gemfiles/rails-8.0.gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" gemspec path: "../.." -gem "activerecord", "~> 5.1.0" +gem "activerecord", "~> 8.0.0" diff --git a/test/integration/mysql_integration_test.rb b/test/integration/mysql_integration_test.rb index de1ce75..64096a7 100644 --- a/test/integration/mysql_integration_test.rb +++ b/test/integration/mysql_integration_test.rb @@ -53,10 +53,6 @@ class BeforePersistedTest < MySQLIntegrationTest end test "validates uniqueness" do - if ActiveRecord.version < Gem::Version.new("5.1.0") - skip("Skipping uniqueness validation test, known issue on Rails/ActiveRecord 5.0") - end - uuid = SecureRandom.uuid MyUuidModelWithValidations.create!(the_uuid: uuid) duplicate = MyUuidModelWithValidations.new(the_uuid: uuid) @@ -106,7 +102,9 @@ class AfterPersistedTest < MySQLIntegrationTest end test "can't be used to inject SQL using .where" do - assert_raises MySQLBinUUID::InvalidUUID do + # In Rails 7.1, the error gets wrapped in an ActiveRecord::StatementInvalid. + expected_error = ActiveRecord.version.to_s.start_with?("7.1") ? ActiveRecord::StatementInvalid : MySQLBinUUID::InvalidUUID + assert_raises(expected_error) do MyUuidModel.where(the_uuid: "' OR ''='").first end end