codecov 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/codecov.rb +1 -1
- data/lib/codecov/formatter.rb +99 -100
- data/lib/codecov/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e4bfdd1a36904d0b501d1e6ad97d5242e4a5ffa17a13b1c2968a8346bc26396
|
4
|
+
data.tar.gz: f0ee40b20016417dafc3aa0d68685872bd4ad2a6795cee3233b04f4de1ea3fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e669367d900a5b432fb511986f6e9276df0594378347de38d1a9462f344262fcc28f33333dfec8475afc68888811507cfb3db56398cea78bd28e0f557bbeddd
|
7
|
+
data.tar.gz: 1ff31b938ed8383c7dc6c067f607283d9d9aafe468302aef8957eb0ba64148c2361feb4b9c5e2129bf529987f09399c020288b542ca5741f8956948d358fcc27
|
data/lib/codecov.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative 'codecov/uploader'
|
|
11
11
|
|
12
12
|
class SimpleCov::Formatter::Codecov
|
13
13
|
def format(result, disable_net_blockers = true)
|
14
|
-
report = Codecov::SimpleCov::Formatter.format(result)
|
14
|
+
report = Codecov::SimpleCov::Formatter.new.format(result)
|
15
15
|
Codecov::Uploader.upload(report, disable_net_blockers)
|
16
16
|
end
|
17
17
|
end
|
data/lib/codecov/formatter.rb
CHANGED
@@ -4,122 +4,121 @@ require 'simplecov'
|
|
4
4
|
|
5
5
|
require_relative 'version'
|
6
6
|
|
7
|
-
module Codecov
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
module Codecov
|
8
|
+
module SimpleCov
|
9
|
+
class Formatter
|
10
|
+
RESULT_FILE_NAME = 'codecov-result.json'
|
11
|
+
|
12
|
+
def format(report)
|
13
|
+
result = {
|
14
|
+
'meta' => {
|
15
|
+
'version' => "codecov-ruby/v#{::Codecov::VERSION}"
|
16
|
+
}
|
13
17
|
}
|
14
|
-
|
15
|
-
result.update(result_to_codecov(report))
|
16
|
-
result
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
# Format SimpleCov coverage data for the Codecov.io API.
|
22
|
-
#
|
23
|
-
# @param result [SimpleCov::Result] The coverage data to process.
|
24
|
-
# @return [Hash]
|
25
|
-
def self.result_to_codecov(result)
|
26
|
-
{
|
27
|
-
'codecov' => result_to_codecov_report(result),
|
28
|
-
'coverage' => result_to_codecov_coverage(result),
|
29
|
-
'messages' => result_to_codecov_messages(result)
|
30
|
-
}
|
31
|
-
end
|
18
|
+
result.update(result_to_codecov(report))
|
32
19
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
invalid_file_types = [
|
40
|
-
'woff', 'eot', 'otf', # fonts
|
41
|
-
'gif', 'png', 'jpg', 'jpeg', 'psd', # images
|
42
|
-
'ptt', 'pptx', 'numbers', 'pages', 'md', 'txt', 'xlsx', 'docx', 'doc', 'pdf', 'csv', # docs
|
43
|
-
'yml', 'yaml', '.gitignore'
|
44
|
-
].freeze
|
45
|
-
|
46
|
-
invalid_directories = [
|
47
|
-
'node_modules/',
|
48
|
-
'public/',
|
49
|
-
'storage/',
|
50
|
-
'tmp/',
|
51
|
-
'vendor/'
|
52
|
-
]
|
53
|
-
|
54
|
-
puts [green('==>'), 'Appending file network'].join(' ')
|
55
|
-
network = []
|
56
|
-
Dir['**/*'].keep_if do |file|
|
57
|
-
if File.file?(file) && !file.end_with?(*invalid_file_types) && invalid_directories.none? { |dir| file.include?(dir) }
|
58
|
-
network.push(file)
|
20
|
+
result_path = File.join(::SimpleCov.coverage_path, RESULT_FILE_NAME)
|
21
|
+
if File.writable?(result_path)
|
22
|
+
File.write(result_path, result['codecov'])
|
23
|
+
puts "Coverage report generated to #{result_path}.\#{result}"
|
24
|
+
else
|
25
|
+
puts "Could not write coverage report to file #{result_path}.\n#{result}"
|
59
26
|
end
|
27
|
+
|
28
|
+
result
|
60
29
|
end
|
61
30
|
|
62
|
-
|
63
|
-
|
64
|
-
|
31
|
+
private
|
32
|
+
|
33
|
+
# Format SimpleCov coverage data for the Codecov.io API.
|
34
|
+
#
|
35
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
36
|
+
# @return [Hash]
|
37
|
+
def result_to_codecov(result)
|
38
|
+
{
|
39
|
+
'codecov' => result_to_codecov_report(result),
|
40
|
+
'coverage' => result_to_codecov_coverage(result),
|
41
|
+
'messages' => result_to_codecov_messages(result)
|
42
|
+
}
|
43
|
+
end
|
65
44
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
# @return [Hash<String, Array>]
|
70
|
-
def self.result_to_codecov_coverage(result)
|
71
|
-
result.files.each_with_object({}) do |file, memo|
|
72
|
-
memo[shortened_filename(file)] = file_to_codecov(file)
|
45
|
+
def result_to_codecov_report(result)
|
46
|
+
report = file_network.join("\n").concat("\n")
|
47
|
+
report.concat({ 'coverage' => result_to_codecov_coverage(result) }.to_json)
|
73
48
|
end
|
74
|
-
end
|
75
49
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
50
|
+
def file_network
|
51
|
+
invalid_file_types = [
|
52
|
+
'woff', 'eot', 'otf', # fonts
|
53
|
+
'gif', 'png', 'jpg', 'jpeg', 'psd', # images
|
54
|
+
'ptt', 'pptx', 'numbers', 'pages', 'md', 'txt', 'xlsx', 'docx', 'doc', 'pdf', 'csv', # docs
|
55
|
+
'yml', 'yaml', '.gitignore'
|
56
|
+
].freeze
|
57
|
+
|
58
|
+
invalid_directories = [
|
59
|
+
'node_modules/',
|
60
|
+
'public/',
|
61
|
+
'storage/',
|
62
|
+
'tmp/',
|
63
|
+
'vendor/'
|
64
|
+
]
|
65
|
+
|
66
|
+
network = []
|
67
|
+
Dir['**/*'].keep_if do |file|
|
68
|
+
if File.file?(file) && !file.end_with?(*invalid_file_types) && invalid_directories.none? { |dir| file.include?(dir) }
|
69
|
+
network.push(file)
|
70
|
+
end
|
84
71
|
end
|
72
|
+
|
73
|
+
network.push('<<<<<< network')
|
74
|
+
network
|
85
75
|
end
|
86
|
-
end
|
87
76
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
if line.skipped?
|
96
|
-
nil
|
97
|
-
else
|
98
|
-
line.coverage
|
77
|
+
# Format SimpleCov coverage data for the Codecov.io coverage API.
|
78
|
+
#
|
79
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
80
|
+
# @return [Hash<String, Array>]
|
81
|
+
def result_to_codecov_coverage(result)
|
82
|
+
result.files.each_with_object({}) do |file, memo|
|
83
|
+
memo[shortened_filename(file)] = file_to_codecov(file)
|
99
84
|
end
|
100
85
|
end
|
101
|
-
end
|
102
86
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
str.nil? ? '' : "\e[30m#{str}\e[0m"
|
115
|
-
end
|
87
|
+
# Format SimpleCov coverage data for the Codecov.io messages API.
|
88
|
+
#
|
89
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
90
|
+
# @return [Hash<String, Hash>]
|
91
|
+
def result_to_codecov_messages(result)
|
92
|
+
result.files.each_with_object({}) do |file, memo|
|
93
|
+
memo[shortened_filename(file)] = file.lines.each_with_object({}) do |line, lines_memo|
|
94
|
+
lines_memo[line.line_number.to_s] = 'skipped' if line.skipped?
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
116
98
|
|
117
|
-
|
118
|
-
|
119
|
-
|
99
|
+
# Format coverage data for a single file for the Codecov.io API.
|
100
|
+
#
|
101
|
+
# @param file [SimpleCov::SourceFile] The file to process.
|
102
|
+
# @return [Array<nil, Integer>]
|
103
|
+
def file_to_codecov(file)
|
104
|
+
# Initial nil is required to offset line numbers.
|
105
|
+
[nil] + file.lines.map do |line|
|
106
|
+
if line.skipped?
|
107
|
+
nil
|
108
|
+
else
|
109
|
+
line.coverage
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
120
113
|
|
121
|
-
|
122
|
-
|
114
|
+
# Get a filename relative to the project root. Based on
|
115
|
+
# https://github.com/colszowka/simplecov-html, copyright Christoph Olszowka.
|
116
|
+
#
|
117
|
+
# @param file [SimpleCov::SourceFile] The file to use.
|
118
|
+
# @return [String]
|
119
|
+
def shortened_filename(file)
|
120
|
+
file.filename.gsub(/^#{::SimpleCov.root}/, '.').gsub(%r{^\./}, '')
|
121
|
+
end
|
123
122
|
end
|
124
123
|
end
|
125
124
|
end
|
data/lib/codecov/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codecov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Peak
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simplecov
|