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 800c71c6..7051ca84 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 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: diff --git a/test/test_helper.rb b/test/test_helper.rb index c1faea37..a02fff9e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,4 @@ +require 'logger' require 'simplecov' require 'database_cleaner'