codecov 0.4.0 → 0.5.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/CHANGELOG.md +130 -0
- data/LICENSE +21 -0
- data/README.md +111 -0
- data/lib/codecov.rb +1 -1
- data/lib/codecov/configuration.rb +7 -0
- data/lib/codecov/formatter.rb +101 -100
- data/lib/codecov/uploader.rb +30 -4
- data/lib/codecov/version.rb +1 -1
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eda9a2c15cf9bca5603e8da966b08f4e74a880d225b1e367581f231c41bc6c54
|
4
|
+
data.tar.gz: dd8dfbafe0b700149632bcc252154b64d56324e7539ff535cd1a5a354c93485d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84fb4095ba5a0a99f7a4089ca1f391f32703aa5ce8f5e31bb2de1a59dd6b559609d7ca83fa33b44695d9b6b3d34f6828b63435665142ac94a3750c0947895978
|
7
|
+
data.tar.gz: 1278f5daa1420a6926352164efec3922099d81fce34f6dc6140aa7166ebc54f8ffd3c47c781c3d07ca3d7bbbf4eb589c3ca12145458d1f6edfa0a3c4c43a5184
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
### `0.5.1`
|
2
|
+
- #138 Update pass_ci_if_error flag
|
3
|
+
|
4
|
+
### `0.5.0`
|
5
|
+
- #137 Place uploader in try/rescue block and add pass_ci_if_error flag
|
6
|
+
|
7
|
+
### `0.4.3`
|
8
|
+
- #135 Shorten coverage message on formatter
|
9
|
+
|
10
|
+
### `0.4.2`
|
11
|
+
- #134 Wrap file creation in try/catch
|
12
|
+
|
13
|
+
### `0.4.1`
|
14
|
+
- #133 Write down to file when using the formatter
|
15
|
+
|
16
|
+
### `0.4.0`
|
17
|
+
- #130 Split uploader from formatter
|
18
|
+
|
19
|
+
### `0.3.0`
|
20
|
+
- #124 Ruby 3.0 support
|
21
|
+
- #125 open simplecov requirement to 0.21.x
|
22
|
+
|
23
|
+
### `0.2.15`
|
24
|
+
- #118 Include codecov/version in the gem
|
25
|
+
|
26
|
+
### `0.2.14`
|
27
|
+
- #107 Add EditorConfig file
|
28
|
+
- #113 Return version constant, don't duplicate version value
|
29
|
+
- #117 Update simplecov dependency versions
|
30
|
+
|
31
|
+
### `0.2.13`
|
32
|
+
- [#105](https://github.com/codecov/codecov-ruby/pull/105) Remove unnecessary dependency for ruby standard gem
|
33
|
+
- [#110](https://github.com/codecov/codecov-ruby/pull/110) Fix GitHub Actions
|
34
|
+
- [#111](https://github.com/codecov/codecov-ruby/pull/111) Fix branch name detection for GitHub Actions CI
|
35
|
+
|
36
|
+
### `0.2.12`
|
37
|
+
- [#102](https://github.com/codecov/codecov-ruby/pull/102) Fix value of params[:pr] when useing CodeBuild
|
38
|
+
|
39
|
+
### `0.2.11`
|
40
|
+
- Add vendor/ to invalid directories
|
41
|
+
|
42
|
+
### `0.2.10`
|
43
|
+
- Adds better logging on error cases
|
44
|
+
- Add more invalid directories in the network
|
45
|
+
|
46
|
+
### `0.2.9`
|
47
|
+
- Remove `String` specific colors
|
48
|
+
- Add support for Codebuild CI
|
49
|
+
|
50
|
+
### `0.2.8`
|
51
|
+
- Remove `colorize` dependency
|
52
|
+
|
53
|
+
### `0.2.7`
|
54
|
+
- Fix for enterprise users unable to upload using the v4 uploader
|
55
|
+
|
56
|
+
### `0.2.6`
|
57
|
+
- Fix issue with `push` events on GitHub Actions
|
58
|
+
|
59
|
+
### `0.2.5`
|
60
|
+
- Revert single use of VERSION
|
61
|
+
|
62
|
+
### `0.2.4`
|
63
|
+
- Adds support for GitHub Actions CI
|
64
|
+
|
65
|
+
### `0.2.3`
|
66
|
+
- Support uploads for jruby 9.1 and 9.2
|
67
|
+
|
68
|
+
### `0.2.2`
|
69
|
+
- Handle SocketError and better error handling of v4 failures
|
70
|
+
|
71
|
+
### `0.2.1`
|
72
|
+
- Properly handle 400 cases when using the v4 endpoint
|
73
|
+
|
74
|
+
### `0.2.0`
|
75
|
+
- move to the v4 upload endpoint with the v2 as a fallback
|
76
|
+
|
77
|
+
### `0.1.20`
|
78
|
+
- fix critical upload issues on V2 endpoint
|
79
|
+
|
80
|
+
### `0.1.19`
|
81
|
+
- fix colorize
|
82
|
+
|
83
|
+
### `0.1.18`
|
84
|
+
- refactor and move to use v2 endpoint
|
85
|
+
- use Timeout::Error
|
86
|
+
|
87
|
+
### `0.1.17`
|
88
|
+
- refactor upload method and add more logging
|
89
|
+
|
90
|
+
### `0.1.10`
|
91
|
+
- update numerous ci environments
|
92
|
+
- dont fail if cannot upload to codecov
|
93
|
+
|
94
|
+
### `0.1.3`
|
95
|
+
- add buildkite
|
96
|
+
|
97
|
+
### `0.1.2`
|
98
|
+
- add slug argument
|
99
|
+
- use slug for uploading
|
100
|
+
- add Accept to uploads
|
101
|
+
|
102
|
+
### `0.1.1`
|
103
|
+
- fix #6, thanks @justmatt
|
104
|
+
- add semaphore thread number
|
105
|
+
|
106
|
+
### `0.1.0`
|
107
|
+
- added more CircleCI env
|
108
|
+
|
109
|
+
### `0.0.11`
|
110
|
+
- send AppVeyor pr# with reports
|
111
|
+
|
112
|
+
### `0.0.10`
|
113
|
+
- fix AppVeyor for public repos
|
114
|
+
|
115
|
+
### `0.0.9`
|
116
|
+
- remove tmp.json creation
|
117
|
+
|
118
|
+
### `0.0.8`
|
119
|
+
- added more jenkins environment references
|
120
|
+
|
121
|
+
### `0.0.7`
|
122
|
+
- added GitLab CI Runner support
|
123
|
+
|
124
|
+
### `0.0.5`
|
125
|
+
- added line messages by @coderanger
|
126
|
+
- fixed skip lines during reporting by @coderanger
|
127
|
+
|
128
|
+
### `0.0.4`
|
129
|
+
- added more test
|
130
|
+
- added more CI providers
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Codecov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# Codecov Ruby Uploader
|
2
|
+
|
3
|
+
## DEPRECATION WARNING
|
4
|
+
|
5
|
+
All versions of the Ruby uploader prior to `0.2.0` will no longer be supported
|
6
|
+
and will be removed from public use on or after *2020-08-17*.
|
7
|
+
Please upgrade to the latest versions to continue using this uploader.
|
8
|
+
|
9
|
+
[](https://codecov.io/github/codecov/codecov-ruby?branch=master)
|
10
|
+
[](https://rubygems.org/gems/codecov)
|
11
|
+
[](http://travis-ci.org/codecov/codecov-ruby)
|
12
|
+
[](https://circleci.com/gh/codecov/codecov-ruby)
|
13
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-ruby?ref=badge_shield)
|
14
|
+
|
15
|
+
|
16
|
+
[Codecov.io](https://codecov.io/) upload support for Ruby.
|
17
|
+
|
18
|
+
## Quick Start
|
19
|
+
|
20
|
+
Add to your `Gemfile`:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'codecov', require: false, group: 'test'
|
24
|
+
```
|
25
|
+
|
26
|
+
Add to the top of your `tests/helper.rb` file:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'simplecov'
|
30
|
+
SimpleCov.start
|
31
|
+
|
32
|
+
require 'codecov'
|
33
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
34
|
+
```
|
35
|
+
|
36
|
+
Add CI Environment Variable:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
CODECOV_TOKEN="your repo token"
|
40
|
+
```
|
41
|
+
|
42
|
+
Find you repo token on your repo page at [codecov.io](https://codecov.io).
|
43
|
+
Repo tokens are **not** required for public repos on Travis-Ci, CircleCI, or AppVeyor CI.
|
44
|
+
|
45
|
+
## Supported CIs
|
46
|
+
| CI/CD |
|
47
|
+
| ----- |
|
48
|
+
| [AppVeyor CI](https://www.appveyor.com/) |
|
49
|
+
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) |
|
50
|
+
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) |
|
51
|
+
| [Bitrise CI](https://www.bitrise.io/) |
|
52
|
+
| [Buildkite CI](https://buildkite.com/) |
|
53
|
+
| [CodeBuild CI](https://aws.amazon.com/codebuild/) |
|
54
|
+
| [CodePipeline](https://aws.amazon.com/codepipeline/) |
|
55
|
+
| [Circle CI](https://circleci.com/) |
|
56
|
+
| [Codeship CI](https://codeship.com/) |
|
57
|
+
| [Drone CI](https://drone.io/) |
|
58
|
+
| [GitLab CI](https://docs.gitlab.com/ee/ci/) |
|
59
|
+
| [Heroku CI](https://www.heroku.com/continuous-integration) |
|
60
|
+
| [Jenkins CI](https://www.jenkins.io/) |
|
61
|
+
| [Semaphore CI](https://semaphoreci.com/) |
|
62
|
+
| [Shippable](https://www.shippable.com/) |
|
63
|
+
| [Solano CI](https://xebialabs.com/technology/solano-ci/) |
|
64
|
+
| [TeamCity CI](https://www.jetbrains.com/teamcity/) |
|
65
|
+
| [Travis CI](https://travis-ci.org/) |
|
66
|
+
| [Wercker CI](https://devcenter.wercker.com/) |
|
67
|
+
|
68
|
+
## Advanced Usage
|
69
|
+
|
70
|
+
#### Submit only in CI example
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
if ENV['CI'] == 'true'
|
74
|
+
require 'codecov'
|
75
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
## Useful Links
|
80
|
+
|
81
|
+
[FAQ](https://docs.codecov.io/docs/frequently-asked-questions)
|
82
|
+
[Recipe List](https://docs.codecov.io/docs/common-recipe-list)
|
83
|
+
[Error Reference](https://docs.codecov.io/docs/error-reference)
|
84
|
+
[Changelog](./CHANGELOG.md)
|
85
|
+
[Support](https://codecov.io/support)
|
86
|
+
[Community Boards](https://community.codecov.io)
|
87
|
+
|
88
|
+
## Caveats
|
89
|
+
|
90
|
+
1. There are known issues when `Simplecov.track_files` is enabled. We recommend that you require all code files in your tests so that SimpleCov can provide Codecov with properly mapped coverage report metrics. [codecov/support#133]( https://github.com/codecov/support/issues/133)
|
91
|
+
- https://github.com/colszowka/simplecov/blob/master/README.md#default-root-filter-and-coverage-for-things-outside-of-it
|
92
|
+
2. `git` must be installed.
|
93
|
+
- https://github.com/codecov/codecov-ruby/blob/5e3dae3/lib/codecov.rb#L284-L295
|
94
|
+
|
95
|
+
## Maintainers
|
96
|
+
|
97
|
+
- [thomasrockhu](https://github.com/thomasrockhu)
|
98
|
+
|
99
|
+
## Enterprise
|
100
|
+
|
101
|
+
For companies using Codecov Enterprise you will need to specify the following parameters:
|
102
|
+
|
103
|
+
```sh
|
104
|
+
CODECOV_URL="https://codecov.mycompany.com"
|
105
|
+
CODECOV_SLUG="owner/repo"
|
106
|
+
CODECOV_TOKEN="repository token or global token"
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
## License
|
111
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fcodecov-ruby?ref=badge_large)
|
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,123 @@ 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
|
-
|
16
|
-
|
17
|
-
|
18
|
+
result.update(result_to_codecov(report))
|
19
|
+
|
20
|
+
begin
|
21
|
+
result_path = File.join(::SimpleCov.coverage_path, RESULT_FILE_NAME)
|
22
|
+
File.write(result_path, result['codecov'])
|
23
|
+
overflow = result['coverage'].to_s.length > 256 ? '...' : ''
|
24
|
+
puts "Coverage report generated to #{result_path}.\n#{result['coverage'].to_s.[](0, 255)}#{overflow}"
|
25
|
+
rescue Errno::ENOENT => e
|
26
|
+
puts e
|
27
|
+
puts "Could not write coverage report to file.\n#{result}"
|
28
|
+
end
|
18
29
|
|
19
|
-
|
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
|
30
|
+
result
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
# Format SimpleCov coverage data for the Codecov.io API.
|
36
|
+
#
|
37
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
38
|
+
# @return [Hash]
|
39
|
+
def result_to_codecov(result)
|
40
|
+
{
|
41
|
+
'codecov' => result_to_codecov_report(result),
|
42
|
+
'coverage' => result_to_codecov_coverage(result),
|
43
|
+
'messages' => result_to_codecov_messages(result)
|
44
|
+
}
|
45
|
+
end
|
37
46
|
|
38
|
-
|
39
|
-
|
40
|
-
|
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)
|
59
|
-
end
|
47
|
+
def result_to_codecov_report(result)
|
48
|
+
report = file_network.join("\n").concat("\n")
|
49
|
+
report.concat({ 'coverage' => result_to_codecov_coverage(result) }.to_json)
|
60
50
|
end
|
61
51
|
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
def file_network
|
53
|
+
invalid_file_types = [
|
54
|
+
'woff', 'eot', 'otf', # fonts
|
55
|
+
'gif', 'png', 'jpg', 'jpeg', 'psd', # images
|
56
|
+
'ptt', 'pptx', 'numbers', 'pages', 'md', 'txt', 'xlsx', 'docx', 'doc', 'pdf', 'csv', # docs
|
57
|
+
'yml', 'yaml', '.gitignore'
|
58
|
+
].freeze
|
59
|
+
|
60
|
+
invalid_directories = [
|
61
|
+
'node_modules/',
|
62
|
+
'public/',
|
63
|
+
'storage/',
|
64
|
+
'tmp/',
|
65
|
+
'vendor/'
|
66
|
+
]
|
67
|
+
|
68
|
+
network = []
|
69
|
+
Dir['**/*'].keep_if do |file|
|
70
|
+
if File.file?(file) && !file.end_with?(*invalid_file_types) && invalid_directories.none? { |dir| file.include?(dir) }
|
71
|
+
network.push(file)
|
72
|
+
end
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
|
68
|
-
# @param result [SimpleCov::Result] The coverage data to process.
|
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)
|
75
|
+
network.push('<<<<<< network')
|
76
|
+
network
|
73
77
|
end
|
74
|
-
end
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
lines_memo[line.line_number.to_s] = 'skipped' if line.skipped?
|
79
|
+
# Format SimpleCov coverage data for the Codecov.io coverage API.
|
80
|
+
#
|
81
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
82
|
+
# @return [Hash<String, Array>]
|
83
|
+
def result_to_codecov_coverage(result)
|
84
|
+
result.files.each_with_object({}) do |file, memo|
|
85
|
+
memo[shortened_filename(file)] = file_to_codecov(file)
|
84
86
|
end
|
85
87
|
end
|
86
|
-
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
else
|
98
|
-
line.coverage
|
89
|
+
# Format SimpleCov coverage data for the Codecov.io messages API.
|
90
|
+
#
|
91
|
+
# @param result [SimpleCov::Result] The coverage data to process.
|
92
|
+
# @return [Hash<String, Hash>]
|
93
|
+
def result_to_codecov_messages(result)
|
94
|
+
result.files.each_with_object({}) do |file, memo|
|
95
|
+
memo[shortened_filename(file)] = file.lines.each_with_object({}) do |line, lines_memo|
|
96
|
+
lines_memo[line.line_number.to_s] = 'skipped' if line.skipped?
|
97
|
+
end
|
99
98
|
end
|
100
99
|
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Get a filename relative to the project root. Based on
|
104
|
-
# https://github.com/colszowka/simplecov-html, copyright Christoph Olszowka.
|
105
|
-
#
|
106
|
-
# @param file [SimpleCov::SourceFile] The file to use.
|
107
|
-
# @return [String]
|
108
|
-
def self.shortened_filename(file)
|
109
|
-
file.filename.gsub(/^#{SimpleCov.root}/, '.').gsub(%r{^\./}, '')
|
110
|
-
end
|
111
|
-
|
112
|
-
# Convenience color methods
|
113
|
-
def self.black(str)
|
114
|
-
str.nil? ? '' : "\e[30m#{str}\e[0m"
|
115
|
-
end
|
116
100
|
|
117
|
-
|
118
|
-
|
119
|
-
|
101
|
+
# Format coverage data for a single file for the Codecov.io API.
|
102
|
+
#
|
103
|
+
# @param file [SimpleCov::SourceFile] The file to process.
|
104
|
+
# @return [Array<nil, Integer>]
|
105
|
+
def file_to_codecov(file)
|
106
|
+
# Initial nil is required to offset line numbers.
|
107
|
+
[nil] + file.lines.map do |line|
|
108
|
+
if line.skipped?
|
109
|
+
nil
|
110
|
+
else
|
111
|
+
line.coverage
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
120
115
|
|
121
|
-
|
122
|
-
|
116
|
+
# Get a filename relative to the project root. Based on
|
117
|
+
# https://github.com/colszowka/simplecov-html, copyright Christoph Olszowka.
|
118
|
+
#
|
119
|
+
# @param file [SimpleCov::SourceFile] The file to use.
|
120
|
+
# @return [String]
|
121
|
+
def shortened_filename(file)
|
122
|
+
file.filename.gsub(/^#{::SimpleCov.root}/, '.').gsub(%r{^\./}, '')
|
123
|
+
end
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
data/lib/codecov/uploader.rb
CHANGED
@@ -37,7 +37,17 @@ class Codecov::Uploader
|
|
37
37
|
|
38
38
|
display_header
|
39
39
|
ci = detect_ci
|
40
|
-
|
40
|
+
|
41
|
+
begin
|
42
|
+
response = upload_to_codecov(ci, report)
|
43
|
+
rescue StandardError => e
|
44
|
+
puts `#{e.message}`
|
45
|
+
puts `#{e.backtrace.join("\n")}`
|
46
|
+
raise e unless ::Codecov.pass_ci_if_error
|
47
|
+
|
48
|
+
response = false
|
49
|
+
end
|
50
|
+
|
41
51
|
if response == false
|
42
52
|
report['result'] = { 'uploaded' => false }
|
43
53
|
return report
|
@@ -180,16 +190,29 @@ class Codecov::Uploader
|
|
180
190
|
params[:commit] = ENV['CIRCLE_SHA1']
|
181
191
|
when CODEBUILD
|
182
192
|
# https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
193
|
+
# To use CodePipeline as CodeBuild source which sets no branch and slug variable:
|
194
|
+
#
|
195
|
+
# 1. Set up CodeStarSourceConnection as source action provider
|
196
|
+
# https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodestarConnectionSource.html
|
197
|
+
# 2. Add a Namespace to your source action. Example: "CodeStar".
|
198
|
+
# https://docs.aws.amazon.com/codepipeline/latest/userguide/reference-variables.html#reference-variables-concepts-namespaces
|
199
|
+
# 3. Add these environment variables to your CodeBuild action:
|
200
|
+
# - CODESTAR_BRANCH_NAME: #{CodeStar.BranchName}
|
201
|
+
# - CODESTAR_FULL_REPOSITORY_NAME: #{CodeStar.FullRepositoryName} (optional)
|
202
|
+
# https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-CodeBuild.html#action-reference-CodeBuild-config
|
203
|
+
#
|
204
|
+
# PRs are not supported with CodePipeline.
|
183
205
|
params[:service] = 'codebuild'
|
184
|
-
params[:branch] = ENV['CODEBUILD_WEBHOOK_HEAD_REF']
|
206
|
+
params[:branch] = ENV['CODEBUILD_WEBHOOK_HEAD_REF']&.split('/')&.[](2) || ENV['CODESTAR_BRANCH_NAME']
|
185
207
|
params[:build] = ENV['CODEBUILD_BUILD_ID']
|
186
208
|
params[:commit] = ENV['CODEBUILD_RESOLVED_SOURCE_VERSION']
|
187
209
|
params[:job] = ENV['CODEBUILD_BUILD_ID']
|
188
|
-
params[:slug] = ENV['CODEBUILD_SOURCE_REPO_URL']
|
189
|
-
params[:pr] = if ENV['CODEBUILD_SOURCE_VERSION']
|
210
|
+
params[:slug] = ENV['CODEBUILD_SOURCE_REPO_URL']&.match(/.*github.com\/(?<slug>.*).git/)&.[]('slug') || ENV['CODESTAR_FULL_REPOSITORY_NAME']
|
211
|
+
params[:pr] = if ENV['CODEBUILD_SOURCE_VERSION'] && !(ENV['CODEBUILD_INITIATOR'] =~ /codepipeline/)
|
190
212
|
matched = ENV['CODEBUILD_SOURCE_VERSION'].match(%r{pr/(?<pr>.*)})
|
191
213
|
matched.nil? ? ENV['CODEBUILD_SOURCE_VERSION'] : matched['pr']
|
192
214
|
end
|
215
|
+
params[:build_url] = ENV['CODEBUILD_BUILD_URL']
|
193
216
|
when CODESHIP
|
194
217
|
# https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
|
195
218
|
params[:service] = 'codeship'
|
@@ -521,3 +544,6 @@ class Codecov::Uploader
|
|
521
544
|
str.nil? ? '' : "\e[32m#{str}\e[0m"
|
522
545
|
end
|
523
546
|
end
|
547
|
+
|
548
|
+
require_relative 'configuration'
|
549
|
+
Codecov.extend Codecov::Configuration
|
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
|
+
version: 0.5.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-
|
12
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simplecov
|
@@ -122,14 +122,23 @@ executables: []
|
|
122
122
|
extensions: []
|
123
123
|
extra_rdoc_files: []
|
124
124
|
files:
|
125
|
+
- CHANGELOG.md
|
126
|
+
- LICENSE
|
127
|
+
- README.md
|
125
128
|
- lib/codecov.rb
|
129
|
+
- lib/codecov/configuration.rb
|
126
130
|
- lib/codecov/formatter.rb
|
127
131
|
- lib/codecov/uploader.rb
|
128
132
|
- lib/codecov/version.rb
|
129
133
|
homepage: https://github.com/codecov/codecov-ruby
|
130
134
|
licenses:
|
131
135
|
- MIT
|
132
|
-
metadata:
|
136
|
+
metadata:
|
137
|
+
bug_tracker_uri: https://github.com/codecov/codecov-ruby/issues
|
138
|
+
changelog_uri: https://github.com/codecov/codecov-ruby/blob/v0.5.1/CHANGELOG.md
|
139
|
+
documentation_uri: http://www.rubydoc.info/gems/codecov/0.5.1
|
140
|
+
homepage_uri: https://github.com/codecov/codecov-ruby
|
141
|
+
source_code_uri: https://github.com/codecov/codecov-ruby
|
133
142
|
post_install_message:
|
134
143
|
rdoc_options: []
|
135
144
|
require_paths:
|