Skip to content

Commit

Permalink
Merge pull request #1604 from tf/fix-ci
Browse files Browse the repository at this point in the history
Fix CI and abort when dummy app generation fails
  • Loading branch information
tf committed Nov 10, 2020
2 parents 3c6b46b + 4e5867b commit 6ce30ae
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -18,7 +18,7 @@ addons:
_ruby_job: &ruby_job
language: ruby
before_install:
- nvm install v10.17.0
- nvm install v10.23.0
- gem update bundler

_pageflow_ruby_job: &pageflow_ruby_job
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:

- name: Jest
language: node_js
node_js: 10.17.0
node_js: 10.23.0
install:
- yarn install
- (cd entry_types/paged/packages/pageflow-paged-react; yarn install)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -53,7 +53,7 @@ Pageflow assumes the following choice of libraries:
Pageflow runs in environments with:

* Ruby >= 2.1 (see `.travis.yml` for supported versions)
* Node >= 10.0
* Node >= 10.18
* Rails 4.2
* Redis server (for Resque)
* A database server supported by Active Record (tested with MySQL)
Expand Down
4 changes: 3 additions & 1 deletion spec/support/pageflow/dummy/app.rb
@@ -1,4 +1,5 @@
require 'pageflow/version'
require 'pageflow/dummy/exit_on_failure_patch'

module Pageflow
module Dummy
Expand All @@ -10,7 +11,8 @@ def generate
puts("Dummy directory #{directory} exists.")
else
system("bundle exec rails new #{directory} " \
"--template #{template_path} #{rails_new_options}")
"--template #{template_path} #{rails_new_options}") ||
raise('Error generating dummy app.')
end

require(File.join(ENV['RAILS_ROOT'], 'config', 'environment'))
Expand Down
25 changes: 25 additions & 0 deletions spec/support/pageflow/dummy/exit_on_failure_patch.rb
@@ -0,0 +1,25 @@
require 'rails/generators'

# Thor exits with 0, when an error occurs. This behavior is deprecated
# in 1.0 [1], but has not yet changed. As a result the dummy app
# generation is not aborted and tests fail due to confusing follow up
# errors. Rails provides an `abort_on_failure` option for `rake` and
# `generate` actions [2], but it needs to be added to each such
# action. In particular, generating the dummy app invokes other
# generators, which we do not have control over.
#
# To work around this problem, we override the default behavior for
# all generators and make them fail loudly.
#
# [1] https://github.com/erikhuda/thor/blob/master/CHANGELOG.md#100
# [2] https://github.com/rails/rails/pull/34420/

module Rails
module Generators
class Base
def self.exit_on_failure?
true
end
end
end
end

0 comments on commit 6ce30ae

Please sign in to comment.