From 3fbf28b84ac3f3b51790b7984ee4c86a98a40a19 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 16:51:07 +0900 Subject: [PATCH 01/10] Add Docker support for multi-version Rails testing - Add Dockerfile with Ruby 3.2 and required dependencies - Add docker-compose.yml with services for Rails 6.1 and 7.0 - Add .dockerignore to exclude unnecessary files from Docker context - Update .gitignore to use coverage/ directory and remove duplicate entry This provides an easy way to test the gem with different Rails versions in isolated Docker environments. --- .dockerignore | 35 +++++++++++++++++++++++++++++++++++ .gitignore | 3 +-- Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d05a424c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,35 @@ +# Git +.git +.gitignore +.github + +# Claude/AI configuration +.claude +.serena +CLAUDE.md + +# Documentation +*.md +!README.md + +# Test artifacts +coverage/ +test_db +*.sqlite3 +.last_run.json +.resultset.json + +# Ruby/bundler +.bundle +vendor/bundle + +# OS files +.DS_Store +Thumbs.db + +# Editor files +.vscode +.idea +*.swp +*.swo +*~ diff --git a/.gitignore b/.gitignore index 71e71f15..11da1f31 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ Gemfile.lock InstalledFiles _yardoc -coverage +coverage/ doc/ lib/bundler/man pkg @@ -17,7 +17,6 @@ spec/reports test/tmp test/version_tmp tmp -coverage test/log log/*.log test_db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..47b7399e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# Dockerfile for testing jsonapi-resources with multiple Rails versions + +FROM ruby:3.2 + +# Install dependencies +RUN apt-get update -qq && \ + apt-get install -y build-essential libpq-dev nodejs && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy Gemfile and gemspec +COPY Gemfile jsonapi-resources.gemspec ./ +COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ + +# Install bundler +RUN gem install bundler + +# Note: bundle install will happen at runtime with specific RAILS_VERSION +# This allows testing multiple Rails versions without rebuilding the image diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..53e3ae69 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +services: + # Base service definition + test-base: &test-base + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/app + - bundle-cache:/usr/local/bundle + working_dir: /app + stdin_open: true + tty: true + + # Rails 6.1.7 + rails-6.1: + <<: *test-base + container_name: jsonapi-rails-6.1 + environment: + - RAILS_VERSION=6.1.7 + command: bash -c "bundle update && bundle exec rake test" + + # Rails 7.0.4 + rails-7.0: + <<: *test-base + container_name: jsonapi-rails-7.0 + environment: + - RAILS_VERSION=7.0.4 + command: bash -c "bundle update && bundle exec rake test" + + # Interactive shell for debugging (defaults to Rails 6.1) + shell: + <<: *test-base + container_name: jsonapi-shell + environment: + - RAILS_VERSION=${RAILS_VERSION:-6.1.7} + command: /bin/bash + +volumes: + bundle-cache: From 9783d74209ba20d2e9f39977386127a5a5170408 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 19:49:41 +0900 Subject: [PATCH 02/10] Add Docker services for Rails 7.1-8.1 testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand docker-compose.yml to include services for all supported Rails versions from the CI matrix: Services added: - rails-7.1: Rails 7.1.6 - rails-7.2: Rails 7.2.3 - rails-8.0: Rails 8.0.4 - rails-8.1: Rails 8.1.2 Updated services: - rails-6.1: 6.1.7 → 6.1.7.10 - rails-7.0: 7.0.4 → 7.0.10 - shell: default Rails version 6.1.7 → 8.1.2 Usage: docker-compose run rails-7.1 docker-compose run rails-7.2 docker-compose run rails-8.0 docker-compose run rails-8.1 This matches the expanded CI matrix and enables local testing across all supported Rails versions. Co-Authored-By: Claude Sonnet 4.5 --- docker-compose.yml | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 53e3ae69..e66c4dda 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,28 +11,60 @@ services: stdin_open: true tty: true - # Rails 6.1.7 + # Rails 6.1.7.10 rails-6.1: <<: *test-base container_name: jsonapi-rails-6.1 environment: - - RAILS_VERSION=6.1.7 + - RAILS_VERSION=6.1.7.10 command: bash -c "bundle update && bundle exec rake test" - # Rails 7.0.4 + # Rails 7.0.10 rails-7.0: <<: *test-base container_name: jsonapi-rails-7.0 environment: - - RAILS_VERSION=7.0.4 + - RAILS_VERSION=7.0.10 command: bash -c "bundle update && bundle exec rake test" - # Interactive shell for debugging (defaults to Rails 6.1) + # Rails 7.1.6 + rails-7.1: + <<: *test-base + container_name: jsonapi-rails-7.1 + environment: + - RAILS_VERSION=7.1.6 + command: bash -c "bundle update && bundle exec rake test" + + # Rails 7.2.3 + rails-7.2: + <<: *test-base + container_name: jsonapi-rails-7.2 + environment: + - RAILS_VERSION=7.2.3 + command: bash -c "bundle update && bundle exec rake test" + + # Rails 8.0.4 + rails-8.0: + <<: *test-base + container_name: jsonapi-rails-8.0 + environment: + - RAILS_VERSION=8.0.4 + command: bash -c "bundle update && bundle exec rake test" + + # Rails 8.1.2 + rails-8.1: + <<: *test-base + container_name: jsonapi-rails-8.1 + environment: + - RAILS_VERSION=8.1.2 + command: bash -c "bundle update && bundle exec rake test" + + # Interactive shell for debugging (defaults to Rails 8.1) shell: <<: *test-base container_name: jsonapi-shell environment: - - RAILS_VERSION=${RAILS_VERSION:-6.1.7} + - RAILS_VERSION=${RAILS_VERSION:-8.1.2} command: /bin/bash volumes: From d51c6dd1e42ffd98c83c502861529b2470b634e4 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 19:55:49 +0900 Subject: [PATCH 03/10] Fix Docker command to remove Gemfile.lock before bundle install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change command from "bundle update" to "rm -f Gemfile.lock && bundle install" to avoid dependency conflicts between different Rails versions. With "bundle update", the existing Gemfile.lock would cause version resolution failures when switching between Rails versions, especially when both activerecord and railties are specified with different version requirements. Removing Gemfile.lock ensures each container gets the correct dependencies for its specified RAILS_VERSION environment variable. Tested and verified all services pass: - Rails 6.1.7.10: 674 runs, 8772 assertions, 0 failures ✅ - Rails 7.0.10: 674 runs, 8772 assertions, 0 failures ✅ - Rails 7.1.6: 674 runs, 8772 assertions, 0 failures ✅ - Rails 7.2.3: 674 runs, 8772 assertions, 0 failures ✅ - Rails 8.0.4: 674 runs, 8772 assertions, 0 failures ✅ - Rails 8.1.2: 674 runs, 8772 assertions, 0 failures ✅ Co-Authored-By: Claude Sonnet 4.5 --- docker-compose.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e66c4dda..a7f54d76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: container_name: jsonapi-rails-6.1 environment: - RAILS_VERSION=6.1.7.10 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Rails 7.0.10 rails-7.0: @@ -25,7 +25,7 @@ services: container_name: jsonapi-rails-7.0 environment: - RAILS_VERSION=7.0.10 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Rails 7.1.6 rails-7.1: @@ -33,7 +33,7 @@ services: container_name: jsonapi-rails-7.1 environment: - RAILS_VERSION=7.1.6 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Rails 7.2.3 rails-7.2: @@ -41,7 +41,7 @@ services: container_name: jsonapi-rails-7.2 environment: - RAILS_VERSION=7.2.3 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Rails 8.0.4 rails-8.0: @@ -49,7 +49,7 @@ services: container_name: jsonapi-rails-8.0 environment: - RAILS_VERSION=8.0.4 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Rails 8.1.2 rails-8.1: @@ -57,7 +57,7 @@ services: container_name: jsonapi-rails-8.1 environment: - RAILS_VERSION=8.1.2 - command: bash -c "bundle update && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" # Interactive shell for debugging (defaults to Rails 8.1) shell: From d4203e24bf14ae09669f09f9daf14954ed1fc968 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 19:57:27 +0900 Subject: [PATCH 04/10] Add SQLite WAL mode files to .gitignore Add test/test_db-shm and test/test_db-wal to .gitignore to exclude SQLite Write-Ahead Logging (WAL) mode files that are created during test execution. These files are temporary database files created by SQLite when WAL mode is enabled and should not be tracked in version control. Co-Authored-By: Claude Sonnet 4.5 --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 11da1f31..a0da8c34 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,7 @@ test/log log/*.log test_db test_db-journal +test/test_db-shm +test/test_db-wal .idea *.iml From 5ff7f95373fbb88fc9aa850d9e6983e44cf9adab Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 19:57:48 +0900 Subject: [PATCH 05/10] Add Docker services for Rails 5.1, 5.2, and 6.0 Add Docker Compose services for older Rails versions to enable comprehensive testing across the full compatibility matrix: Services added: - rails-5.1: Rails 5.1.7 - rails-5.2: Rails 5.2.8.1 - rails-6.0: Rails 6.0.6 Usage: docker-compose run rails-5.1 docker-compose run rails-5.2 docker-compose run rails-6.0 This completes the Docker setup for all Rails versions supported in the CI matrix (5.1.7 through 8.1.2). Co-Authored-By: Claude Sonnet 4.5 --- docker-compose.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index a7f54d76..88c09aed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,30 @@ services: stdin_open: true tty: true + # Rails 5.1.7 + rails-5.1: + <<: *test-base + container_name: jsonapi-rails-5.1 + environment: + - RAILS_VERSION=5.1.7 + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + + # Rails 5.2.8.1 + rails-5.2: + <<: *test-base + container_name: jsonapi-rails-5.2 + environment: + - RAILS_VERSION=5.2.8.1 + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + + # Rails 6.0.6 + rails-6.0: + <<: *test-base + container_name: jsonapi-rails-6.0 + environment: + - RAILS_VERSION=6.0.6 + command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + # Rails 6.1.7.10 rails-6.1: <<: *test-base From 74294a51e8d955827cf18d6abbd64e1bfa130e12 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 20:01:38 +0900 Subject: [PATCH 06/10] Add Ruby 2.7 Dockerfile for Rails 5.1-6.0 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Dockerfile.ruby2.7 to support older Rails versions that are not compatible with Ruby 3.2. Based on CI matrix compatibility: Ruby 2.7 supports: - Rails 5.1.7 ✅ - Rails 5.2.8.1 ✅ - Rails 6.0.6 ✅ - Rails 6.1.7.10 (also works with Ruby 3.2) - Rails 7.0.10 (also works with Ruby 3.2) Ruby 3.2 (existing Dockerfile): - Rails 6.1.7.10 ✅ - Rails 7.0.10 ✅ - Rails 7.1.6 ✅ - Rails 7.2.3 ✅ - Rails 8.0.4 ✅ - Rails 8.1.2 ✅ Changes: - Add Dockerfile.ruby2.7 with Ruby 2.7 base image - Update docker-compose.yml to use Ruby 2.7 for Rails 5.1, 5.2, 6.0 - Add bundle-cache-ruby27 volume for separate gem caching - Keep Ruby 3.2 for Rails 6.1-8.1 This ensures all Rails versions in the CI matrix can be tested locally with the appropriate Ruby version. Co-Authored-By: Claude Sonnet 4.5 --- Dockerfile.ruby2.7 | 22 ++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.ruby2.7 diff --git a/Dockerfile.ruby2.7 b/Dockerfile.ruby2.7 new file mode 100644 index 00000000..aae525c8 --- /dev/null +++ b/Dockerfile.ruby2.7 @@ -0,0 +1,22 @@ +# Dockerfile for testing jsonapi-resources with Rails 5.1-7.0 (Ruby 2.7) + +FROM ruby:2.7 + +# Install dependencies +RUN apt-get update -qq && \ + apt-get install -y build-essential libpq-dev nodejs && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy Gemfile and gemspec +COPY Gemfile jsonapi-resources.gemspec ./ +COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ + +# Install bundler +RUN gem install bundler + +# Note: bundle install will happen at runtime with specific RAILS_VERSION +# This allows testing multiple Rails versions without rebuilding the image diff --git a/docker-compose.yml b/docker-compose.yml index 88c09aed..a2168e63 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ services: - # Base service definition + # Base service definition for Ruby 3.2 (Rails 6.1-8.1) test-base: &test-base build: context: . @@ -11,9 +11,21 @@ services: stdin_open: true tty: true + # Base service definition for Ruby 2.7 (Rails 5.1-7.0) + test-base-ruby27: &test-base-ruby27 + build: + context: . + dockerfile: Dockerfile.ruby2.7 + volumes: + - .:/app + - bundle-cache-ruby27:/usr/local/bundle + working_dir: /app + stdin_open: true + tty: true + # Rails 5.1.7 rails-5.1: - <<: *test-base + <<: *test-base-ruby27 container_name: jsonapi-rails-5.1 environment: - RAILS_VERSION=5.1.7 @@ -21,7 +33,7 @@ services: # Rails 5.2.8.1 rails-5.2: - <<: *test-base + <<: *test-base-ruby27 container_name: jsonapi-rails-5.2 environment: - RAILS_VERSION=5.2.8.1 @@ -29,7 +41,7 @@ services: # Rails 6.0.6 rails-6.0: - <<: *test-base + <<: *test-base-ruby27 container_name: jsonapi-rails-6.0 environment: - RAILS_VERSION=6.0.6 @@ -93,3 +105,4 @@ services: volumes: bundle-cache: + bundle-cache-ruby27: From 44f92663bcc4fb69841b6b97b863766d7449ad70 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 20:03:07 +0900 Subject: [PATCH 07/10] Fix bundler version for Ruby 2.7 compatibility Ruby 2.7 requires bundler < 2.5. Install bundler 2.4.22 specifically to avoid compatibility issues. Co-Authored-By: Claude Sonnet 4.5 --- Dockerfile.ruby2.7 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.ruby2.7 b/Dockerfile.ruby2.7 index aae525c8..f53b24f2 100644 --- a/Dockerfile.ruby2.7 +++ b/Dockerfile.ruby2.7 @@ -15,8 +15,8 @@ WORKDIR /app COPY Gemfile jsonapi-resources.gemspec ./ COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ -# Install bundler -RUN gem install bundler +# Install bundler (Ruby 2.7 requires bundler < 2.5) +RUN gem install bundler -v 2.4.22 # Note: bundle install will happen at runtime with specific RAILS_VERSION # This allows testing multiple Rails versions without rebuilding the image From 5c90b83ef65067f1dbe835d378a9eeaff0cf8262 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 20:12:41 +0900 Subject: [PATCH 08/10] Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 2.7+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Psych patch to allow loading Date, Time, DateTime classes from YAML fixtures in Rails 6.0 test environment. Rails 6.0 + Ruby 2.7 combination uses Psych 3.1+, which introduced stricter security for YAML.load. The default safe_load behavior rejects Date/Time/DateTime classes, causing test fixtures to fail. Solution: Patch Psych.load to use unsafe_load in test environment. This is safe since we're only loading trusted test fixture files. Fixes error: Psych::DisallowedClass: Tried to load unspecified class: Date Test result: Rails 6.0.6 now passes all 674 tests ✅ Co-Authored-By: Claude Sonnet 4.5 --- test/test_helper.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 81514079..e146eef3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -78,6 +78,25 @@ class TestApp < Rails::Application require 'jsonapi-resources' require 'pry' +# Fix Psych::DisallowedClass error for Rails 6.0 with Ruby 2.7+ +# In test environment, allow all classes from YAML (safe for test fixtures) +if defined?(Psych::VERSION) && Psych::VERSION.to_f >= 3.1 && Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR == 0 + require 'psych' + + # Patch Psych.load to use unsafe_load in test environment + # This is safe because we're only loading trusted test fixtures + module Psych + class << self + alias_method :safe_load_original, :load + + def load(yaml, *args, **kwargs) + # Use unsafe_load to allow Date, Time, DateTime from YAML + unsafe_load(yaml) + end + end + end +end + require File.expand_path('../helpers/value_matchers', __FILE__) require File.expand_path('../helpers/assertions', __FILE__) require File.expand_path('../helpers/functional_helpers', __FILE__) From d78b012b15afca5e5cf58c727e01befb806e032a Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 20:15:25 +0900 Subject: [PATCH 09/10] Change Rails 6.1-8.1 to use Ruby 3.1.5 Replace Ruby 3.2 with Ruby 3.1.5 for Rails 6.1-8.1 testing. This change will be validated by running tests on each version sequentially. Co-Authored-By: Claude Sonnet 4.5 --- Dockerfile.ruby3.1 | 22 ++++++++++++++++++++++ docker-compose.yml | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 Dockerfile.ruby3.1 diff --git a/Dockerfile.ruby3.1 b/Dockerfile.ruby3.1 new file mode 100644 index 00000000..ebddcf63 --- /dev/null +++ b/Dockerfile.ruby3.1 @@ -0,0 +1,22 @@ +# Dockerfile for testing jsonapi-resources with Rails 6.1-8.1 (Ruby 3.1.5) + +FROM ruby:3.1.5 + +# Install dependencies +RUN apt-get update -qq && \ + apt-get install -y build-essential libpq-dev nodejs && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy Gemfile and gemspec +COPY Gemfile jsonapi-resources.gemspec ./ +COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ + +# Install bundler +RUN gem install bundler + +# Note: bundle install will happen at runtime with specific RAILS_VERSION +# This allows testing multiple Rails versions without rebuilding the image diff --git a/docker-compose.yml b/docker-compose.yml index a2168e63..4a41d558 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,9 @@ services: - # Base service definition for Ruby 3.2 (Rails 6.1-8.1) + # Base service definition for Ruby 3.1.5 (Rails 6.1-8.1) test-base: &test-base build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile.ruby3.1 volumes: - .:/app - bundle-cache:/usr/local/bundle @@ -11,7 +11,7 @@ services: stdin_open: true tty: true - # Base service definition for Ruby 2.7 (Rails 5.1-7.0) + # Base service definition for Ruby 2.7 (Rails 5.1-6.0) test-base-ruby27: &test-base-ruby27 build: context: . From 49d75c62bfd444857da60573e1dc6117a38b43f4 Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 20:32:00 +0900 Subject: [PATCH 10/10] Use Ruby 3.1.5 for Rails 6.1-7.2, Ruby 3.4 for Rails 8.0-8.1 Updated Docker configuration to use specific Ruby versions for each Rails version: - Rails 5.1-6.0: Ruby 2.7 with bundler 2.4.22 - Rails 6.1-7.2: Ruby 3.1.5 with bundler 2.4.14 - Rails 8.0-8.1: Ruby 3.4 with bundler 2.4.14 Rails 8.0+ requires Ruby >= 3.2.0, so we use Ruby 3.4 for these versions. All tests pass successfully for all 9 Rails versions. Changes: - Created Dockerfile.ruby3.1 for Ruby 3.1.5 - Created Dockerfile.ruby3.4 for Ruby 3.4 - Updated docker-compose.yml to use appropriate Ruby versions - Added separate bundle cache volumes for each Ruby version Co-Authored-By: Claude Sonnet 4.5 --- Dockerfile.ruby3.1 | 6 ++++-- Dockerfile.ruby3.4 | 24 ++++++++++++++++++++++++ docker-compose.yml | 37 +++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 Dockerfile.ruby3.4 diff --git a/Dockerfile.ruby3.1 b/Dockerfile.ruby3.1 index ebddcf63..ecb7193a 100644 --- a/Dockerfile.ruby3.1 +++ b/Dockerfile.ruby3.1 @@ -15,8 +15,10 @@ WORKDIR /app COPY Gemfile jsonapi-resources.gemspec ./ COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ -# Install bundler -RUN gem install bundler +# Install specific bundler version for compatibility +RUN gem install bundler -v 2.4.14 --no-document && \ + gem install bundler -v 2.4.14 --install-dir /usr/local/bundle --no-document && \ + bundle --version # Note: bundle install will happen at runtime with specific RAILS_VERSION # This allows testing multiple Rails versions without rebuilding the image diff --git a/Dockerfile.ruby3.4 b/Dockerfile.ruby3.4 new file mode 100644 index 00000000..607bc76b --- /dev/null +++ b/Dockerfile.ruby3.4 @@ -0,0 +1,24 @@ +# Dockerfile for testing jsonapi-resources with Rails 8.0-8.1 (Ruby 3.4) + +FROM ruby:3.4 + +# Install dependencies +RUN apt-get update -qq && \ + apt-get install -y build-essential libpq-dev nodejs && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy Gemfile and gemspec +COPY Gemfile jsonapi-resources.gemspec ./ +COPY lib/jsonapi/resources/version.rb ./lib/jsonapi/resources/ + +# Install specific bundler version for compatibility +RUN gem install bundler -v 2.4.14 --no-document && \ + gem install bundler -v 2.4.14 --install-dir /usr/local/bundle --no-document && \ + bundle --version + +# Note: bundle install will happen at runtime with specific RAILS_VERSION +# This allows testing multiple Rails versions without rebuilding the image diff --git a/docker-compose.yml b/docker-compose.yml index 4a41d558..59e28158 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile.ruby3.1 volumes: - .:/app - - bundle-cache:/usr/local/bundle + - bundle-cache-ruby31:/usr/local/bundle working_dir: /app stdin_open: true tty: true @@ -23,6 +23,18 @@ services: stdin_open: true tty: true + # Base service definition for Ruby 3.4 (Rails 8.0-8.1) + test-base-ruby34: &test-base-ruby34 + build: + context: . + dockerfile: Dockerfile.ruby3.4 + volumes: + - .:/app + - bundle-cache-ruby34:/usr/local/bundle + working_dir: /app + stdin_open: true + tty: true + # Rails 5.1.7 rails-5.1: <<: *test-base-ruby27 @@ -53,7 +65,7 @@ services: container_name: jsonapi-rails-6.1 environment: - RAILS_VERSION=6.1.7.10 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" # Rails 7.0.10 rails-7.0: @@ -61,7 +73,7 @@ services: container_name: jsonapi-rails-7.0 environment: - RAILS_VERSION=7.0.10 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" # Rails 7.1.6 rails-7.1: @@ -69,7 +81,7 @@ services: container_name: jsonapi-rails-7.1 environment: - RAILS_VERSION=7.1.6 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" # Rails 7.2.3 rails-7.2: @@ -77,23 +89,23 @@ services: container_name: jsonapi-rails-7.2 environment: - RAILS_VERSION=7.2.3 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" - # Rails 8.0.4 + # Rails 8.0.4 (Ruby 3.4 required) rails-8.0: - <<: *test-base + <<: *test-base-ruby34 container_name: jsonapi-rails-8.0 environment: - RAILS_VERSION=8.0.4 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" - # Rails 8.1.2 + # Rails 8.1.2 (Ruby 3.4 required) rails-8.1: - <<: *test-base + <<: *test-base-ruby34 container_name: jsonapi-rails-8.1 environment: - RAILS_VERSION=8.1.2 - command: bash -c "rm -f Gemfile.lock && bundle install && bundle exec rake test" + command: bash -c "rm -f Gemfile.lock && /usr/local/bin/bundler _2.4.14_ install && /usr/local/bin/bundler _2.4.14_ exec rake test" # Interactive shell for debugging (defaults to Rails 8.1) shell: @@ -104,5 +116,6 @@ services: command: /bin/bash volumes: - bundle-cache: + bundle-cache-ruby31: bundle-cache-ruby27: + bundle-cache-ruby34: