diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index 373c2b554..ac8aab7f8 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -39,8 +39,14 @@ jobs: name: Bundle update adapters run: | for gemfile_path in gemfiles/*.gemfile; do + # Edge Gemfiles intentionally have no lockfile so CI resolves rails/main at run time. + case "${gemfile_path}" in + *_edge.gemfile) continue ;; + esac + BUNDLE_GEMFILE="${gemfile_path}" bundle update done + rm -f gemfiles/*_edge.gemfile.lock - name: Create Pull Request id: cpr diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b56c62c6b..f887bc183 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ concurrency: jobs: semian: - name: Ruby ${{ matrix.ruby }} / semian + name: Ruby ${{ matrix.ruby }} / semian / Rails ${{ matrix.rails_version }} runs-on: ubuntu-latest container: image: ruby:${{ matrix.ruby }} @@ -28,14 +28,21 @@ jobs: options: --hostname http-server env: CI: "1" - BUNDLE_GEMFILE: Gemfile + BUNDLE_GEMFILE: ${{ matrix.gemfile }} strategy: - fail-fast: true + fail-fast: false matrix: ruby: - "3.4" - "3.3" - - "3.2" + gemfile: + - Gemfile + - gemfiles/rails_edge.gemfile + include: + - gemfile: Gemfile + rails_version: released + - gemfile: gemfiles/rails_edge.gemfile + rails_version: edge services: mysql: image: mysql:9.3 @@ -74,9 +81,9 @@ jobs: with: path: vendor/bundle # yamllint disable-line rule:line-length - key: ${{ runner.os }}-ruby-${{ matrix.ruby }}-gems-${{ hashFiles( format('{0}.lock', env.BUNDLE_GEMFILE) ) }} + key: ${{ runner.os }}-ruby-${{ matrix.ruby }}-semian-${{ matrix.rails_version }}-gems-${{ hashFiles(env.BUNDLE_GEMFILE, format('{0}.lock', env.BUNDLE_GEMFILE)) }} restore-keys: | - ${{ runner.os }}-ruby-${{ matrix.ruby }}-gems- + ${{ runner.os }}-ruby-${{ matrix.ruby }}-semian-${{ matrix.rails_version }}-gems- - name: Bundle run: | @@ -122,18 +129,21 @@ jobs: ruby: - "3.4" - "3.3" - - "3.2" gemfile: - grpc - mysql2 - net_http - rails_mysql2 + - rails_mysql2_edge - rails_trilogy + - rails_trilogy_edge - redis_4 - redis_5 - redis_client - activerecord_trilogy_adapter + - activerecord_trilogy_adapter_edge - activerecord_postgresql_adapter + - activerecord_postgresql_adapter_edge include: - gemfile: grpc adapter: grpc @@ -143,8 +153,12 @@ jobs: adapter: net_http - gemfile: rails_mysql2 adapter: rails_mysql2 + - gemfile: rails_mysql2_edge + adapter: rails_mysql2 - gemfile: rails_trilogy adapter: rails_trilogy + - gemfile: rails_trilogy_edge + adapter: rails_trilogy - gemfile: redis_4 adapter: redis - gemfile: redis_5 @@ -153,8 +167,12 @@ jobs: adapter: redis_client - gemfile: activerecord_trilogy_adapter adapter: activerecord_trilogy_adapter + - gemfile: activerecord_trilogy_adapter_edge + adapter: activerecord_trilogy_adapter - gemfile: activerecord_postgresql_adapter adapter: activerecord_postgresql_adapter + - gemfile: activerecord_postgresql_adapter_edge + adapter: activerecord_postgresql_adapter services: mysql: image: mysql:9.3 @@ -193,7 +211,7 @@ jobs: with: path: vendor/bundle # yamllint disable-line rule:line-length - key: ${{ runner.os }}-ruby-${{ matrix.ruby }}-adapter-${{ matrix.gemfile }}-gems-${{ hashFiles( format('{0}.lock', env.BUNDLE_GEMFILE) ) }} + key: ${{ runner.os }}-ruby-${{ matrix.ruby }}-adapter-${{ matrix.gemfile }}-gems-${{ hashFiles(env.BUNDLE_GEMFILE, format('{0}.lock', env.BUNDLE_GEMFILE)) }} restore-keys: | ${{ runner.os }}-ruby-${{ matrix.ruby }}-adapter-${{ matrix.gemfile }}-gems- - diff --git a/.gitignore b/.gitignore index 06ba450d6..7720e24ad 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ .vscode/ipch .vscode/launch.json *.gem +gemfiles/*.gemfile.lock *.swo *.swp /checksums/ diff --git a/Gemfile b/Gemfile index 96b2a9e1c..382d27c17 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ group :test do gem "benchmark-memory" gem "benchmark-ips" gem "memory_profiler" - gem "minitest" + gem "minitest", "5.26.2" gem "mocha" gem "pry-byebug", require: false gem "toxiproxy" @@ -22,7 +22,7 @@ group :test do gem "mysql2", "~> 0.5" gem "trilogy", "~> 2.9" gem "pg", "~> 1.6" - gem "activerecord", github: "rails/rails", branch: "main" + gem "activerecord", "~> 8.1.0" gem "hiredis", "~> 0.6" # NOTE: v0.12.0 required for ruby 3.2.0. https://github.com/redis-rb/redis-client/issues/58 gem "hiredis-client", ">= 0.12.0" diff --git a/Gemfile.lock b/Gemfile.lock index 869077c70..46bea22b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,15 +1,19 @@ -GIT - remote: https://github.com/rails/rails.git - revision: 12188144b205bcb7a67adb05d9913ea7a256d54c - branch: main +PATH + remote: . specs: - activemodel (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - activerecord (8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) + semian (0.28.2) + concurrent-ruby + +GEM + remote: https://rubygems.org/ + specs: + activemodel (8.1.3.1) + activesupport (= 8.1.3.1) + activerecord (8.1.3.1) + activemodel (= 8.1.3.1) + activesupport (= 8.1.3.1) timeout (>= 0.4.0) - activesupport (8.2.0.alpha) + activesupport (8.1.3.1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -22,26 +26,16 @@ GIT securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - -PATH - remote: . - specs: - semian (0.28.2) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: ast (2.4.3) base64 (0.3.0) benchmark-ips (2.14.0) benchmark-memory (0.2.0) memory_profiler (~> 1) - bigdecimal (3.3.1) + bigdecimal (4.1.2) byebug (12.0.0) coderay (1.1.3) - concurrent-ruby (1.3.5) - connection_pool (3.0.1) + concurrent-ruby (1.3.8) + connection_pool (3.0.2) date (3.4.1) debug (1.11.0) irb (~> 1.10) @@ -77,14 +71,14 @@ GEM hiredis (0.6.3) hiredis-client (0.26.1) redis-client (= 0.26.1) - i18n (1.14.7) + i18n (1.15.2) concurrent-ruby (~> 1.0) io-console (0.8.0) irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.15.2) + json (2.21.2) language_server-protocol (3.17.0.5) lint_roller (1.1.0) logger (1.7.0) @@ -163,7 +157,7 @@ GEM ruby2_keywords (0.0.5) securerandom (0.4.1) stringio (3.1.7) - timeout (0.4.4) + timeout (0.6.1) toxiproxy (2.0.2) trilogy (2.9.0) tzinfo (2.0.6) @@ -187,7 +181,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - activerecord! + activerecord (~> 8.1.0) benchmark-ips benchmark-memory bigdecimal @@ -197,7 +191,7 @@ DEPENDENCIES hiredis (~> 0.6) hiredis-client (>= 0.12.0) memory_profiler - minitest + minitest (= 5.26.2) mocha mutex_m mysql2 (~> 0.5) @@ -217,4 +211,4 @@ DEPENDENCIES webrick BUNDLED WITH - 2.6.2 + 2.6.9 diff --git a/gemfiles/activerecord_postgresql_adapter.gemfile b/gemfiles/activerecord_postgresql_adapter.gemfile index a3afa01fa..50a5c7c31 100644 --- a/gemfiles/activerecord_postgresql_adapter.gemfile +++ b/gemfiles/activerecord_postgresql_adapter.gemfile @@ -11,6 +11,6 @@ gem "webrick" gem "concurrent-ruby" gem "pg", "~> 1.6" -gem "activerecord", github: "rails/rails" +gem "activerecord", "~> 8.1.0" gemspec path: "../" diff --git a/gemfiles/activerecord_postgresql_adapter.gemfile.lock b/gemfiles/activerecord_postgresql_adapter.gemfile.lock deleted file mode 100644 index 40b84ce22..000000000 --- a/gemfiles/activerecord_postgresql_adapter.gemfile.lock +++ /dev/null @@ -1,89 +0,0 @@ -GIT - remote: https://github.com/rails/rails.git - revision: a84c99b1a6a80d0be5059626941deea09c898446 - specs: - activemodel (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - activerecord (8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - timeout (>= 0.4.0) - activesupport (8.2.0.alpha) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - base64 (0.3.0) - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - drb (2.2.3) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - json (2.18.0) - logger (1.7.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - pg (1.6.2) - pg (1.6.2-aarch64-linux) - pg (1.6.2-aarch64-linux-musl) - pg (1.6.2-arm64-darwin) - pg (1.6.2-x86_64-darwin) - pg (1.6.2-x86_64-linux) - pg (1.6.2-x86_64-linux-musl) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - securerandom (0.4.1) - timeout (0.6.0) - toxiproxy (2.0.2) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.1.1) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - aarch64-linux-musl - arm64-darwin - ruby - x86_64-darwin - x86_64-linux - x86_64-linux-musl - -DEPENDENCIES - activerecord! - concurrent-ruby - minitest - mocha - pg (~> 1.6) - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/activerecord_postgresql_adapter_edge.gemfile b/gemfiles/activerecord_postgresql_adapter_edge.gemfile new file mode 100644 index 000000000..1b2a26c6b --- /dev/null +++ b/gemfiles/activerecord_postgresql_adapter_edge.gemfile @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rake" +gem "rake-compiler" +gem "minitest" +gem "mocha" +gem "toxiproxy" +gem "webrick" +gem "concurrent-ruby" + +gem "pg", "~> 1.6" +gem "activerecord", github: "rails/rails", branch: "main" + +gemspec path: "../" diff --git a/gemfiles/activerecord_trilogy_adapter.gemfile b/gemfiles/activerecord_trilogy_adapter.gemfile index 5f0ed4a6d..17b1f3e9e 100644 --- a/gemfiles/activerecord_trilogy_adapter.gemfile +++ b/gemfiles/activerecord_trilogy_adapter.gemfile @@ -11,6 +11,6 @@ gem "webrick" gem "concurrent-ruby" gem "trilogy", "~> 2.4" -gem "activerecord", github: "rails/rails" +gem "activerecord", "~> 8.1.0" gemspec path: "../" diff --git a/gemfiles/activerecord_trilogy_adapter.gemfile.lock b/gemfiles/activerecord_trilogy_adapter.gemfile.lock deleted file mode 100644 index 38fb608dc..000000000 --- a/gemfiles/activerecord_trilogy_adapter.gemfile.lock +++ /dev/null @@ -1,80 +0,0 @@ -GIT - remote: https://github.com/rails/rails.git - revision: a84c99b1a6a80d0be5059626941deea09c898446 - specs: - activemodel (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - activerecord (8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - timeout (>= 0.4.0) - activesupport (8.2.0.alpha) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - base64 (0.3.0) - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - drb (2.2.3) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - json (2.18.0) - logger (1.7.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - securerandom (0.4.1) - timeout (0.6.0) - toxiproxy (2.0.2) - trilogy (2.9.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.1.1) - webrick (1.9.2) - -PLATFORMS - arm64-darwin-21 - arm64-darwin-22 - arm64-darwin-24 - x86_64-linux - -DEPENDENCIES - activerecord! - concurrent-ruby - minitest - mocha - rake - rake-compiler - semian! - toxiproxy - trilogy (~> 2.4) - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/activerecord_trilogy_adapter_edge.gemfile b/gemfiles/activerecord_trilogy_adapter_edge.gemfile new file mode 100644 index 000000000..8e4afe976 --- /dev/null +++ b/gemfiles/activerecord_trilogy_adapter_edge.gemfile @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rake" +gem "rake-compiler" +gem "minitest" +gem "mocha" +gem "toxiproxy" +gem "webrick" +gem "concurrent-ruby" + +gem "trilogy", "~> 2.4" +gem "activerecord", github: "rails/rails", branch: "main" + +gemspec path: "../" diff --git a/gemfiles/grpc.gemfile.lock b/gemfiles/grpc.gemfile.lock deleted file mode 100644 index 5d4d9d8ca..000000000 --- a/gemfiles/grpc.gemfile.lock +++ /dev/null @@ -1,75 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - google-protobuf (4.33.2) - bigdecimal - rake (>= 13) - google-protobuf (4.33.2-aarch64-linux-gnu) - bigdecimal - rake (>= 13) - google-protobuf (4.33.2-arm64-darwin) - bigdecimal - rake (>= 13) - google-protobuf (4.33.2-x86_64-darwin) - bigdecimal - rake (>= 13) - google-protobuf (4.33.2-x86_64-linux-gnu) - bigdecimal - rake (>= 13) - googleapis-common-protos-types (1.22.0) - google-protobuf (~> 4.26) - grpc (1.76.0) - google-protobuf (>= 3.25, < 5.0) - googleapis-common-protos-types (~> 1.0) - grpc (1.76.0-aarch64-linux-gnu) - google-protobuf (>= 3.25, < 5.0) - googleapis-common-protos-types (~> 1.0) - grpc (1.76.0-arm64-darwin) - google-protobuf (>= 3.25, < 5.0) - googleapis-common-protos-types (~> 1.0) - grpc (1.76.0-x86_64-darwin) - google-protobuf (>= 3.25, < 5.0) - googleapis-common-protos-types (~> 1.0) - grpc (1.76.0-x86_64-linux-gnu) - google-protobuf (>= 3.25, < 5.0) - googleapis-common-protos-types (~> 1.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - concurrent-ruby - grpc - minitest - mocha - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/mysql2.gemfile.lock b/gemfiles/mysql2.gemfile.lock deleted file mode 100644 index 9f45efb8c..000000000 --- a/gemfiles/mysql2.gemfile.lock +++ /dev/null @@ -1,48 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - mutex_m (0.3.0) - mysql2 (0.5.7) - bigdecimal - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - bigdecimal - concurrent-ruby - minitest - mocha - mutex_m - mysql2 (~> 0.5) - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/net_http.gemfile.lock b/gemfiles/net_http.gemfile.lock deleted file mode 100644 index c57717b48..000000000 --- a/gemfiles/net_http.gemfile.lock +++ /dev/null @@ -1,41 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - concurrent-ruby (1.3.6) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - concurrent-ruby - minitest - mocha - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/rails.gemfile b/gemfiles/rails.gemfile index 00f15ce40..c27324519 100644 --- a/gemfiles/rails.gemfile +++ b/gemfiles/rails.gemfile @@ -11,6 +11,6 @@ gem "webrick" gem "concurrent-ruby" gem "mysql2", "~> 0.5" -gem "activerecord", ">= 7.0.3" +gem "activerecord", "~> 8.1.0" gemspec path: "../" diff --git a/gemfiles/rails.gemfile.lock b/gemfiles/rails.gemfile.lock deleted file mode 100644 index 6a591e65f..000000000 --- a/gemfiles/rails.gemfile.lock +++ /dev/null @@ -1,77 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - activemodel (8.1.1) - activesupport (= 8.1.1) - activerecord (8.1.1) - activemodel (= 8.1.1) - activesupport (= 8.1.1) - timeout (>= 0.4.0) - activesupport (8.1.1) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - base64 (0.3.0) - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - drb (2.2.3) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - json (2.18.0) - logger (1.7.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - mysql2 (0.5.7) - bigdecimal - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - securerandom (0.4.1) - timeout (0.6.0) - toxiproxy (2.0.2) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.1.1) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - activerecord (>= 7.0.3) - concurrent-ruby - minitest - mocha - mysql2 (~> 0.5) - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/rails_edge.gemfile b/gemfiles/rails_edge.gemfile new file mode 100644 index 000000000..eb94b04f4 --- /dev/null +++ b/gemfiles/rails_edge.gemfile @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rake" +gem "rake-compiler" +gem "concurrent-ruby" + +group :test do + gem "benchmark-memory" + gem "benchmark-ips" + gem "memory_profiler" + gem "minitest", "5.26.2" + gem "mocha" + gem "pry-byebug", require: false + gem "toxiproxy" + gem "webrick" + + gem "bigdecimal" + gem "mutex_m" + gem "grpc", "1.76.0" + gem "mysql2", "~> 0.5" + gem "trilogy", "~> 2.9" + gem "pg", "~> 1.6" + gem "activerecord", github: "rails/rails", branch: "main" + gem "hiredis", "~> 0.6" + # NOTE: v0.12.0 required for ruby 3.2.0. https://github.com/redis-rb/redis-client/issues/58 + gem "hiredis-client", ">= 0.12.0" + gem "redis" + gem "debug" +end + +gemspec path: "../" diff --git a/gemfiles/rails_mysql2.gemfile b/gemfiles/rails_mysql2.gemfile index 00f15ce40..c27324519 100644 --- a/gemfiles/rails_mysql2.gemfile +++ b/gemfiles/rails_mysql2.gemfile @@ -11,6 +11,6 @@ gem "webrick" gem "concurrent-ruby" gem "mysql2", "~> 0.5" -gem "activerecord", ">= 7.0.3" +gem "activerecord", "~> 8.1.0" gemspec path: "../" diff --git a/gemfiles/rails_mysql2.gemfile.lock b/gemfiles/rails_mysql2.gemfile.lock deleted file mode 100644 index 6a591e65f..000000000 --- a/gemfiles/rails_mysql2.gemfile.lock +++ /dev/null @@ -1,77 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - activemodel (8.1.1) - activesupport (= 8.1.1) - activerecord (8.1.1) - activemodel (= 8.1.1) - activesupport (= 8.1.1) - timeout (>= 0.4.0) - activesupport (8.1.1) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - base64 (0.3.0) - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - drb (2.2.3) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - json (2.18.0) - logger (1.7.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - mysql2 (0.5.7) - bigdecimal - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - securerandom (0.4.1) - timeout (0.6.0) - toxiproxy (2.0.2) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.1.1) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - activerecord (>= 7.0.3) - concurrent-ruby - minitest - mocha - mysql2 (~> 0.5) - rake - rake-compiler - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/rails_mysql2_edge.gemfile b/gemfiles/rails_mysql2_edge.gemfile new file mode 100644 index 000000000..374fa446f --- /dev/null +++ b/gemfiles/rails_mysql2_edge.gemfile @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rake" +gem "rake-compiler" +gem "minitest" +gem "mocha" +gem "toxiproxy" +gem "webrick" +gem "concurrent-ruby" + +gem "mysql2", "~> 0.5" +gem "activerecord", github: "rails/rails", branch: "main" + +gemspec path: "../" diff --git a/gemfiles/rails_trilogy.gemfile b/gemfiles/rails_trilogy.gemfile index 0b9fff0e2..17b1f3e9e 100644 --- a/gemfiles/rails_trilogy.gemfile +++ b/gemfiles/rails_trilogy.gemfile @@ -11,7 +11,6 @@ gem "webrick" gem "concurrent-ruby" gem "trilogy", "~> 2.4" -# we can share the Gemfile with rails mysql2 once activerecord is released with the trilogy adapter -gem "activerecord", github: "rails/rails", branch: "main" +gem "activerecord", "~> 8.1.0" gemspec path: "../" diff --git a/gemfiles/rails_trilogy.gemfile.lock b/gemfiles/rails_trilogy.gemfile.lock deleted file mode 100644 index 846a6d68a..000000000 --- a/gemfiles/rails_trilogy.gemfile.lock +++ /dev/null @@ -1,80 +0,0 @@ -GIT - remote: https://github.com/rails/rails.git - revision: a84c99b1a6a80d0be5059626941deea09c898446 - branch: main - specs: - activemodel (8.2.0.alpha) - activesupport (= 8.2.0.alpha) - activerecord (8.2.0.alpha) - activemodel (= 8.2.0.alpha) - activesupport (= 8.2.0.alpha) - timeout (>= 0.4.0) - activesupport (8.2.0.alpha) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.3.1) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - json - logger (>= 1.4.2) - minitest (>= 5.1) - securerandom (>= 0.3) - tzinfo (~> 2.0, >= 2.0.5) - uri (>= 0.13.1) - -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - base64 (0.3.0) - bigdecimal (4.0.1) - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - drb (2.2.3) - i18n (1.14.7) - concurrent-ruby (~> 1.0) - json (2.18.0) - logger (1.7.0) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - securerandom (0.4.1) - timeout (0.6.0) - toxiproxy (2.0.2) - trilogy (2.9.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - uri (1.1.1) - webrick (1.9.2) - -PLATFORMS - arm64-darwin-22 - arm64-darwin-24 - x86_64-linux - -DEPENDENCIES - activerecord! - concurrent-ruby - minitest - mocha - rake - rake-compiler - semian! - toxiproxy - trilogy (~> 2.4) - webrick - -BUNDLED WITH - 2.6.2 diff --git a/gemfiles/rails_trilogy_edge.gemfile b/gemfiles/rails_trilogy_edge.gemfile new file mode 100644 index 000000000..8e4afe976 --- /dev/null +++ b/gemfiles/rails_trilogy_edge.gemfile @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rake" +gem "rake-compiler" +gem "minitest" +gem "mocha" +gem "toxiproxy" +gem "webrick" +gem "concurrent-ruby" + +gem "trilogy", "~> 2.4" +gem "activerecord", github: "rails/rails", branch: "main" + +gemspec path: "../" diff --git a/gemfiles/redis_4.gemfile.lock b/gemfiles/redis_4.gemfile.lock deleted file mode 100644 index a85601bed..000000000 --- a/gemfiles/redis_4.gemfile.lock +++ /dev/null @@ -1,51 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - hiredis (0.6.3) - hiredis-client (0.26.2) - redis-client (= 0.26.2) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - redis (4.8.1) - redis-client (0.26.2) - connection_pool - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - concurrent-ruby - hiredis (~> 0.6) - hiredis-client - minitest - mocha - rake - rake-compiler - redis (~> 4.8) - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/gemfiles/redis_5.gemfile.lock b/gemfiles/redis_5.gemfile.lock deleted file mode 100644 index cf1e42274..000000000 --- a/gemfiles/redis_5.gemfile.lock +++ /dev/null @@ -1,52 +0,0 @@ -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - hiredis (0.6.3) - hiredis-client (0.26.2) - redis-client (= 0.26.2) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - redis (5.4.1) - redis-client (>= 0.22.0) - redis-client (0.26.2) - connection_pool - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - concurrent-ruby - hiredis (~> 0.6) - hiredis-client (>= 0.12.0) - minitest - mocha - rake - rake-compiler - redis - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.2 diff --git a/gemfiles/redis_client.gemfile.lock b/gemfiles/redis_client.gemfile.lock deleted file mode 100644 index f258f207f..000000000 --- a/gemfiles/redis_client.gemfile.lock +++ /dev/null @@ -1,62 +0,0 @@ -GIT - remote: https://github.com/redis-rb/redis-client.git - revision: 7655bb8d2a86b5c7457271febf0807250f58b4b1 - specs: - hiredis-client (0.26.2) - redis-client (= 0.26.2) - redis-client (0.26.2) - connection_pool - -GIT - remote: https://github.com/redis/redis-rb.git - revision: 028059d13f86cea6ca7331539077b0cf9afa30ae - specs: - redis (5.4.1) - redis-client (>= 0.22.0) - -PATH - remote: .. - specs: - semian (0.26.6) - concurrent-ruby - -GEM - remote: https://rubygems.org/ - specs: - concurrent-ruby (1.3.6) - connection_pool (3.0.2) - hiredis (0.6.3) - minitest (6.0.0) - prism (~> 1.5) - mocha (3.0.1) - ruby2_keywords (>= 0.0.5) - prism (1.7.0) - rake (13.3.1) - rake-compiler (1.3.1) - rake - ruby2_keywords (0.0.5) - toxiproxy (2.0.2) - webrick (1.9.2) - -PLATFORMS - aarch64-linux - arm64-darwin-21 - ruby - x86_64-darwin-21 - x86_64-linux - -DEPENDENCIES - concurrent-ruby - hiredis (~> 0.6) - hiredis-client! - minitest - mocha - rake - rake-compiler - redis! - semian! - toxiproxy - webrick - -BUNDLED WITH - 2.6.9 diff --git a/lib/semian/activerecord_adapter.rb b/lib/semian/activerecord_adapter.rb index 6330d96e3..379729b60 100644 --- a/lib/semian/activerecord_adapter.rb +++ b/lib/semian/activerecord_adapter.rb @@ -58,8 +58,26 @@ def initialize(*options) def execute_intent(intent) return super if self.class.query_allowlisted?(intent.processed_sql) + result = nil + delivered_error = nil + acquire_semian_resource(adapter: semian_adapter_name, scope: :query) do - super + result = super + + # In Rails 8.2 execute_intent no longer raises errors. Instead, they are stored on the intent + # and handled later by the caller to better enable asynchronous execution. However, we need to raise + # any errors here to trip the circuit breaker. Then we can swallow the error and return the result for + # Rails to continue with. + if intent.respond_to?(:error) + delivered_error = intent.error + raise delivered_error if delivered_error + end + end + rescue => error + if error.equal?(delivered_error) + result + else + raise end end else diff --git a/lib/semian/activerecord_postgresql_adapter.rb b/lib/semian/activerecord_postgresql_adapter.rb index 29f0fc74c..b284dafc7 100644 --- a/lib/semian/activerecord_postgresql_adapter.rb +++ b/lib/semian/activerecord_postgresql_adapter.rb @@ -7,6 +7,7 @@ module ActiveRecord module ConnectionAdapters class PostgreSQLAdapter ActiveRecord::ActiveRecordError.include(::Semian::AdapterError) + ::PG::ConnectionBad.include(::Semian::AdapterError) class SemianError < ConnectionNotEstablished def initialize(semian_identifier, *args) @@ -40,6 +41,10 @@ def with_resource_timeout(_temp_timeout) private + def resource_exceptions + super + [::PG::ConnectionBad] + end + def semian_adapter_name = :postgresql_adapter def semian_adapter_default_port = 5432 diff --git a/test/adapters/activerecord_adapter_shared_tests.rb b/test/adapters/activerecord_adapter_shared_tests.rb index 4a4598e69..284dc5da1 100644 --- a/test/adapters/activerecord_adapter_shared_tests.rb +++ b/test/adapters/activerecord_adapter_shared_tests.rb @@ -75,7 +75,7 @@ def test_unconfigured def test_connection_errors_open_the_circuit @proxy.downstream(:latency, latency: 2200).apply do ERROR_THRESHOLD.times do - assert_raises(ActiveRecord::ConnectionNotEstablished) do + assert_raises(*connection_failed_error_classes) do @adapter.execute("SELECT 1;") end end @@ -162,7 +162,7 @@ def test_active_instrumentation def test_network_errors_are_tagged_with_the_resource_identifier @proxy.down do - error = assert_raises(ActiveRecord::ConnectionNotEstablished) do + error = assert_raises(*connection_failed_error_classes) do @adapter.execute("SELECT 1 + 1;") end @@ -173,7 +173,7 @@ def test_network_errors_are_tagged_with_the_resource_identifier def test_connection_failed_errors_are_tagged_with_the_resource_identifier @adapter.send(:raw_connection).close - error = assert_raises(ActiveRecord::ConnectionFailed, ActiveRecord::ConnectionNotEstablished) do + error = assert_raises(*connection_failed_error_classes) do @adapter.execute("SELECT 1 + 1;") end @@ -333,7 +333,7 @@ def test_semian_allows_rollback_to_savepoint def test_circuit_open_errors_do_not_trigger_the_circuit_breaker @proxy.down do ERROR_THRESHOLD.times do - assert_raises(ActiveRecord::ConnectionNotEstablished) do + assert_raises(*connection_failed_error_classes) do @adapter.execute("SELECT 1;") end end @@ -343,7 +343,7 @@ def test_circuit_open_errors_do_not_trigger_the_circuit_breaker end error = adapter_resource.circuit_breaker.last_error - assert_instance_of(ActiveRecord::ConnectionNotEstablished, error) + assert_includes(connection_failed_error_classes, error.class) end end @@ -357,6 +357,10 @@ def new_adapter(**config_overrides) adapter_class.new(@configuration.merge(config_overrides)) end + def connection_failed_error_classes + [ActiveRecord::ConnectionFailed, ActiveRecord::ConnectionNotEstablished] + end + def adapter_name raise NotImplementedError end diff --git a/test/adapters/activerecord_postgresql_adapter_test.rb b/test/adapters/activerecord_postgresql_adapter_test.rb index c35e51c2d..643448bc2 100644 --- a/test/adapters/activerecord_postgresql_adapter_test.rb +++ b/test/adapters/activerecord_postgresql_adapter_test.rb @@ -41,6 +41,10 @@ def adapter_class PostgreSQLAdapter end + def connection_failed_error_classes + super + [::PG::ConnectionBad] + end + def adapter_name :postgresql_adapter end