Skip to content

Enable github actions and multiple ruby version testing #1

Enable github actions and multiple ruby version testing

Enable github actions and multiple ruby version testing #1

Workflow file for this run

name: CI
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
- '3.3'
- '3.4'
activesupport-version:
- '~> 6.1.0'
- '~> 7.0.0'
- '~> 7.1.0'
- '~> 7.2.0'
exclude:
# ActiveSupport 7.1+ requires Ruby 3.1+
- ruby-version: '2.7'
activesupport-version: '~> 7.1.0'
- ruby-version: '3.0'
activesupport-version: '~> 7.1.0'
- ruby-version: '2.7'
activesupport-version: '~> 7.2.0'
- ruby-version: '3.0'
activesupport-version: '~> 7.2.0'
env:
ACTIVESUPPORT_VERSION: ${{ matrix.activesupport-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- name: Create Gemfile for testing
run: |
cat > Gemfile.ci << EOF
source 'https://rubygems.org'
gemspec
gem 'activesupport', '${{ matrix.activesupport-version }}'
gem 'minitest', '~> 5.20'
gem 'mutex_m' if RUBY_VERSION >= '3.4'
gem 'rake'
EOF
- name: Install dependencies
run: |
cp Gemfile.ci Gemfile
bundle install
- name: Run tests
run: |
bundle exec rake test || bundle exec ruby -I test -e "Dir['test/*_test.rb'].each { |f| require f }"
- name: Run individual test files (fallback)
if: failure()
run: |
find test -name "*_test.rb" -exec bundle exec ruby {} \;
compatibility:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.5'
- '2.6'
activesupport-version:
- '~> 5.2.0'
- '~> 6.0.0'
- '~> 6.1.0'
env:
ACTIVESUPPORT_VERSION: ${{ matrix.activesupport-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- name: Remove safe navigation operator for older Ruby versions
run: |
# Replace &. with && for Ruby < 2.3 compatibility
sed -i 's/self\.directories\[key\]&\./self.directories[key] \&\& self.directories[key]./g' lib/config_files.rb
sed -i 's/loaders\.detect{|_, extensions| extensions\.include?(::File\.extname(file_name)\.strip\.downcase\[1\.\.-1\])}&\./loaders.detect{|_, extensions| extensions.include?(::File.extname(file_name).strip.downcase[1..-1])} \&\&/g' lib/config_files/loader_factory.rb
- name: Create Gemfile for compatibility testing
run: |
cat > Gemfile.ci << EOF
source 'https://rubygems.org'
gemspec
gem 'activesupport', '${{ matrix.activesupport-version }}'
gem 'minitest', '~> 5.15' # Older minitest for older Ruby
gem 'rake'
EOF
- name: Install dependencies
run: |
cp Gemfile.ci Gemfile
bundle install
- name: Run tests
run: |
find test -name "*_test.rb" -exec bundle exec ruby {} \;
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
- name: Install RuboCop
run: |
gem install rubocop rubocop-minitest
- name: Run RuboCop
run: |
rubocop --format github || true # Don't fail on style issues for now