Skip to content

Commit

Permalink
Update release script to update spec/dummy/package.json and fix Ruby …
Browse files Browse the repository at this point in the history
…2.1 issues (#867)

* remove <<~ syntax for Ruby 2
* change check for ENV COVERAGE to check value
* only automatically set COVERAGE if USE_COVERALLS
* update release script to update node version.
  • Loading branch information
justin808 authored Jun 9, 2017
1 parent 88608bd commit 27c2cbc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Starts SimpleCov for code coverage.

if ENV["COVERAGE"]
if ENV["COVERAGE"] == "true"
require "simplecov"

# Using a command name prevents results from getting clobbered by other test suites
Expand Down
2 changes: 1 addition & 1 deletion lib/react_on_rails/git_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module ReactOnRails
module GitUtils
def self.uncommitted_changes?(message_handler)
return false if ENV["COVERAGE"]
return false if ENV["COVERAGE"] == "true"
status = `git status --porcelain`
return false if status.empty?
error = "You have uncommitted code. Please commit or stash your changes before continuing"
Expand Down
24 changes: 15 additions & 9 deletions lib/react_on_rails/prerender_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ def initialize(component_name: nil, err: nil, props: nil,
js_code: nil, console_messages: nil)
message = "ERROR in SERVER PRERENDERING\n".dup
if err
message << <<~MSG
Encountered error: \"#{err}\"
# rubocop:disable Layout/IndentHeredoc
message << <<-MSG
Encountered error: \"#{err}\"
MSG
# rubocop:enable Layout/IndentHeredoc
backtrace = err.backtrace.join("\n")
else
backtrace = nil
end
message << <<~MSG
when prerendering #{component_name} with props: #{props}
js_code was:
#{js_code}
# rubocop:disable Layout/IndentHeredoc
message << <<-MSG
when prerendering #{component_name} with props: #{props}
js_code was:
#{js_code}
MSG
# rubocop:enable Layout/IndentHeredoc

if console_messages
message << <<~MSG
console messages:
#{console_messages}
# rubocop:disable Layout/IndentHeredoc
message << <<-MSG
console messages:
#{console_messages}
MSG
# rubocop:enable Layout/IndentHeredoc
end

super([message, backtrace].compact.join("\n"))
Expand Down
5 changes: 5 additions & 0 deletions rakelib/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ which are installed via `bundle install` and `yarn`
Example: `rake release[2.1.0,false]`")

# rubocop:disable Metrics/BlockLength
task :release, %i[gem_version dry_run tools_install] do |_t, args|
class MessageHandler
def add_error(error)
Expand Down Expand Up @@ -66,4 +67,8 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|

# Release the new gem version
sh_in_dir(gem_root, "gem release") unless is_dry_run

# Update master with new npm version
sh_in_dir(Path.join(gem_root, "spec", "dummy", "client"), "yarn add react-on-rails@#{npm_version}")
sh_in_dir(gem_root, "git commit -am 'Updated spec/dummy/client/package.json latest version'") unless is_dry_run
end
7 changes: 4 additions & 3 deletions rakelib/run_rspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace :run_rspec do

desc "(HACK) Run RSpec on spec/empty_spec in order to have SimpleCov generate a coverage report from cache"
task :empty do
sh %(COVERAGE=true rspec spec/empty_spec.rb)
sh %(#{ENV['USE_COVERALLS'] ? 'COVERAGE=true' : ''} rspec spec/empty_spec.rb)
end

Coveralls::RakeTask.new if ENV["USE_COVERALLS"] == "TRUE"
Expand All @@ -70,7 +70,7 @@ task :js_tests do
sh "yarn run test"
end

msg = <<~DESC
msg = <<-DESC.strip_heredoc
Runs all tests, run `rake -D run_rspec` to see all available test options.
"rake run_rspec:example_basic" is a good way to run only one generator test.
DESC
Expand Down Expand Up @@ -101,7 +101,8 @@ def run_tests_in(dir, options = {})

command_name = options.fetch(:command_name, path.basename)
rspec_args = options.fetch(:rspec_args, "")
env_vars = %(#{options.fetch(:env_vars, '')} COVERAGE=true TEST_ENV_COMMAND_NAME="#{command_name}")
env_vars = %(#{options.fetch(:env_vars, '')} TEST_ENV_COMMAND_NAME="#{command_name}").dup
env_vars << "COVERAGE=true" if ENV["USE_COVERALLS"]
sh_in_dir(path.realpath, "#{env_vars} bundle exec rspec #{rspec_args}")
end

Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/spec/simplecov_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Starts SimpleCov for code coverage.

if ENV["COVERAGE"]
if ENV["COVERAGE"] == "true"
require "simplecov"

# Using a command name along with the test_env_number prevents results from
Expand Down
2 changes: 1 addition & 1 deletion spec/react_on_rails/simplecov_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Starts SimpleCov for code coverage.

if ENV["COVERAGE"]
if ENV["COVERAGE"] == "true"
require "simplecov"
# Using a command name prevents results from getting clobbered by other test
# suites
Expand Down

0 comments on commit 27c2cbc

Please sign in to comment.