diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d491ed..3e3c47b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,31 +15,24 @@ jobs: fail-fast: false matrix: ruby: - - "2.5" - - "2.6" - - "2.7" - - "3.0" - "3.1" - "3.2" + - "3.3" + - "3.4" gemfile: - - gemfiles/activesupport_5_2.gemfile - - gemfiles/activesupport_6_0.gemfile - - gemfiles/activesupport_6_1.gemfile - gemfiles/activesupport_7_0.gemfile + - gemfiles/activesupport_7_1.gemfile + - gemfiles/activesupport_7_2.gemfile - gemfiles/without_activesupport.gemfile + - gemfiles/dalli_3.gemfile + - gemfiles/dalli_4.gemfile + - gemfiles/dalli_5.gemfile exclude: - - ruby: "2.5" - gemfile: gemfiles/activesupport_7_0.gemfile - - ruby: "2.6" - gemfile: gemfiles/activesupport_7_0.gemfile - - ruby: "3.0" - gemfile: gemfiles/activesupport_5_2.gemfile - - ruby: "3.0" - gemfile: gemfiles/activesupport_5_2.gemfile + # dalli 5.x requires Ruby 3.3+ - ruby: "3.1" - gemfile: gemfiles/activesupport_5_2.gemfile + gemfile: gemfiles/dalli_5.gemfile - ruby: "3.2" - gemfile: gemfiles/activesupport_5_2.gemfile + gemfile: gemfiles/dalli_5.gemfile services: memcached_11211: image: memcached diff --git a/.rubocop.yml b/.rubocop.yml index ecdba0a..b56803b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ AllCops: - "vendor/**/*" DisplayCopNames: true NewCops: disable - TargetRubyVersion: 2.5 + TargetRubyVersion: 3.1 SuggestExtensions: false Style/AsciiComments: diff --git a/.ruby-version b/.ruby-version index b347b11..37d02a6 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.3 +3.3.8 diff --git a/Appraisals b/Appraisals index 9447289..3817ead 100644 --- a/Appraisals +++ b/Appraisals @@ -1,18 +1,30 @@ appraise "without_activesupport" do end -appraise "activesupport_5_2" do - gem "activesupport", "~> 5.2.8.1" +appraise "activesupport_7_0" do + gem "activesupport", "~> 7.0.8" end -appraise "activesupport_6_0" do - gem "activesupport", "~> 6.0.6.1" +appraise "activesupport_7_1" do + gem "activesupport", "~> 7.1.5" end -appraise "activesupport_6_1" do - gem "activesupport", "~> 6.1.7.7" +appraise "activesupport_7_2" do + gem "activesupport", "~> 7.2.2" end -appraise "activesupport_7_0" do - gem "activesupport", "~> 7.0.8.1" +# dalli version tests +appraise "dalli_3" do + gem "activesupport", "~> 7.2.2" + gem "dalli", "~> 3.2" +end + +appraise "dalli_4" do + gem "activesupport", "~> 7.2.2" + gem "dalli", "~> 4.3" +end + +appraise "dalli_5" do + gem "activesupport", "~> 7.2.2" + gem "dalli", "~> 5.0" end diff --git a/README.md b/README.md index 34af940..3cde1a9 100644 --- a/README.md +++ b/README.md @@ -61,16 +61,24 @@ end ## Run tests locally -``` +```bash docker compose up -d bundle install bundle exec appraisal install + +# Run tests with specific ActiveSupport version +bundle exec appraisal activesupport_7_2 rake +bundle exec appraisal activesupport_7_1 rake bundle exec appraisal activesupport_7_0 rake +bundle exec appraisal activesupport_6_1 rake + +# Run tests with specific dalli version +bundle exec appraisal dalli_5 rake +bundle exec appraisal dalli_4 rake +bundle exec appraisal dalli_3 rake -#bundle exec appraisal activesupport_5_2 rake -#bundle exec appraisal activesupport_6_0 rake -#bundle exec appraisal activesupport_6_1 rake -#bundle exec appraisal without_activesupport rake +# Run tests without ActiveSupport +bundle exec appraisal without_activesupport rake ``` ## Contributing diff --git a/double_write_cache_stores.gemspec b/double_write_cache_stores.gemspec index f197728..e30e0f8 100644 --- a/double_write_cache_stores.gemspec +++ b/double_write_cache_stores.gemspec @@ -17,9 +17,9 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.required_ruby_version = Gem::Requirement.new(">= 2.5") + spec.required_ruby_version = Gem::Requirement.new(">= 3.1") - spec.add_runtime_dependency "dalli", "~> 3.0" + spec.add_runtime_dependency "dalli", ">= 3.0", "< 6.0" spec.add_development_dependency "appraisal", "~> 2.5.0" spec.add_development_dependency "bundler", "~> 2.0" diff --git a/gemfiles/activesupport_7_0.gemfile b/gemfiles/activesupport_7_0.gemfile index dd928fe..6f99b2c 100644 --- a/gemfiles/activesupport_7_0.gemfile +++ b/gemfiles/activesupport_7_0.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "activesupport", "~> 7.0.8.1" +gem "activesupport", "~> 7.0.8" gemspec path: "../" diff --git a/gemfiles/activesupport_5_2.gemfile b/gemfiles/activesupport_7_1.gemfile similarity index 73% rename from gemfiles/activesupport_5_2.gemfile rename to gemfiles/activesupport_7_1.gemfile index c9221e0..c53c285 100644 --- a/gemfiles/activesupport_5_2.gemfile +++ b/gemfiles/activesupport_7_1.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "activesupport", "~> 5.2.8.1" +gem "activesupport", "~> 7.1.5" gemspec path: "../" diff --git a/gemfiles/activesupport_6_0.gemfile b/gemfiles/activesupport_7_2.gemfile similarity index 73% rename from gemfiles/activesupport_6_0.gemfile rename to gemfiles/activesupport_7_2.gemfile index d0d6cf3..02456f4 100644 --- a/gemfiles/activesupport_6_0.gemfile +++ b/gemfiles/activesupport_7_2.gemfile @@ -2,6 +2,6 @@ source "https://rubygems.org" -gem "activesupport", "~> 6.0.6.1" +gem "activesupport", "~> 7.2.2" gemspec path: "../" diff --git a/gemfiles/activesupport_6_1.gemfile b/gemfiles/dalli_3.gemfile similarity index 63% rename from gemfiles/activesupport_6_1.gemfile rename to gemfiles/dalli_3.gemfile index 57dbf02..b0d28fe 100644 --- a/gemfiles/activesupport_6_1.gemfile +++ b/gemfiles/dalli_3.gemfile @@ -2,6 +2,7 @@ source "https://rubygems.org" -gem "activesupport", "~> 6.1.7.7" +gem "activesupport", "~> 7.2.2" +gem "dalli", "~> 3.2" gemspec path: "../" diff --git a/gemfiles/dalli_4.gemfile b/gemfiles/dalli_4.gemfile new file mode 100644 index 0000000..807b80b --- /dev/null +++ b/gemfiles/dalli_4.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activesupport", "~> 7.2.2" +gem "dalli", "~> 4.3" + +gemspec path: "../" diff --git a/gemfiles/dalli_5.gemfile b/gemfiles/dalli_5.gemfile new file mode 100644 index 0000000..5ba3e03 --- /dev/null +++ b/gemfiles/dalli_5.gemfile @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "activesupport", "~> 7.2.2" +gem "dalli", "~> 5.0" + +gemspec path: "../" diff --git a/spec/double_write_cache_stores/client_spec.rb b/spec/double_write_cache_stores/client_spec.rb index 27b0b7f..fda1f88 100644 --- a/spec/double_write_cache_stores/client_spec.rb +++ b/spec/double_write_cache_stores/client_spec.rb @@ -193,7 +193,7 @@ def get_or_read(store, key) end shared_examples "read cache after increment or decrement example" do - before { cache_store.set(key, 10, raw: true) } + before { cache_store.set(key, "10", raw: true) } it { expect((cache_store.read key).to_i).to eq expected_value } end @@ -207,7 +207,7 @@ def get_or_read(store, key) context "when options[:initial] does not exist" do context "when value exists" do - before { cache_store.set(key, 0, raw: true) } + before { cache_store.set(key, "0", raw: true) } context "when amount does not exist" do it { expect(cache_store.increment key).to eq 1 } @@ -240,7 +240,7 @@ def get_or_read(store, key) else let(:opt) { { initial: 12_345_678 } } context "when value exists" do - before { cache_store.set(key, 0, raw: true) } + before { cache_store.set(key, "0", raw: true) } it { expect(cache_store.increment key, 1, opt).to eq 1 } end context "when value does not exist" do @@ -260,7 +260,7 @@ def get_or_read(store, key) context "when options[:initial] does not exist" do context "when value exists" do - before { cache_store.set(key, 101, raw: true) } + before { cache_store.set(key, "101", raw: true) } context "when amount does not exist" do it { expect(cache_store.decrement key).to eq 100 } @@ -293,7 +293,7 @@ def get_or_read(store, key) else let(:opt) { { initial: 12_345_678 } } context "when value exists" do - before { cache_store.set(key, 101, raw: true) } + before { cache_store.set(key, "101", raw: true) } it { expect(cache_store.decrement key, 1, opt).to eq 100 } end context "when value does not exist" do @@ -347,12 +347,12 @@ def get_or_read(store, key) end describe "shard example" do - if DoubleWriteCacheStores.loaded_active_support? + if DoubleWriteCacheStores.loaded_active_support? && ActiveSupport::VERSION::MAJOR < 7 context "ActiveSupport MemCacheStore" do options = { raw: true, expires_in: 3600 } - read_and_write_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211", options - write_only_store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:21211", options + read_and_write_store = ActiveSupport::Cache.lookup_store(:mem_cache_store, "localhost:11211", options) + write_only_store = ActiveSupport::Cache.lookup_store(:mem_cache_store, "localhost:21211", options) context "double cache store" do copy_cache_store = DoubleWriteCacheStores::Client.new(read_and_write_store, write_only_store) @@ -365,7 +365,8 @@ def get_or_read(store, key) end end else - skip "Not load ActiveSupport" + as_version = DoubleWriteCacheStores.loaded_active_support? ? ActiveSupport::VERSION::STRING : "not loaded" + skip "ActiveSupport MemCacheStore requires ActiveSupport < 7 (current: #{as_version})" end context "Dalli::Client" do