From 0bd6f65f711ad104dc8a8412fe912b24649497df Mon Sep 17 00:00:00 2001 From: Alex Rothenberg Date: Wed, 24 Feb 2021 12:47:40 -0500 Subject: [PATCH] Moving CI to github actions & trying to get it green Some of the missing combinations in the matrix: * Ruby 3 with Rails 5.2 are skipped because my tests error when trying to start rails * Rspec-rails 3 with Rails 6.1 because of a rails change rspec-rails needs https://github.com/rspec/rspec-rails/pull/2215 or the more recent https://github.com/rspec/rspec-rails/pull/2461 --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++ .travis.yml | 22 ------- Gemfile | 44 ++++---------- README.md | 2 +- Rakefile | 3 +- ammeter.gemspec | 2 - features/support/env.rb | 2 +- features/templates/generate_example_app.rb | 1 - features/templates/my_rails_gem/Gemfile | 16 +---- features/templates/my_railties_gem/Gemfile | 16 +---- 10 files changed, 91 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e26d4a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: Ammeter CI +on: + push: + branches: + - 'main' + - 'gitub-action-ci' + pull_request: + branches: + - '*' +jobs: + test: + name: 'Ruby: ${{ matrix.ruby }}, Rspec: ${{matrix.env.RSPEC_VERSION}}, Rails: ${{ matrix.env.RAILS_VERSION }}' + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + - ruby: 3.0 + env: + RSPEC_VERSION: 'master' + RAILS_VERSION: '~> 6.1.0' + - ruby: 3.0 + env: + RSPEC_VERSION: '~> 4.0' + RAILS_VERSION: '~> 6.1.0' + - ruby: 3.0 + env: + RSPEC_VERSION: '~> 4.0' + RAILS_VERSION: '~> 6.0.0' + - ruby: 3.0 + env: + RSPEC_VERSION: '~> 3.9' + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.5 + env: + RSPEC_VERSION: 'master' + RAILS_VERSION: '~> 6.1.0' + - ruby: 2.5 + env: + RSPEC_VERSION: '~> 4.0' + RAILS_VERSION: '~> 6.1.0' + - ruby: 2.5 + env: + RSPEC_VERSION: '~> 4.0' + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.5 + env: + RSPEC_VERSION: '~> 4.0' + RAILS_VERSION: '~> 5.2.0' + - ruby: 2.5 + env: + RSPEC_VERSION: '~> 3.9' + RAILS_VERSION: '~> 6.0.0' + - ruby: 2.5 + env: + RSPEC_VERSION: '~> 3.9' + RAILS_VERSION: '~> 5.2.0' + - ruby: ruby-head + env: + RSPEC_VERSION: 'master' + RAILS_VERSION: '~> 6.1.0' + env: ${{ matrix.env }} + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - run: bundle install + - run: bundle exec rake ci + continue-on-error: ${{ matrix.allow_failure || false }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3f6067b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: ruby -sudo: false - -rvm: - - 2.6 - - 2.7 - - 3.0 - - ruby-head - - jruby-9.2.14 - -env: - - RSPEC_VERSION=master - - RSPEC_VERSION='~> 3.10' - -bundler_args: "--retry=3 --jobs=3" - -script: "bundle exec rake ci --trace" - -matrix: - allow_failures: - - rvm: ruby-head - - rvm: jruby-9.2.14.0 diff --git a/Gemfile b/Gemfile index 0dee7b8..b6dfca0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ -source "http://rubygems.org" +source 'https://rubygems.org' -rspec_version = ENV['RSPEC_VERSION'] -rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3' +rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0' +rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0' if rspec_version == 'master' gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git' @@ -13,38 +13,16 @@ if rspec_version == 'master' gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git' else gem 'rspec-rails', rspec_version - gem 'rspec', rspec_version end -if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9 - # rspec 2.x does not support Rails 4.1+ nor does Ruby 1.8.7 - gem 'rails', '~> 3.2' - gem 'uglifier', '~> 1.2.4' - gem 'rake', '~> 0.9.2.2' - gem 'coffee-rails', '~> 3.2' - gem 'sass-rails', '~> 3.2' - gem 'jquery-rails', '~> 2.0' - gem 'haml-rails', '~> 0.4' - gem 'execjs', '~> 2.0.0' -elsif rspec_major_version == '3' - if RUBY_VERSION < '2.2.2' - gem 'rails', '< 5.0' # rails 5 is ruby >= 2.2.2 - else - gem 'rails', '>= 4.0' - end - gem 'uglifier', '>= 1.3' - gem 'rake', '>= 0.10' - gem 'coffee-rails', '>= 4.0' - gem 'sass-rails', '>= 4.0' - gem 'jquery-rails', '>= 3.0' - gem 'haml-rails', '>= 0.5' -else - raise "rspec version #{rspec_version} is not supported" -end - -gem "i18n", '< 0.7.0' if RUBY_VERSION < '1.9.3' -gem "rack", '<= 1.6.4' if RUBY_VERSION < '2.2.2' +gem 'rails', rails_version +gem 'uglifier' +gem 'rake' +gem 'coffee-rails' +gem 'sass-rails' +gem 'jquery-rails' +gem 'haml-rails' -# Specify your gem's dependencies in rspec-rails-generator-specs.gemspec +# Specify your gem's dependencies in ammeter.gemspec gemspec diff --git a/README.md b/README.md index 8d4e845..d54ba3a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ammeter [![Build Status](https://secure.travis-ci.org/alexrothenberg/ammeter.png)](http://travis-ci.org/alexrothenberg/ammeter) [![Code Climate](https://codeclimate.com/github/alexrothenberg/ammeter.png)](https://codeclimate.com/github/alexrothenberg/ammeter) [![Gem Version](https://badge.fury.io/rb/ammeter.png)](http://badge.fury.io/rb/ammeter) +# Ammeter [![Ammeter CI](https://github.com/alexrothenberg/ammeter/actions/workflows/ci.yml/badge.svg)](https://github.com/alexrothenberg/ammeter/actions/workflows/ci.yml) [![Code Climate](https://codeclimate.com/github/alexrothenberg/ammeter.png)](https://codeclimate.com/github/alexrothenberg/ammeter) [![Gem Version](https://badge.fury.io/rb/ammeter.png)](http://badge.fury.io/rb/ammeter) A gem that makes it easy to write specs for your Rails 3 Generators. diff --git a/Rakefile b/Rakefile index e21ca75..464d8e2 100644 --- a/Rakefile +++ b/Rakefile @@ -42,13 +42,12 @@ end namespace :generate do desc "generate a fresh app with rspec installed" task :app => :ensure_bundler_11 do |t| - sh "bundle exec rails new ./tmp/example_app -m 'features/templates/generate_example_app.rb' --skip-test-unit" + sh "bundle exec rails new ./tmp/example_app -m 'features/templates/generate_example_app.rb' --skip-test-unit --skip-bootsnap --skip-spring --skip-webpack-install" sh "cp 'features/templates/rspec.rake' ./tmp/example_app/lib/tasks" Dir.chdir("./tmp/example_app/") do Bundler.unbundled_system 'bundle install' Bundler.unbundled_system 'rake db:migrate' Bundler.unbundled_system 'rails g rspec:install' - Bundler.unbundled_system 'spring stop' end end diff --git a/ammeter.gemspec b/ammeter.gemspec index 2d13f4c..fe9939d 100644 --- a/ammeter.gemspec +++ b/ammeter.gemspec @@ -21,8 +21,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'activesupport', '>= 3.0' s.add_runtime_dependency 'rspec-rails', '>= 2.2' - s.add_runtime_dependency 'bootsnap' - s.add_development_dependency 'rspec', '>= 2.2' s.add_development_dependency 'rails', '>= 3.1' s.add_development_dependency 'uglifier', '>= 1.2.4' diff --git a/features/support/env.rb b/features/support/env.rb index 0e3646c..162ddb5 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -42,7 +42,7 @@ def copy_to_aruba_from(gem_or_app_name) if rspec_major_version == '2' # rspec 2.x does not create rails_helper.rb so we create a symlink to avoid cluttering tests write_symlink("tmp/#{gem_or_app_name}/spec/spec_helper.rb", gem_or_app_name, 'rails_helper.rb') - elsif rspec_major_version == '3' + elsif rspec_major_version >= '3' write_symlink("tmp/#{gem_or_app_name}/spec/rails_helper.rb", gem_or_app_name) end end diff --git a/features/templates/generate_example_app.rb b/features/templates/generate_example_app.rb index 7c6e305..d0c35b1 100644 --- a/features/templates/generate_example_app.rb +++ b/features/templates/generate_example_app.rb @@ -11,7 +11,6 @@ gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git' else gem 'rspec-rails', rspec_version - gem 'rspec', rspec_version end gem "i18n", '< 0.7.0' if RUBY_VERSION < '1.9.3' diff --git a/features/templates/my_rails_gem/Gemfile b/features/templates/my_rails_gem/Gemfile index de20d55..61e6319 100644 --- a/features/templates/my_rails_gem/Gemfile +++ b/features/templates/my_rails_gem/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' -rspec_version = ENV['RSPEC_VERSION'] -rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3' +rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0' +rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0' if rspec_version == 'master' gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git' @@ -13,19 +13,9 @@ if rspec_version == 'master' gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git' else gem 'rspec-rails', rspec_version - gem 'rspec', rspec_version -end - -if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9 - gem 'rails', '~> 3.2.0' - # Execjs is causing problems on 1.8.7 - gem 'execjs', '~> 2.0.0' -elsif rspec_major_version == '3' - gem 'rails', '>= 4.1' -else - raise "rspec version #{rspec_version} is not supported" end +gem 'rails', rails_version # Specify your gem's dependencies in my_gem.gemspec gemspec diff --git a/features/templates/my_railties_gem/Gemfile b/features/templates/my_railties_gem/Gemfile index e784851..7ad5e8c 100644 --- a/features/templates/my_railties_gem/Gemfile +++ b/features/templates/my_railties_gem/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' -rspec_version = ENV['RSPEC_VERSION'] -rspec_major_version = (rspec_version && rspec_version != 'master') ? rspec_version.scan(/\d+/).first : '3' +rspec_version = ENV['RSPEC_VERSION'] || '~> 4.0' +rails_version = ENV['RAILS_VERSION'] || '>= 5.1.0' if rspec_version == 'master' gem "rspec-rails", :git => 'git://github.com/rspec/rspec-rails.git' @@ -13,19 +13,9 @@ if rspec_version == 'master' gem "rspec-support", :git => 'git://github.com/rspec/rspec-support.git' else gem 'rspec-rails', rspec_version - gem 'rspec', rspec_version -end - -if rspec_major_version == '2' || RUBY_VERSION.to_f < 1.9 - gem 'railties', '~> 3.2.0' - # Execjs is causing problems on 1.8.7 - #gem 'execjs', '~> 2.0.0' -elsif rspec_major_version == '3' - gem 'railties', '>= 4.1' -else - raise "rspec version #{rspec_version} is not supported" end +gem 'railties', rails_version # Specify your gem's dependencies in my_gem.gemspec gemspec