diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b908a3..8af5fb9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,22 +14,18 @@ jobs: fail-fast: false matrix: include: - - ruby: 2.7.3 - gemfile: Gemfile.6-1 - - ruby: 2.7.3 - gemfile: Gemfile.7-1 - ruby: 3.2.0 - gemfile: Gemfile.6-1 - - ruby: 3.2.0 - gemfile: Gemfile.7-1 + gemfile: Gemfile.7-2 - ruby: 3.2.0 gemfile: Gemfile.8-0 - - ruby: 3.4.1 - gemfile: Gemfile.7-1 - ruby: 3.4.1 gemfile: Gemfile.7-2 - ruby: 3.4.1 gemfile: Gemfile.8-0 + - ruby: 4.0.1 + gemfile: Gemfile.8-0 + - ruby: 4.0.1 + gemfile: Gemfile.8-1 env: BUNDLE_GEMFILE: "${{ matrix.gemfile }}" steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a9af5d..2438168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,13 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html - +## 2.0.1 - 2026-03-10 +### Compatible changes + +- Add tests for Ruby 4.0 and Rails 8.1 +- Introduce `required_ruby_version` in gemspec so people on legacy Ruby versions don't receive future upgrades +- Drop tests and support for Ruby < 3 and Rails < 7.2 ## 2.0.0 - 2025-01-22 diff --git a/Gemfile.6-1.lock b/Gemfile.6-1.lock deleted file mode 100644 index eec6c4b..0000000 --- a/Gemfile.6-1.lock +++ /dev/null @@ -1,127 +0,0 @@ -PATH - remote: . - specs: - consul (2.0.0) - activerecord (>= 6.0) - activesupport (>= 6.0) - edge_rider (>= 0.3.0) - memoized (>= 1.0.2) - railties (>= 6.0) - -GEM - remote: https://rubygems.org/ - specs: - actionpack (6.1.3) - actionview (= 6.1.3) - activesupport (= 6.1.3) - rack (~> 2.0, >= 2.0.9) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.1.3) - activesupport (= 6.1.3) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (6.1.3) - activesupport (= 6.1.3) - activerecord (6.1.3) - activemodel (= 6.1.3) - activesupport (= 6.1.3) - activesupport (6.1.3) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - assignable_values (0.18.0) - activerecord (>= 2.3) - builder (3.2.4) - concurrent-ruby (1.2.0) - crass (1.0.6) - database_cleaner (1.7.0) - diff-lcs (1.3) - edge_rider (2.1.1) - activerecord (>= 3.2) - erubi (1.10.0) - gemika (0.8.1) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - loofah (2.9.0) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - memoized (1.1.1) - method_source (1.1.0) - mini_portile2 (2.8.8) - minitest (5.15.0) - nokogiri (1.15.0) - mini_portile2 (~> 2.8.2) - racc (~> 1.4) - racc (1.8.1) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.3.0) - loofah (~> 2.3) - railties (6.1.3) - actionpack (= 6.1.3) - activesupport (= 6.1.3) - method_source - rake (>= 0.8.7) - thor (~> 1.0) - rake (13.2.1) - rspec (3.6.0) - rspec-core (~> 3.6.0) - rspec-expectations (~> 3.6.0) - rspec-mocks (~> 3.6.0) - rspec-core (3.6.0) - rspec-support (~> 3.6.0) - rspec-expectations (3.6.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-mocks (3.6.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-rails (3.6.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.6.0) - rspec-expectations (~> 3.6.0) - rspec-mocks (~> 3.6.0) - rspec-support (~> 3.6.0) - rspec-support (3.6.0) - rspec_candy (0.4.1) - rspec - sneaky-save - shoulda-matchers (3.1.1) - activesupport (>= 4.0.0) - sneaky-save (0.1.2) - activerecord (>= 3.2.0) - sqlite3 (1.4.2) - thor (1.3.2) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - zeitwerk (2.6.6) - -PLATFORMS - ruby - -DEPENDENCIES - assignable_values - consul! - database_cleaner - gemika (>= 0.8.1) - railties (~> 6.1) - rspec - rspec-rails - rspec_candy - shoulda-matchers - sqlite3 - -BUNDLED WITH - 2.3.1 diff --git a/Gemfile.7-1 b/Gemfile.7-1 deleted file mode 100644 index 653db94..0000000 --- a/Gemfile.7-1 +++ /dev/null @@ -1,17 +0,0 @@ -source 'https://rubygems.org' - -# Runtime dependencies -gem 'railties', '~> 7.1' -gem 'assignable_values' - -# Development dependencies -gem 'rspec' -gem 'rspec-rails' -gem 'rspec_candy' -gem 'shoulda-matchers' -gem 'sqlite3', "~> 1.7" -gem 'database_cleaner' -gem 'gemika', '>= 0.8.1' - -# Gem under test -gem 'consul', :path => '.' diff --git a/Gemfile.7-2 b/Gemfile.7-2 index aad267c..80bf34e 100644 --- a/Gemfile.7-2 +++ b/Gemfile.7-2 @@ -11,7 +11,7 @@ gem 'rspec_candy' gem 'shoulda-matchers' gem 'sqlite3', "~> 1.7" gem 'database_cleaner' -gem 'gemika', '>= 0.8.1' +gem 'gemika', '>= 2.0.0' # Gem under test gem 'consul', :path => '.' diff --git a/Gemfile.7-2.lock b/Gemfile.7-2.lock index 9c70527..1a94789 100644 --- a/Gemfile.7-2.lock +++ b/Gemfile.7-2.lock @@ -1,12 +1,12 @@ PATH remote: . specs: - consul (2.0.0) - activerecord (>= 6.0) - activesupport (>= 6.0) + consul (2.0.1) + activerecord (>= 7.2) + activesupport (>= 7.2) edge_rider (>= 0.3.0) memoized (>= 1.0.2) - railties (>= 6.0) + railties (>= 7.2) GEM remote: https://rubygems.org/ @@ -66,7 +66,7 @@ GEM edge_rider (2.3.0) activerecord (>= 3.2) erubi (1.13.0) - gemika (0.8.3) + gemika (2.0.0) i18n (1.14.5) concurrent-ruby (~> 1.0) io-console (0.7.2) @@ -159,7 +159,7 @@ DEPENDENCIES assignable_values consul! database_cleaner - gemika (>= 0.8.1) + gemika (>= 2.0.0) railties (~> 7.2) rspec rspec-rails diff --git a/Gemfile.8-0 b/Gemfile.8-0 index a5c84df..e794e3d 100644 --- a/Gemfile.8-0 +++ b/Gemfile.8-0 @@ -11,7 +11,11 @@ gem 'rspec_candy' gem 'shoulda-matchers' gem 'sqlite3' gem 'database_cleaner' -gem 'gemika', '>= 0.8.1' +gem 'gemika', '>= 2.0.0' +gem 'actionpack' + +# Previous default gems +gem 'cgi' # Gem under test gem 'consul', :path => '.' diff --git a/Gemfile.8-0.lock b/Gemfile.8-0.lock index d244d35..9bf4626 100644 --- a/Gemfile.8-0.lock +++ b/Gemfile.8-0.lock @@ -1,12 +1,12 @@ PATH remote: . specs: - consul (2.0.0) - activerecord (>= 6.0) - activesupport (>= 6.0) + consul (2.0.1) + activerecord (>= 7.2) + activesupport (>= 7.2) edge_rider (>= 0.3.0) memoized (>= 1.0.2) - railties (>= 6.0) + railties (>= 7.2) GEM remote: https://rubygems.org/ @@ -52,6 +52,7 @@ GEM benchmark (0.4.0) bigdecimal (3.1.8) builder (3.3.0) + cgi (0.3.6) concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) @@ -67,7 +68,7 @@ GEM edge_rider (2.3.0) activerecord (>= 3.2) erubi (1.13.0) - gemika (0.8.3) + gemika (2.0.0) i18n (1.14.5) concurrent-ruby (~> 1.0) io-console (0.8.0) @@ -80,10 +81,12 @@ GEM nokogiri (>= 1.12.0) memoized (1.1.1) mini_portile2 (2.8.8) - minitest (5.24.1) + minitest (6.0.1) + prism (~> 1.5) nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) + prism (1.9.0) psych (5.2.2) date stringio @@ -159,10 +162,12 @@ PLATFORMS ruby DEPENDENCIES + actionpack assignable_values + cgi consul! database_cleaner - gemika (>= 0.8.1) + gemika (>= 2.0.0) railties (~> 8.0) rspec rspec-rails diff --git a/Gemfile.6-1 b/Gemfile.8-1 similarity index 71% rename from Gemfile.6-1 rename to Gemfile.8-1 index 6cb5829..4b1c61b 100644 --- a/Gemfile.6-1 +++ b/Gemfile.8-1 @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Runtime dependencies -gem 'railties', '~> 6.1' +gem 'railties', '~> 8.1' gem 'assignable_values' # Development dependencies @@ -11,7 +11,11 @@ gem 'rspec_candy' gem 'shoulda-matchers' gem 'sqlite3' gem 'database_cleaner' -gem 'gemika', '>= 0.8.1' +gem 'gemika', '>= 2.0.0' +gem 'actionpack' + +# Previous default gems +gem 'cgi' # Gem under test gem 'consul', :path => '.' diff --git a/Gemfile.7-1.lock b/Gemfile.8-1.lock similarity index 64% rename from Gemfile.7-1.lock rename to Gemfile.8-1.lock index 824ae35..2452157 100644 --- a/Gemfile.7-1.lock +++ b/Gemfile.8-1.lock @@ -1,53 +1,57 @@ PATH remote: . specs: - consul (2.0.0) - activerecord (>= 6.0) - activesupport (>= 6.0) + consul (2.0.1) + activerecord (>= 7.2) + activesupport (>= 7.2) edge_rider (>= 0.3.0) memoized (>= 1.0.2) - railties (>= 6.0) + railties (>= 7.2) GEM remote: https://rubygems.org/ specs: - actionpack (7.1.4.2) - actionview (= 7.1.4.2) - activesupport (= 7.1.4.2) + actionpack (8.1.2) + actionview (= 8.1.2) + activesupport (= 8.1.2) nokogiri (>= 1.8.5) - racc rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - actionview (7.1.4.2) - activesupport (= 7.1.4.2) + useragent (~> 0.16) + actionview (8.1.2) + activesupport (= 8.1.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activemodel (7.1.4.2) - activesupport (= 7.1.4.2) - activerecord (7.1.4.2) - activemodel (= 7.1.4.2) - activesupport (= 7.1.4.2) + activemodel (8.1.2) + activesupport (= 8.1.2) + activerecord (8.1.2) + activemodel (= 8.1.2) + activesupport (= 8.1.2) timeout (>= 0.4.0) - activesupport (7.1.4.2) + activesupport (8.1.2) base64 bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) + 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) - mutex_m - tzinfo (~> 2.0) - assignable_values (1.1.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + assignable_values (1.0.0) activerecord (>= 2.3) base64 (0.2.0) bigdecimal (3.1.8) builder (3.3.0) + cgi (0.3.6) concurrent-ruby (1.3.3) connection_pool (2.4.1) crass (1.0.6) @@ -57,34 +61,39 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.4.1) + date (3.5.1) diff-lcs (1.5.1) drb (2.2.1) edge_rider (2.3.0) activerecord (>= 3.2) + erb (6.0.1) erubi (1.13.0) - gemika (0.8.3) + gemika (2.0.0) i18n (1.14.5) concurrent-ruby (~> 1.0) - io-console (0.8.0) - irb (1.15.1) + io-console (0.8.2) + irb (1.17.0) pp (>= 0.6.0) + prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) + json (2.18.1) + logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) memoized (1.1.1) - mini_portile2 (2.8.7) - minitest (5.24.1) - mutex_m (0.3.0) - nokogiri (1.15.6) + mini_portile2 (2.8.8) + minitest (6.0.1) + prism (~> 1.5) + nokogiri (1.16.6) mini_portile2 (~> 2.8.2) racc (~> 1.4) - pp (0.6.2) + pp (0.6.3) prettyprint prettyprint (0.2.0) - psych (5.2.3) + prism (1.9.0) + psych (5.3.1) date stringio racc (1.8.0) @@ -93,7 +102,7 @@ GEM rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.2.1) + rackup (2.3.1) rack (>= 3) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) @@ -102,18 +111,21 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.1.4.2) - actionpack (= 7.1.4.2) - activesupport (= 7.1.4.2) - irb + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) + irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) zeitwerk (~> 2.6) - rake (13.2.1) - rdoc (6.11.0) + rake (13.3.1) + rdoc (7.2.0) + erb psych (>= 4.0.0) - reline (0.6.0) + tsort + reline (0.6.3) io-console (~> 0.5) rspec (3.13.0) rspec-core (~> 3.13.0) @@ -127,10 +139,10 @@ GEM rspec-mocks (3.13.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.1.0) - actionpack (>= 7.0) - activesupport (>= 7.0) - railties (>= 7.0) + rspec-rails (6.1.3) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) rspec-core (~> 3.13) rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) @@ -139,33 +151,39 @@ GEM rspec_candy (0.5.1) rspec sneaky-save - shoulda-matchers (5.3.0) + securerandom (0.3.2) + shoulda-matchers (6.2.0) activesupport (>= 5.2.0) sneaky-save (0.1.3) activerecord (>= 3.2.0) - sqlite3 (1.7.3) + sqlite3 (2.4.1) mini_portile2 (~> 2.8.0) - stringio (3.1.2) - thor (1.3.2) + stringio (3.2.0) + thor (1.5.0) timeout (0.4.1) + tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - zeitwerk (2.6.18) + uri (1.0.2) + useragent (0.16.10) + zeitwerk (2.7.4) PLATFORMS ruby DEPENDENCIES + actionpack assignable_values + cgi consul! database_cleaner - gemika (>= 0.8.1) - railties (~> 7.1) + gemika (>= 2.0.0) + railties (~> 8.1) rspec rspec-rails rspec_candy shoulda-matchers - sqlite3 (~> 1.7) + sqlite3 BUNDLED WITH - 2.4.22 + 2.5.15 diff --git a/README.md b/README.md index 2230d1f..3de9e9e 100644 --- a/README.md +++ b/README.md @@ -834,16 +834,39 @@ Now run `bundle install` to lock the gem into your project. ## Development -We currently develop using Ruby 3.4.1 (see `.ruby-version`) since that version works for current versions of ActiveRecord that we support. GitHub Actions will test additional Ruby versions (2.7.3, 3.2.0). +We currently develop using Ruby 3.4.1 (see `.ruby-version`) since that version works for current versions of ActiveRecord that we support. GitHub Actions will test additional Ruby versions (3.2.0, 4.0.1). There are tests in `spec`. We only accept PRs with tests. To run tests: -- Install Ruby 3.4.1 -- run `bundle install` -- Put your database credentials into `spec/support/database.yml`. There's a `database.sample.yml` you can use as a template. -- There are gem bundles in the project root for each rails version that we support. -- You can bundle all test applications by saying `bundle exec rake matrix:install` -- You can run specs from the project root by saying `bundle exec rake matrix:spec`. This will run all gemfiles compatible with your current Ruby. +- First, put your database credentials into `spec/support/database.yml`. There's a `database.sample.yml` you can use as + a template. + +Then, you have multiple options: + +1. Running tests for a single set of dependencies + - Install and switch to a Ruby version + - run `BUNDLE_GEMFILE=... bundle install` + - run `BUNDLE_GEMFILE=... bundle exec rspec` + - NOTE: + - There are gem bundles in the project root for each rails version that we support. + - Refer to `.github/workflows/test.yml` to see which Gemfiles are supported for which Ruby version. + +2. Run tests against a specific Ruby version and all Gemfiles for that version: + - Install and switch to the Ruby version + - Install development dependencies using `rake matrix:install` + - Run tests using `rake matrix:spec` + +3. Run tests against all Ruby versions: + - Install all Ruby versions mentioned in `.github/workflows/test.yml` + - run `dev/matrix` (only supports `rbenv` for switching Ruby versions currently) + +Hints: + +- Check the [gemika](github.com/makandra/gemika) README for more detailed development instructions. +- We recommend to have sufficiently new versions of bundler (> 2.3.0) and rubygems (> 3.3.0) installed for each Ruby + version. +- The script `dev/matrix` will warn you, if that is not the case. For all other methods you need to ensure that + yourself. If you would like to contribute: diff --git a/consul.gemspec b/consul.gemspec index 0a8e553..c8b2777 100644 --- a/consul.gemspec +++ b/consul.gemspec @@ -10,24 +10,24 @@ Gem::Specification.new do |s| s.summary = 'A scope-based authorization solution for Ruby on Rails.' s.description = s.summary s.license = 'MIT' + s.metadata = { + 'source_code_uri' => s.homepage, + 'bug_tracker_uri' => 'https://github.com/makandra/consul/issues', + 'changelog_uri' => 'https://github.com/makandra/consul/blob/master/CHANGELOG.md', + 'rubygems_mfa_required' => 'true', + } - if RUBY_VERSION.to_f >= 2.0 - s.metadata = { - 'source_code_uri' => s.homepage, - 'bug_tracker_uri' => 'https://github.com/makandra/consul/issues', - 'changelog_uri' => 'https://github.com/makandra/consul/blob/master/CHANGELOG.md', - 'rubygems_mfa_required' => 'true', - } - end - - s.files = `git ls-files`.split("\n").reject { |f| f.match(%r{^(test|spec|features)/}) } - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.files = `git ls-files`.split("\n").reject { |f| File.symlink?(f) }.reject { |f| f.match(%r{^(spec|dev|media|.github)/}) } s.require_paths = ["lib"] + s.bindir = 'exe' + s.executables = [] + + s.required_ruby_version = '>= 3.0.0' + s.add_dependency('memoized', '>=1.0.2') - s.add_dependency('activerecord', '>= 6.0') - s.add_dependency('activesupport', '>= 6.0') - s.add_dependency('railties', '>= 6.0') + s.add_dependency('activerecord', '>= 7.2') + s.add_dependency('activesupport', '>= 7.2') + s.add_dependency('railties', '>= 7.2') s.add_dependency('edge_rider', '>= 0.3.0') end diff --git a/dev/matrix b/dev/matrix new file mode 100755 index 0000000..38498a8 --- /dev/null +++ b/dev/matrix @@ -0,0 +1,65 @@ +#!/bin/bash +set -euo pipefail + +# utility for comparing version strings +# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash +function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + +# store current Ruby version and restore it on exit +original_ruby_version=$(cat .ruby-version) +trap "rbenv local $original_ruby_version" EXIT + +# determine employed Ruby versions (awk command == "strip whitespace", sed command == "delete_prefix") +readarray -t versions < <(grep ruby: .github/workflows/test.yml | awk '{$1=$1};1' | sed 's/- ruby: //' | sort | uniq) +echo "Detected Ruby versions:" +for version in "${versions[@]}" +do + echo "- $version" +done +echo "" + +for version in "${versions[@]}" +do + # switch Ruby version + rbenv local "$version" + + # determine actual versions + ruby_version=$(ruby -v) + rubygems_version=$(gem -v) + bundler_version=$(bundler -v | sed 's/Bundler version //') + + # debug output + echo "=====================" + echo "Target Ruby version: $version" + echo "" + echo "Ruby: $ruby_version" + echo "rubygems: $rubygems_version" + echo "Bundler: $bundler_version" + echo "=====================" + echo "" + + # version checks (minimum versions to make 'BUNDLED WITH' in Gemfile.lock work correctly) + if [ $(version $rubygems_version) -lt $(version "3.3.0") ]; then + echo "Please ensure that your rubygems version is > 3.3.0 for Ruby $ruby_version!" + echo "Install newest version:" + echo "gem update --system" + echo "Install specific version:" + echo "gem update --system " + exit 1 + fi + + if [ $(version $bundler_version) -lt $(version "2.3.0") ]; then + echo "Please ensure that your Bundler version is > 2.3.0 for Ruby $ruby_version!" + echo "Install newest version:" + echo "gem install bundler" + echo "Install specific version:" + echo "gem install bundler:" + exit 1 + fi + + # bundle and run specs + rake matrix:install + rake matrix:spec +done + +exit 0 diff --git a/lib/consul/version.rb b/lib/consul/version.rb index 6c92a0e..8c9e984 100644 --- a/lib/consul/version.rb +++ b/lib/consul/version.rb @@ -1,3 +1,3 @@ module Consul - VERSION = '2.0.0' + VERSION = '2.0.1' end