Skip to content

Commit

Permalink
Workflows / CI: fixed & refactored
Browse files Browse the repository at this point in the history
## Fixed

* Ruby 2.6 (see hotwired/turbo-rails/#681).

## Changed

* Moved Rails versions to CI `matrix`.
* Both edge and outdated Ruby / Rails versions may fail.
* Use the latest RubyGems.
  • Loading branch information
Alexander-Senko committed Oct 3, 2024
1 parent 93a9bc2 commit 5fe90c6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 35 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,42 @@
name: CI

on:
- push
- pull_request
push:
branches:
- master
pull_request:

permissions:
contents: read

jobs:
rspec:
runs-on: ubuntu-20.04
name: >-
rspec (${{ matrix.ruby }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby:
- '3.3'
- '3.2'
- '3.1'
- '3.0'
- '2.7'
- '2.6'
- '2.5'
- '2.4'
- 3.3
- 3.2
- 3.1
rails:
- 6.1 # TODO: move to 7.2
include:
# Edge
- { ruby: 'head', rails: 'edge', allow-fail: true }
# Outdated
- { ruby: '3.0', rails: '6.1' } # TODO: move to 7.1
- { ruby: '2.7', rails: '6' } # RSpec AR Expectations support Rails 7.1 since Ruby 3.0
- { ruby: '2.6', rails: '6' }
- { ruby: '2.5', rails: '6' }
- { ruby: '2.4', rails: '5' }

env:
RAILS_VERSION: "${{ matrix.rails }}"

services:
mongodb:
Expand All @@ -31,13 +46,13 @@ jobs:
- 27017:27017

steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
rubygems: latest
bundler-cache: true

- name: RSpec & publish code coverage
Expand All @@ -46,3 +61,11 @@ jobs:
CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915
with:
coverageCommand: bin/rake
continue-on-error: ${{ matrix.allow-fail }}
id: test

- name: >-
Test ${{ steps.test.outcome }}
run: |
echo Ruby ${{ matrix.ruby }}
echo Rails ${{ matrix.rails }}
38 changes: 18 additions & 20 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ source "https://rubygems.org"

gemspec

gem 'puma'

platforms :ruby do
if RUBY_VERSION >= "2.5.0"
gem 'sqlite3', '~> 1.4'
Expand All @@ -15,32 +17,28 @@ platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
end

if RUBY_VERSION >= "2.6.0"
gem "turbo-rails"
gem "redis", "~> 4.0"
end
gem 'mongoid'

if RUBY_VERSION >= "2.5.0"
gem "rails", "~> 6.0"
gem 'webrick'
case rails_version = ENV['RAILS_VERSION']
when nil
gem 'rails'
when 'edge'
gem 'rails', github: 'rails/rails'
else
gem "rails", "~> 5.0"
gem 'rails', "~> #{rails_version}.0"
end

if RUBY_VERSION >= "2.7.0"
gem "mongoid", github: "mongodb/mongoid"
elsif RUBY_VERSION >= "2.6.0"
gem "mongoid", "~> 8.1"
else
gem "mongoid", "~> 7.2"
end

if RUBY_VERSION >= "3.1.0"
gem "net-imap"
gem "net-pop"
gem "net-smtp"
case RUBY_VERSION
when '2.6'...'3.0'
gem "turbo-rails", "<= 2.0.7"
gem "redis", "~> 4.0"
when '3.0'...'4'
gem 'turbo-rails'
gem 'redis', '~> 4.0'
end

if RUBY_VERSION < "2.5.0"
gem 'rspec-activerecord-expectations', '~> 1.2.0'
gem 'simplecov', '0.17.1'
gem "loofah", "< 2.21.0" # Workaround for `uninitialized constant Nokogiri::HTML4`
end
4 changes: 2 additions & 2 deletions draper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Gem::Specification.new do |s|
s.add_development_dependency 'ammeter'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'rspec-activerecord-expectations', '~> 1.2.0'
s.add_development_dependency 'rspec-activerecord-expectations'
s.add_development_dependency 'minitest-rails'
s.add_development_dependency 'capybara'
s.add_development_dependency 'active_model_serializers', '>= 0.10'
s.add_development_dependency 'rubocop'
s.add_development_dependency 'simplecov', '0.17.1'
s.add_development_dependency 'simplecov'
end

0 comments on commit 5fe90c6

Please sign in to comment.