Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

travis test under rails 6 edge using 'appraisal' gem #35

Merged
merged 4 commits into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/spec/internal/tmp/cache
/tmp/
.byebug_history
/gemfiles/*.lock
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ language: ruby
cache: bundler
rvm:
- 2.4
- 2.5.0
env:
- RAILS_GEM="~> 5.0.0" PG_GEM="~> 0.18"
- RAILS_GEM="~> 5.1.0"
- RAILS_GEM=">= 5.2.0.rc2,< 5.3.0"
- 2.5.1
gemfile:
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_edge_6.gemfile
before_install:
- gem install bundler -v 1.14.6
matrix:
allow_failures:
- gemfile: gemfiles/rails_edge_6.gemfile
40 changes: 40 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
appraise "rails-5-0" do
gem 'combustion', '~> 0.9.0'

gem "rails", "~> 5.0.0"

# rails 5.1+ includes it by default, but rails 5.0 needs it:
gem 'rails-ujs', require: false

# Rails 5 won't work with pg 1.0 even though it doesn't say so
gem "pg", "~> 0.18"
end

appraise "rails-5-1" do
gem 'combustion', '~> 0.9.0'

gem "rails", "~> 5.1.0"

gem "pg", "~> 1.0"
end

appraise "rails-5-2" do
gem 'combustion', '~> 0.9.0'

gem "rails", "~> 5.2.0"
gem "pg", "~> 1.0"
end

appraise "rails-edge-6" do
# Edge rails needs unreleased combustion
# https://github.com/pat/combustion/issues/92
gem 'combustion', git: "https://github.com/pat/combustion.git"

gem "rails", git: "https://github.com/rails/rails.git", branch: "master"
gem "pg", "~> 1.0"

# We don't actually use coffeescript at all, we need coffee-rails as an explicit
# dependency just for transitory edge weirdness using current sprockets release
# with rails 6 edge.
gem 'coffee-rails'
end
66 changes: 31 additions & 35 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,36 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in attr_json.gemspec
gemspec

# for our integration test in a real rails env, we add em in development too,
# so we can bring up the app or a console in development to play with it.
group :test, :development do
gem 'combustion', '~> 0.9.0'
# all of rails is NOT a dependency, just activerecord.
# But we use it for integration testing with combustion. Hmm, a bit annoying
# that now our other tests can't be sure they're depending, this might not
# be the way to do it.
gem "rails", ENV["RAILS_GEM"] && ENV["RAILS_GEM"].split(",")

# Rails 5.0 won't work with pg 1.0, but that isn't actually in it's gemspec.
# So we specify a compatible PG_GEM spec when testing with rails 5.
ENV['PG_GEM'] ||= ">= 0.18.1"
gem "pg", ENV['PG_GEM']

gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem 'cocoon', ">= 1.2"
gem 'jquery-rails'
gem 'capybara', "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"
# rails 5.1+ includes it by default, but rails 5.0 needs it:
gem 'rails-ujs', require: false
end

if ENV['RAILS_GEM']
gem "activerecord", ENV['RAILS_GEM'].split(",")

# This shouldn't really be needed, but seems to maybe be a bundler bug,
# this makes standalone_migrations dependencies resolve properly even when our
# RAILS_REQ is for 5.2.0.rc2. If in the future you delete this and everything
# still passes, feel free to remove.
gem "railties", ENV['RAILS_GEM'].split(",")
end
# Dependencies for testing and development. To let appraisal override them, we
# do NOT put them in group :test,:development -- which anyway doesn't make a
# lot of sense in a gem Gemfile anyway, there is no "production" in a gem Gemfile.
#
# We also have these development dependencies here in the Gemfile instead of the
# gemspec so appraisal can override them from our Appraisal file.

gem 'combustion', '~> 0.9.0'

# all of rails is NOT a dependency, just activerecord.
# But we use it for integration testing with combustion. Hmm, a bit annoying
# that now our other tests can't be sure they're depending, this might not
# be the way to do it.
gem 'rails'

# We should not really need to mention railties, it's already a dependency of
# rails, but seems to be necessary to get around some mystery bug in bundler
# dependency resolution.
gem 'railties'

gem "pg"
gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem 'cocoon', ">= 1.2"
gem 'jquery-rails'

gem 'capybara', "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"

gem "byebug"


2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ At present this does mean that all our automated tests are run in a full Rails e

Tests are in rspec, run tests simply with `./bin/rspec`.

We use [appraisal](https://github.com/thoughtbot/appraisal) to test with multiple rails versions, including on travis. Locally you can run `bundle exec appraisal rspec` to run tests multiple times for each rails version, or eg `bundle exec appraisal rails-5-1 rspec`. If the `Gemfile` _or_ `Appraisal` file changes, you may need to re-run `bundle exec appraisal install` and commit changes. (Try to put dev dependencies in gemspec instead of Gemfile, but sometimes it gets weird.)

There is a `./bin/console` that will give you a console in the context of attr_json and all it's dependencies, including the combustion rails app, and the models defined there.

## Acknowledements and Prior Art
Expand Down
7 changes: 6 additions & 1 deletion attr_json.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ attributes use as much of the existing ActiveRecord architecture as we can.}

spec.required_ruby_version = '>= 2.4.0'

spec.add_runtime_dependency "activerecord", ">= 5.0.0", "< 5.3"
# Only to get CI to work on versions of Rails other than we release with,
# should never release a gem with RAILS_GEM set!
unless ENV['APPRAISAL_INITIALIZED'] || ENV["TRAVIS"]
spec.add_runtime_dependency "activerecord", ">= 5.0.0", "< 5.3"
end

spec.add_development_dependency "bundler", "~> 1.14"
spec.add_development_dependency "rake", ">= 10.0"
spec.add_development_dependency "rspec", "~> 3.7"
spec.add_development_dependency "database_cleaner", "~> 1.5"
spec.add_development_dependency "yard-activesupport-concern"
spec.add_development_dependency "appraisal", "~> 2.2"
end
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
19 changes: 19 additions & 0 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "combustion", "~> 0.9.0"
gem "rails", "~> 5.0.0"
gem "railties"
gem "pg", "~> 0.18"
gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem "cocoon", ">= 1.2"
gem "jquery-rails"
gem "capybara", "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"
gem "byebug"
gem "rails-ujs", require: false

gemspec path: "../"
18 changes: 18 additions & 0 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "combustion", "~> 0.9.0"
gem "rails", "~> 5.1.0"
gem "railties"
gem "pg", "~> 1.0"
gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem "cocoon", ">= 1.2"
gem "jquery-rails"
gem "capybara", "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"
gem "byebug"

gemspec path: "../"
18 changes: 18 additions & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "combustion", "~> 0.9.0"
gem "rails", "~> 5.2.0"
gem "railties"
gem "pg", "~> 1.0"
gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem "cocoon", ">= 1.2"
gem "jquery-rails"
gem "capybara", "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"
gem "byebug"

gemspec path: "../"
19 changes: 19 additions & 0 deletions gemfiles/rails_edge_6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "combustion", git: "https://github.com/pat/combustion.git"
gem "rails", git: "https://github.com/rails/rails.git", branch: "master"
gem "railties"
gem "pg", "~> 1.0"
gem "rspec-rails", "~> 3.7"
gem "simple_form", ">= 4.0"
gem "cocoon", ">= 1.2"
gem "jquery-rails"
gem "capybara", "~> 3.0"
gem "chromedriver-helper"
gem "selenium-webdriver"
gem "byebug"
gem "coffee-rails"

gemspec path: "../"