From 2d8b1571cbf4347358af7eb4719934fe1abdb79c Mon Sep 17 00:00:00 2001 From: mizuki-y Date: Sat, 6 Sep 2025 11:57:59 +0900 Subject: [PATCH 1/2] Update Gemfile and CI configuration to support multiple Rails versions --- .github/workflows/main.yml | 33 +++++++++++++++++++++++++++------ Gemfile | 16 ++++++++++++---- structured_params.gemspec | 4 ++-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d43286..b9d279e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,19 +10,40 @@ on: jobs: build: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} + name: Ruby ${{ matrix.ruby }} - Rails ${{ matrix.rails }} strategy: + fail-fast: false matrix: - ruby: - - '3.2' - - '3.3' - - '3.4' + include: + # Test with latest patch versions + - ruby: '3.2' + rails: '~> 7.2.0' + - ruby: '3.3' + rails: '~> 7.2.0' + - ruby: '3.4' + rails: '~> 7.2.0' + - ruby: '3.2' + rails: '~> 8.0.0' + - ruby: '3.3' + rails: '~> 8.0.0' + - ruby: '3.4' + rails: '~> 8.0.0' + steps: - uses: actions/checkout@v5 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - bundler-cache: true + bundler-cache: false + - name: Set Rails version + run: | + echo "RAILS_VERSION=${{ matrix.rails }}" >> $GITHUB_ENV + bundle config set --local gemfile Gemfile + - name: Install dependencies + run: | + bundle install --jobs 4 --retry 3 + env: + RAILS_VERSION: ${{ matrix.rails }} - name: Run the default task run: bundle exec rake diff --git a/Gemfile b/Gemfile index 0fe9f87..417ccdd 100644 --- a/Gemfile +++ b/Gemfile @@ -4,11 +4,19 @@ source 'https://rubygems.org' gemspec -version = ENV['RAILS_VERSION'] || '8.0' +# Allow testing different Rails versions via environment variable +rails_version = ENV['RAILS_VERSION'] || '~> 8.0.0' -gem_version = "~> #{version}.0" -gem 'actionpack', gem_version -gem 'activemodel', gem_version +if rails_version.start_with?('~>') + # Version constraint specified (e.g., "~> 7.2.0") + gem 'actionpack', rails_version + gem 'activemodel', rails_version +else + # Legacy format support (e.g., "7.2") + gem_version = "~> #{rails_version}.0" + gem 'actionpack', gem_version + gem 'activemodel', gem_version +end group :development, :test do gem 'factory_bot' diff --git a/structured_params.gemspec b/structured_params.gemspec index 767317e..5a3672a 100644 --- a/structured_params.gemspec +++ b/structured_params.gemspec @@ -29,6 +29,6 @@ Gem::Specification.new do |spec| 'rubygems_mfa_required' => 'true' } - spec.add_dependency 'actionpack', '~> 8.0.0' - spec.add_dependency 'activemodel', '~> 8.0.0' + spec.add_dependency 'actionpack', '>= 7.2', '< 9.0' + spec.add_dependency 'activemodel', '>= 7.2', '< 9.0' end From d187549df57abe156430a59d3adce0036242fde4 Mon Sep 17 00:00:00 2001 From: mizuki-y Date: Sat, 6 Sep 2025 12:02:19 +0900 Subject: [PATCH 2/2] Update .github/workflows/main.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9d279e..c36d729 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,7 +39,6 @@ jobs: - name: Set Rails version run: | echo "RAILS_VERSION=${{ matrix.rails }}" >> $GITHUB_ENV - bundle config set --local gemfile Gemfile - name: Install dependencies run: | bundle install --jobs 4 --retry 3