Add Docker support for multi-version Rails testing#10
Merged
takaokouji merged 10 commits intomasterfrom Jan 20, 2026
Merged
Conversation
- 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.
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Ruby 2.7 requires bundler < 2.5. Install bundler 2.4.22 specifically to avoid compatibility issues. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds Docker support to enable easy testing across multiple Rails versions in isolated environments.
Changes
Docker Configuration
Docker Services Available
The docker-compose.yml provides services for testing with:
Usage Examples
Other Changes
coverage/directory pattern and removed duplicate entryBenefits
Testing
Tested with:
Related
This Docker setup complements the Rails 7.1-8.1 support added in #9, providing a convenient way to test across the expanded version matrix.
🤖 Generated with Claude Code