diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fcb36a..f3ecda6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: PGUSER: postgres PGPASSWORD: postgres TESTOPTS: "--fail-fast" - + jobs: lint: name: "Lint" @@ -24,7 +24,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 3.4.7 bundler-cache: true - name: Lint code for consistent style @@ -53,7 +53,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 3.4.7 bundler-cache: true - name: Run tests @@ -82,8 +82,37 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 3.4.7 bundler-cache: true - name: Run tests - run: bundle exec rake \ No newline at end of file + run: bundle exec rake + + test_rails_8_1: + name: "Tests (Rails 8.1)" + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + ports: + - 5432:5432 + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_8_1.gemfile + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y curl libjemalloc2 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.4.7 + bundler-cache: true + + - name: Run tests + run: bundle exec rake diff --git a/.ruby-version b/.ruby-version index be94e6f..2aa5131 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.4.7 diff --git a/Appraisals b/Appraisals index 0896b06..7bcac9c 100644 --- a/Appraisals +++ b/Appraisals @@ -7,3 +7,8 @@ appraise "rails-8" do gem "rails", ">= 8.0" gem "async", "~> 2.25" end + +appraise "rails-8-1" do + gem "rails", ">= 8.1" + gem "async", "~> 2.25" +end diff --git a/Gemfile b/Gemfile index 4c9d979..33bfe57 100644 --- a/Gemfile +++ b/Gemfile @@ -7,3 +7,4 @@ gem "standard", require: false gem "rake", "~> 13.0" gem "minitest", "~> 5.0" gem "async", "~> 2.25" +gem "csv" # Used to be in stdlib diff --git a/gemfiles/.bundle/config b/gemfiles/.bundle/config new file mode 100644 index 0000000..c127f80 --- /dev/null +++ b/gemfiles/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_RETRY: "1" diff --git a/gemfiles/rails_7.gemfile b/gemfiles/rails_7.gemfile index 4b27ad4..675762f 100644 --- a/gemfiles/rails_7.gemfile +++ b/gemfiles/rails_7.gemfile @@ -6,6 +6,7 @@ gem "standard", require: false gem "rake", "~> 13.0" gem "minitest", "~> 5.0" gem "async", "~> 2.25" +gem "csv" gem "rails", "< 8.0" gemspec path: "../" diff --git a/gemfiles/rails_7.gemfile.lock b/gemfiles/rails_7.gemfile.lock index c5a9549..f92b9cd 100644 --- a/gemfiles/rails_7.gemfile.lock +++ b/gemfiles/rails_7.gemfile.lock @@ -106,6 +106,7 @@ GEM fiber-local (~> 1.1) json crass (1.0.6) + csv (3.3.5) date (3.4.1) debug (1.10.0) irb (~> 1.10) @@ -278,6 +279,7 @@ PLATFORMS DEPENDENCIES appraisal async (~> 2.25) + csv debug gouda! minitest (~> 5.0) diff --git a/gemfiles/rails_8.gemfile b/gemfiles/rails_8.gemfile index df119ef..3fd3b21 100644 --- a/gemfiles/rails_8.gemfile +++ b/gemfiles/rails_8.gemfile @@ -6,6 +6,7 @@ gem "standard", require: false gem "rake", "~> 13.0" gem "minitest", "~> 5.0" gem "async", "~> 2.25" +gem "csv" gem "rails", ">= 8.0" gemspec path: "../" diff --git a/gemfiles/rails_8.gemfile.lock b/gemfiles/rails_8.gemfile.lock index 391bdd9..c22ac51 100644 --- a/gemfiles/rails_8.gemfile.lock +++ b/gemfiles/rails_8.gemfile.lock @@ -106,6 +106,7 @@ GEM fiber-local (~> 1.1) json crass (1.0.6) + csv (3.3.5) date (3.4.1) debug (1.10.0) irb (~> 1.10) @@ -279,6 +280,7 @@ PLATFORMS DEPENDENCIES appraisal async (~> 2.25) + csv debug gouda! minitest (~> 5.0) diff --git a/gemfiles/rails_8_1.gemfile b/gemfiles/rails_8_1.gemfile new file mode 100644 index 0000000..3f20560 --- /dev/null +++ b/gemfiles/rails_8_1.gemfile @@ -0,0 +1,12 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "standard", require: false +gem "rake", "~> 13.0" +gem "minitest", "~> 5.0" +gem "async", "~> 2.25" +gem "csv" +gem "rails", ">= 8.1" + +gemspec path: "../" diff --git a/gemfiles/rails_8_1.gemfile.lock b/gemfiles/rails_8_1.gemfile.lock new file mode 100644 index 0000000..a15bde4 --- /dev/null +++ b/gemfiles/rails_8_1.gemfile.lock @@ -0,0 +1,303 @@ +PATH + remote: .. + specs: + gouda (0.2.0) + activejob (>= 7.2.0) + activerecord (>= 7.2.0) + activesupport (>= 7.2.0) + async (~> 2.25) + fugit (~> 1.10) + railties (>= 7.2.0) + +GEM + remote: https://rubygems.org/ + specs: + action_text-trix (2.1.15) + railties + actioncable (8.1.1) + actionpack (= 8.1.1) + activesupport (= 8.1.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (8.1.1) + actionpack (= 8.1.1) + activejob (= 8.1.1) + activerecord (= 8.1.1) + activestorage (= 8.1.1) + activesupport (= 8.1.1) + mail (>= 2.8.0) + actionmailer (8.1.1) + actionpack (= 8.1.1) + actionview (= 8.1.1) + activejob (= 8.1.1) + activesupport (= 8.1.1) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.1.1) + actionview (= 8.1.1) + activesupport (= 8.1.1) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.1.1) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.1) + activerecord (= 8.1.1) + activestorage (= 8.1.1) + activesupport (= 8.1.1) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.1.1) + activesupport (= 8.1.1) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.1.1) + activesupport (= 8.1.1) + globalid (>= 0.3.6) + activemodel (8.1.1) + activesupport (= 8.1.1) + activerecord (8.1.1) + activemodel (= 8.1.1) + activesupport (= 8.1.1) + timeout (>= 0.4.0) + activestorage (8.1.1) + actionpack (= 8.1.1) + activejob (= 8.1.1) + activerecord (= 8.1.1) + activesupport (= 8.1.1) + marcel (~> 1.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) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + ast (2.4.3) + async (2.34.0) + console (~> 1.29) + fiber-annotation + io-event (~> 1.11) + metrics (~> 0.12) + traces (~> 0.18) + base64 (0.3.0) + bigdecimal (3.3.1) + builder (3.3.0) + coderay (1.1.3) + concurrent-ruby (1.3.5) + connection_pool (2.5.4) + console (1.34.2) + fiber-annotation + fiber-local (~> 1.1) + json + crass (1.0.6) + csv (3.3.5) + date (3.5.0) + debug (1.11.0) + irb (~> 1.10) + reline (>= 0.3.8) + drb (2.2.3) + erb (5.1.3) + erubi (1.13.1) + et-orbi (1.4.0) + tzinfo + fiber-annotation (0.2.0) + fiber-local (1.1.0) + fiber-storage + fiber-storage (1.0.1) + fugit (1.12.1) + et-orbi (~> 1.4) + raabro (~> 1.4) + globalid (1.3.0) + activesupport (>= 6.1) + i18n (1.14.7) + concurrent-ruby (~> 1.0) + io-console (0.8.1) + io-event (1.11.2) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.15.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.24.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.9.0) + logger + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.1.0) + method_source (1.1.0) + metrics (0.15.0) + mini_mime (1.1.5) + minitest (5.26.0) + net-imap (0.5.12) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.10-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-gnu) + racc (~> 1.4) + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + pg (1.6.2-arm64-darwin) + pg (1.6.2-x86_64-linux) + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.6.0) + pry (0.15.2) + coderay (~> 1.1) + method_source (~> 1.0) + psych (5.2.6) + date + stringio + raabro (1.4.0) + racc (1.8.1) + rack (3.2.3) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.2.1) + rack (>= 3) + rails (8.1.1) + actioncable (= 8.1.1) + actionmailbox (= 8.1.1) + actionmailer (= 8.1.1) + actionpack (= 8.1.1) + actiontext (= 8.1.1) + actionview (= 8.1.1) + activejob (= 8.1.1) + activemodel (= 8.1.1) + activerecord (= 8.1.1) + activestorage (= 8.1.1) + activesupport (= 8.1.1) + bundler (>= 1.15.0) + railties (= 8.1.1) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.1.1) + actionpack (= 8.1.1) + activesupport (= 8.1.1) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.3.1) + rdoc (6.15.0) + erb + psych (>= 4.0.0) + tsort + regexp_parser (2.11.3) + reline (0.6.2) + io-console (~> 0.5) + rubocop (1.80.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-performance (1.25.0) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.38.0, < 2.0) + ruby-progressbar (1.13.0) + securerandom (0.4.1) + standard (1.51.1) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.80.2) + standard-custom (~> 1.0.0) + standard-performance (~> 1.8) + standard-custom (1.0.2) + lint_roller (~> 1.0) + rubocop (~> 1.50) + standard-performance (1.8.0) + lint_roller (~> 1.1) + rubocop-performance (~> 1.25.0) + stringio (3.1.7) + thor (1.4.0) + timeout (0.4.4) + traces (0.18.2) + tsort (0.2.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uri (1.0.4) + useragent (0.16.11) + websocket-driver (0.8.0) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.7.3) + +PLATFORMS + arm64-darwin-23 + x86_64-linux + +DEPENDENCIES + appraisal + async (~> 2.25) + csv + debug + gouda! + minitest (~> 5.0) + pg + pry + rails (>= 8.1) + rake (~> 13.0) + standard + +BUNDLED WITH + 2.4.21 diff --git a/gouda.gemspec b/gouda.gemspec index 53e33a2..1a37be6 100644 --- a/gouda.gemspec +++ b/gouda.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.add_dependency "fugit", "~> 1.10" spec.add_dependency "async", "~> 2.25" - spec.add_development_dependency "standard" + # spec.add_development_dependency "standard" spec.add_development_dependency "pg" spec.add_development_dependency "debug" spec.add_development_dependency "pry" diff --git a/test/gouda/concurrency_extension_test.rb b/test/gouda/concurrency_extension_test.rb index 528ec5d..91119a9 100644 --- a/test/gouda/concurrency_extension_test.rb +++ b/test/gouda/concurrency_extension_test.rb @@ -4,6 +4,7 @@ class GoudaConcurrencyExtensionTest < ActiveSupport::TestCase include AssertHelper + class TestJobWithoutConcurrency < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new end @@ -11,6 +12,7 @@ class TestJobWithoutConcurrency < ActiveJob::Base class TestJobWithPerformConcurrency < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(perform_limit: 1) def perform(*args) @@ -42,6 +44,7 @@ def perform(*args) class TestJobWithCommonConcurrency < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(total_limit: 1) def perform(*args) @@ -79,6 +82,7 @@ def perform(*args) class TestJobWithEnqueueConcurrency < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(enqueue_limit: 1) def perform(*args) @@ -105,6 +109,7 @@ def perform(*args) class TestJobWithCustomKey < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with total_limit: 1, key: "42" end @@ -117,6 +122,7 @@ class TestJobWithCustomKey < ActiveJob::Base class TestJobWithCustomKeyProc < ActiveJob::Base self.queue_adapter = Gouda::Adapter.new include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with total_limit: 1, key: -> { @ivar } def initialize(...) diff --git a/test/gouda/gouda_test.rb b/test/gouda/gouda_test.rb index 561773a..e91b1de 100644 --- a/test/gouda/gouda_test.rb +++ b/test/gouda/gouda_test.rb @@ -58,6 +58,7 @@ def enqueue_concurrency_key class JobWithEnqueueConcurrencyViaGoudaAndEnqueueLimit < GoudaTestJob include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(enqueue_limit: 1, key: -> { self.class.to_s }) def perform "perform result of #{self.class}" @@ -66,6 +67,7 @@ def perform class JobWithEnqueueConcurrencyViaGoudaAndTotalLimit < GoudaTestJob include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(total_limit: 1, key: -> { self.class.to_s }) def perform "perform result of #{self.class}" @@ -84,6 +86,7 @@ def execution_concurrency_key class JobWithExecutionConcurrencyViaGoudaAndTotalLimit < GoudaTestJob include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(total_limit: 1, key: -> { self.class.to_s }) def perform "perform result of #{self.class}" @@ -92,6 +95,7 @@ def perform class JobWithExecutionConcurrencyViaGoudaAndPerformLimit < GoudaTestJob include Gouda::ActiveJobExtensions::Concurrency + gouda_control_concurrency_with(perform_limit: 1, key: -> { self.class.to_s }) def perform "perform result of #{self.class}" diff --git a/test/gouda/scheduler_test.rb b/test/gouda/scheduler_test.rb index 937145b..cb9c8c1 100644 --- a/test/gouda/scheduler_test.rb +++ b/test/gouda/scheduler_test.rb @@ -19,6 +19,7 @@ def perform(regular = "ok", mandatory:, optional: "hidden") class FailingJob < ActiveJob::Base include Gouda::ActiveJobExtensions::Concurrency + self.queue_adapter = Gouda::Adapter.new class MegaError < StandardError