-
Notifications
You must be signed in to change notification settings - Fork 92
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
refactor start script and add option for custom coverage result path #158
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,20 @@ | |
|
||
require "codeclimate-test-reporter" | ||
|
||
COVERAGE_FILE = "coverage/.resultset.json".freeze | ||
repo_token = ENV["CODECLIMATE_REPO_TOKEN"] | ||
if repo_token.nil? || repo_token.empty? | ||
STDERR.puts "Cannot post results: environment variable CODECLIMATE_REPO_TOKEN must be set." | ||
exit | ||
end | ||
|
||
COVERAGE_FILE = ARGV.first || "coverage/.resultset.json" | ||
|
||
if (repo_token = ENV["CODECLIMATE_REPO_TOKEN"]) && !repo_token.empty? | ||
if File.exist?(COVERAGE_FILE) | ||
begin | ||
results = JSON.parse(File.read(COVERAGE_FILE)) | ||
rescue JSON::ParserError => e | ||
$stderr.puts "Error encountered while parsing #{COVERAGE_FILE}: #{e}" | ||
exit(1) | ||
end | ||
abort "Coverage results not found" unless File.exist?(COVERAGE_FILE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you either user parens here, or don't use them at L18? Our in-house style is to use parens except in special cases (e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright. I'd argue that abort is similar to puts and shouldn't be wrapped in parens, so i'll remove them in L18 |
||
|
||
CodeClimate::TestReporter.run(results) | ||
else | ||
$stderr.puts "Coverage results not found" | ||
exit(1) | ||
end | ||
else | ||
$stderr.puts "Cannot post results: environment variable CODECLIMATE_REPO_TOKEN must be set." | ||
exit(0) | ||
begin | ||
results = JSON.parse(File.read(COVERAGE_FILE)) | ||
rescue JSON::ParserError => e | ||
abort "Error encountered while parsing #{COVERAGE_FILE}: #{e}" | ||
end | ||
|
||
CodeClimate::TestReporter.run(results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do like the improvements in this PR and am happy to continue reviewing it as-is, but before I do so, what would you think of solving this issue with a smaller, and perhaps even more flexible change of:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem. Using option parser is maybe premature at this point. I'll update the pr.