codecov 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/codecov.rb +11 -3
  3. data/test/test_codecov.rb +17 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be241629e51b22f3694227f087f7b2737cb89906a82c1a6c34e8f385d7e8694f
4
- data.tar.gz: 9a9631626638e3211e652fa99b493a64b4bad0264b1369ac107f2addd843571d
3
+ metadata.gz: c8a7910be87b931e578ca118951e56d194e4eacce5bae5c43f00008ee5da7ba6
4
+ data.tar.gz: 10ebc17802361f6940bbec66dd8bf0407af083b0eaeccad17c480e72a587b79f
5
5
  SHA512:
6
- metadata.gz: 6b7891248226a1cabf8e4972b252a464b4f58ebfa6ef61a7db796c3ae32b4fc2a6501e7d257a3e1b4ee2bff695cbb735c85a97a2d61a01602d8c5e0e00c0cd46
7
- data.tar.gz: 855d2d29ef145f69e741b95264c53d3cebb6a05618c0b5c5a1184a0f8b6d7839486eb399dfe87c12c5149888c6572ac7c2187aa12de86b8e35e8be5de3e9c170
6
+ metadata.gz: bcbb1f88c22749834ca20f87869a8d189fb0ac592a1b2a5507c69d7177376850085caaf0f414cfbb778af8e9c9002fa2e6c4994be59fdc5fb42a3b39149ccf9d
7
+ data.tar.gz: e02d2cda3d6bcc3e5d26391b49a737b31ea992679444dfbc53633eb999574929e2d7e67d2f180c7200daa00a7c6b9f8e94e5c6c80da2c94440748dd81b734a1b
@@ -8,7 +8,7 @@ require 'colorize'
8
8
  require 'zlib'
9
9
 
10
10
  class SimpleCov::Formatter::Codecov
11
- VERSION = '0.2.0'
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
- return unless response.code == '200'
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)
@@ -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.0
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-10 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize