Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
ci(actions): fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 committed Apr 29, 2020
1 parent f469061 commit 7d049d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
24 changes: 24 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
# frozen_string_literal: true

require 'rake/testtask'
require 'json'

Rake::TestTask.new do |test|
test.test_files = Dir.glob('test/**/*_spec.rb')
end

Rake::Task['test'].enhance do
# Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed
# upstream: https://github.com/codeclimate/test-reporter/issues/413
if ENV['CI'] == 'true'
def remove_lines_key(obj)
case obj
when Hash
obj.transform_values do |val|
val.is_a?(Hash) && val.key?('lines') ? val['lines'] : remove_lines_key(val)
end
else
obj
end
end

puts 'Patchin .resultset.json for CodeClimate compatability'
filename = 'coverage/.resultset.json'
contents = JSON.parse(File.read(filename))
# overwrite
File.write(filename, JSON.generate(remove_lines_key(contents)))
end
end

task(default: :test)
21 changes: 0 additions & 21 deletions test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,3 @@
require 'json'

SimpleCov.start

filename = 'coverage/.resultset.json'
contents = JSON.parse(File.read(filename))

# Temporary hack to get CodeClimate to work with SimpleCov 0.18 JSON format until issue is fixed
# upstream: https://github.com/codeclimate/test-reporter/issues/413
if ENV['CI'] == 'true'
def remove_lines_key(obj)
case obj
when Hash
obj.transform_values do |val|
val.is_a?(Hash) && val.key?('lines') ? val['lines'] : remove_lines_key(val)
end
else
obj
end
end

# overwrite
File.write(filename, JSON.generate(remove_lines_key(contents)))
end

0 comments on commit 7d049d3

Please sign in to comment.