Skip to content

Commit

Permalink
add override option to coverage task
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Aug 8, 2024
1 parent 283aac5 commit fedcfea
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/tasks/coverage.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ BASE_BRANCHES = ["main", "staging"]
CURRENT_COMMIT = ENV.fetch("CIRCLE_SHA1", "")
CSS_SELECTOR = ".fraction"
FRACTION_DELIM = "/"
REMOTE_COVERAGE_OVERRIDE = ENV.fetch('REMOTE_COVERAGE_OVERRIDE', '0').to_f

# Fetch JSON over HTTP. Rails probably already has a helper for this :shrug:
def open_json(url)
if REMOTE_COVERAGE_OVERRIDE > 0
return {}
end
begin
JSON.parse(URI.parse(url).open.read)
rescue *[OpenURI::HTTPError, SocketError] => exception
Expand Down Expand Up @@ -272,6 +276,16 @@ namespace :coverage do

if remote[:percent].nil?
puts "Error getting coveralls data."
puts "Checking for override."
percent = REMOTE_COVERAGE_OVERRIDE
if percent > 0
puts "Using override of #{percent}% for remote coverage value."
remote = { branch: "N/A", commit: "", percent: percent }
end
end

if remote[:percent].nil?
puts "No override available."
puts "Using 100 instead of nil for remote coverage value."
remote = { branch: "N/A", commit: "", percent: 100 }
end
Expand Down

0 comments on commit fedcfea

Please sign in to comment.