codecov 0.2.0 → 0.2.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 +11 -3
- data/test/test_codecov.rb +17 -2
- 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: c8a7910be87b931e578ca118951e56d194e4eacce5bae5c43f00008ee5da7ba6
|
4
|
+
data.tar.gz: 10ebc17802361f6940bbec66dd8bf0407af083b0eaeccad17c480e72a587b79f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbb1f88c22749834ca20f87869a8d189fb0ac592a1b2a5507c69d7177376850085caaf0f414cfbb778af8e9c9002fa2e6c4994be59fdc5fb42a3b39149ccf9d
|
7
|
+
data.tar.gz: e02d2cda3d6bcc3e5d26391b49a737b31ea992679444dfbc53633eb999574929e2d7e67d2f180c7200daa00a7c6b9f8e94e5c6c80da2c94440748dd81b734a1b
|
data/lib/codecov.rb
CHANGED
@@ -8,7 +8,7 @@ require 'colorize'
|
|
8
8
|
require 'zlib'
|
9
9
|
|
10
10
|
class SimpleCov::Formatter::Codecov
|
11
|
-
VERSION = '0.2.
|
11
|
+
VERSION = '0.2.1'
|
12
12
|
|
13
13
|
### CIs
|
14
14
|
RECOGNIZED_CIS = [
|
@@ -340,6 +340,8 @@ class SimpleCov::Formatter::Codecov
|
|
340
340
|
puts " query: #{query_without_token}"
|
341
341
|
|
342
342
|
response = upload_to_v4(url, gzipped_report, query, query_without_token)
|
343
|
+
return false if response == false
|
344
|
+
|
343
345
|
response || upload_to_v2(url, gzipped_report, query, query_without_token)
|
344
346
|
end
|
345
347
|
|
@@ -360,8 +362,10 @@ class SimpleCov::Formatter::Codecov
|
|
360
362
|
}
|
361
363
|
)
|
362
364
|
response = retry_request(req, https)
|
363
|
-
|
364
|
-
|
365
|
+
if response.code == '400'
|
366
|
+
puts response.body.red
|
367
|
+
return false
|
368
|
+
end
|
365
369
|
|
366
370
|
reports_url = response.body.lines[0]
|
367
371
|
s3target = response.body.lines[1]
|
@@ -432,6 +436,10 @@ class SimpleCov::Formatter::Codecov
|
|
432
436
|
ci = detect_ci
|
433
437
|
report = create_report(result)
|
434
438
|
response = upload_to_codecov(ci, report)
|
439
|
+
if response == false
|
440
|
+
report['result'] = { 'uploaded' => false }
|
441
|
+
return report
|
442
|
+
end
|
435
443
|
|
436
444
|
report['result'] = JSON.parse(response)
|
437
445
|
handle_report_response(report)
|
data/test/test_codecov.rb
CHANGED
@@ -32,7 +32,7 @@ class TestCodecov < Minitest::Test
|
|
32
32
|
stub('SimpleCov::SourceFile', filename: filename, lines: lines)
|
33
33
|
end
|
34
34
|
|
35
|
-
def upload
|
35
|
+
def upload(success=true)
|
36
36
|
formatter = SimpleCov::Formatter::Codecov.new
|
37
37
|
result = stub('SimpleCov::Result', files: [
|
38
38
|
stub_file('/path/lib/something.rb', [1, 0, 0, nil, 1, nil]),
|
@@ -42,6 +42,13 @@ class TestCodecov < Minitest::Test
|
|
42
42
|
data = formatter.format(result)
|
43
43
|
puts data
|
44
44
|
puts data['params']
|
45
|
+
if success
|
46
|
+
assert_successful_upload(data)
|
47
|
+
end
|
48
|
+
data
|
49
|
+
end
|
50
|
+
|
51
|
+
def assert_successful_upload(data)
|
45
52
|
assert_equal(data['result']['uploaded'], true)
|
46
53
|
assert_equal(data['result']['message'], 'Coverage reports upload successfully')
|
47
54
|
assert_equal(data['meta']['version'], 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION)
|
@@ -49,7 +56,6 @@ class TestCodecov < Minitest::Test
|
|
49
56
|
'lib/something.rb' => [nil, 1, 0, 0, nil, 1, nil],
|
50
57
|
'lib/somefile.rb' => [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil]
|
51
58
|
}.to_json)
|
52
|
-
data
|
53
59
|
end
|
54
60
|
|
55
61
|
def setup
|
@@ -513,4 +519,13 @@ class TestCodecov < Minitest::Test
|
|
513
519
|
'path/lib/path_somefile.rb' => [nil]
|
514
520
|
}.to_json)
|
515
521
|
end
|
522
|
+
|
523
|
+
def test_invalid_token
|
524
|
+
ENV['CODECOV_TOKEN'] = 'fake'
|
525
|
+
result = upload(false)
|
526
|
+
assert_equal(false, result['result']['uploaded'])
|
527
|
+
branch = `git rev-parse --abbrev-ref HEAD`.strip
|
528
|
+
assert_equal(branch != 'HEAD' ? branch : 'master', result['params'][:branch])
|
529
|
+
assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
|
530
|
+
end
|
516
531
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codecov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- codecov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|