From f2ca3cc5d9ce88f2182dc329b934722bd6d05c4b Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 16:51:07 +0900 Subject: [PATCH 1/2] 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 000000000..d05a424c0 --- /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 800c71c6a..7051ca844 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 test_db test_db-journal diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..47b7399eb --- /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 000000000..53e3ae691 --- /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 f9fa8f9da6526a20f973ce026134aca0bc2e7fee Mon Sep 17 00:00:00 2001 From: Koji Takao Date: Tue, 20 Jan 2026 17:10:32 +0900 Subject: [PATCH 2/2] Add Logger require for Ruby 2.6 compatibility Fix CI failures with Ruby 2.6 and Rails 6.0/6.1 by adding explicit require 'logger' to prevent NameError: uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index c1faea370..a02fff9e7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,4 @@ +require 'logger' require 'simplecov' require 'database_cleaner'