Skip to content

Commit

Permalink
Add rails 6.0 config to travis (lynndylanhurley#1366)
Browse files Browse the repository at this point in the history
* Add rails 6.0 config to travis

* Exclude Travis Rails 6.0 checks for Ruby below 2.5

* Updates tests to be compatible with Rails 6

Rails 6 no longer generates migration with id: :uuid, so I changed the range of two ifs in tests and everything goes well now.

* Add Ruby 2.7.0 to Travis

* Exclude travis test for Ruby 2.7.0 with Rails 4.2

Ruby 2.7 comes with Bundler 2 which is not compatible with Rails 4

* Add to Travis test for rails 6 + mongoid 7

* Downgrade mongoid-locker for rails 6 gemfile

* Allow to change primary key type for Rails 6
  • Loading branch information
brateq committed Jan 30, 2020
1 parent 880a249 commit 8326cc7
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 44 deletions.
91 changes: 51 additions & 40 deletions .travis.yml
Expand Up @@ -11,12 +11,14 @@ rvm:
- 2.4.7
- 2.5.6
- 2.6.4
- 2.7.0

gemfile:
- gemfiles/rails_4_2.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile

env:
global:
Expand All @@ -28,51 +30,60 @@ env:

matrix:
include:
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rmv: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
- rvm: 2.3.8
gemfile: gemfiles/rails_4_2_mongoid_5.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.3.8
gemfile: gemfiles/rails_5_1_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.4.7
gemfile: gemfiles/rails_5_1_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_6.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.5.6
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.6.4
gemfile: gemfiles/rails_5_2_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- rvm: 2.7.0
gemfile: gemfiles/rails_6_0_mongoid_7.gemfile
env: DEVISE_TOKEN_AUTH_ORM=mongoid
- name: Code Climate Test Coverage
rvm: 2.5.6
env:
- CC_TEST_REPORTER_ID=44d7688de8e1b567b4af25ec5083c2cc0a355ab911192a7cbefd1ea25b2ffd3d
- GEMFILE_AR=gemfiles/rails_5_1.gemfile
- GEMFILE_MONGOID=gemfiles/rails_5_1_mongoid_7.gemfile
script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
# with ActiveRecord
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_AR
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake --trace db:migrate
- BUNDLE_GEMFILE=$GEMFILE_AR bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.active_record.json coverage/.resultset.json
# with Mongoid
- bundle install --jobs=3 --retry=3 --gemfile $GEMFILE_MONGOID
- BUNDLE_GEMFILE=$GEMFILE_MONGOID DEVISE_TOKEN_AUTH_ORM=mongoid bundle exec rake
- ./cc-test-reporter format-coverage -t simplecov -o coverage/codeclimate.mongoid.json coverage/.resultset.json
# merge test results
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then
./cc-test-reporter sum-coverage coverage/codeclimate.active_record.json coverage/codeclimate.mongoid.json;
./cc-test-reporter upload-coverage;
fi
fi
exclude:
- rvm: 2.6.4
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.7.0
gemfile: gemfiles/rails_4_2.gemfile
- rvm: 2.3.8
gemfile: gemfiles/rails_6_0.gemfile
- rvm: 2.4.7
gemfile: gemfiles/rails_6_0.gemfile
fast_finish: true

before_install:
Expand Down
3 changes: 2 additions & 1 deletion Appraisals
Expand Up @@ -32,7 +32,8 @@ end
{ name: '5-1', ruby: '2.4.5', rails: '5.1', mongoid: '7.0' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '6.4' },
{ name: '5-2', ruby: '2.5.5', rails: '5.2', mongoid: '7.0' },
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' }
{ name: '5-2', ruby: '2.6.2', rails: '5.2', mongoid: '7.0' },
{ name: '6-0', ruby: '2.7.0', rails: '6.0', mongoid: '7.0' }
].each do |set|
appraise "rails-#{set[:name]}-mongoid-#{set[:mongoid][0]}" do
gem 'rails', "~> #{set[:rails]}"
Expand Down
45 changes: 45 additions & 0 deletions gemfiles/rails_6_0.gemfile
@@ -0,0 +1,45 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0"
gem "sqlite3", "~> 1.4.1"
gem "mysql2"
gem "pg"

group :development, :test do
gem "attr_encrypted"
gem "figaro", git: "https://github.com/laserlemon/figaro"
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
gem "factory_bot_rails"
gem "faker"
gem "fuzz_ball"
gem "guard"
gem "guard-minitest"
gem "minitest"
gem "minitest-focus"
gem "minitest-rails"
gem "minitest-reporters"
gem "mocha", ">= 1.5"
gem "pry"
gem "pry-byebug"
gem "pry-remote"
gem "rubocop", require: false
end

group :test do
gem "rails-controller-testing"
gem "simplecov", require: false
end

group :development do
gem "github_changelog_generator"
end

gemspec path: "../"
44 changes: 44 additions & 0 deletions gemfiles/rails_6_0_mongoid_7.gemfile
@@ -0,0 +1,44 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0"
gem "mongoid", "~> 7.0"
gem "mongoid-locker", "~> 1.0"

group :development, :test do
gem "attr_encrypted"
gem "figaro", git: "https://github.com/laserlemon/figaro"
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem "omniauth-apple"
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
gem "factory_bot_rails"
gem "faker"
gem "fuzz_ball"
gem "guard"
gem "guard-minitest"
gem "minitest"
gem "minitest-focus"
gem "minitest-rails"
gem "minitest-reporters"
gem "mocha", ">= 1.5"
gem "pry"
gem "pry-byebug"
gem "pry-remote"
gem "rubocop", require: false
end

group :test do
gem "rails-controller-testing"
gem "simplecov", require: false
end

group :development do
gem "github_changelog_generator"
end

gemspec path: "../"
6 changes: 3 additions & 3 deletions lib/generators/devise_token_auth/install_generator.rb
Expand Up @@ -75,12 +75,12 @@ def database_version
ActiveRecord::Base.connection.select_value('SELECT VERSION()')
end

def rails5?
Rails.version.start_with? '5'
def rails_5_or_newer?
Rails::VERSION::MAJOR >= 5
end

def primary_key_type
primary_key_string if rails5?
primary_key_string if rails_5_or_newer?
end

def primary_key_string
Expand Down

0 comments on commit 8326cc7

Please sign in to comment.