codecov 0.1.21 → 0.2.0

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 +16 -76
  3. data/test/test_codecov.rb +18 -177
  4. metadata +8 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e9408049c526c9e3733a4b4431fb8f5f479db5a6d70ac769655c178690b878c
4
- data.tar.gz: 7f73f2059b9b0f1e8f5549e955f8482532ef34c8505114f068ba689042d6ada9
3
+ metadata.gz: be241629e51b22f3694227f087f7b2737cb89906a82c1a6c34e8f385d7e8694f
4
+ data.tar.gz: 9a9631626638e3211e652fa99b493a64b4bad0264b1369ac107f2addd843571d
5
5
  SHA512:
6
- metadata.gz: 0332e23b36a550b36f86dab1d9915c616dca2a119735616486ac4829ad88ad05c46721de6bfea2c400b3f735b26167587acda24db84397842bf9328616fe2997
7
- data.tar.gz: e9d9b9ecd83b6c4037d6ca15964184fbe9745e93f33f0b7a17aa0e4d032d13353ffb1893288240c9c004b353e97623f2d88e4e5b3371b507050a8f9273eb5a68
6
+ metadata.gz: 6b7891248226a1cabf8e4972b252a464b4f58ebfa6ef61a7db796c3ae32b4fc2a6501e7d257a3e1b4ee2bff695cbb735c85a97a2d61a01602d8c5e0e00c0cd46
7
+ data.tar.gz: 855d2d29ef145f69e741b95264c53d3cebb6a05618c0b5c5a1184a0f8b6d7839486eb399dfe87c12c5149888c6572ac7c2187aa12de86b8e35e8be5de3e9c170
@@ -4,10 +4,11 @@ require 'uri'
4
4
  require 'json'
5
5
  require 'net/http'
6
6
  require 'simplecov'
7
+ require 'colorize'
7
8
  require 'zlib'
8
9
 
9
10
  class SimpleCov::Formatter::Codecov
10
- VERSION = '0.1.21'
11
+ VERSION = '0.2.0'
11
12
 
12
13
  ### CIs
13
14
  RECOGNIZED_CIS = [
@@ -17,10 +18,8 @@ class SimpleCov::Formatter::Codecov
17
18
  BITRISE = 'Bitrise CI',
18
19
  BUILDKITE = 'Buildkite CI',
19
20
  CIRCLE = 'Circle CI',
20
- CODEBUILD = 'Codebuild CI',
21
21
  CODESHIP = 'Codeship CI',
22
22
  DRONEIO = 'Drone CI',
23
- GITHUB = 'GitHub Actions',
24
23
  GITLAB = 'GitLab CI',
25
24
  HEROKU = 'Heroku CI',
26
25
  JENKINS = 'Jenkins CI',
@@ -59,14 +58,10 @@ class SimpleCov::Formatter::Codecov
59
58
  BUILDKITE
60
59
  elsif (ENV['CI'] == 'true') && (ENV['CIRCLECI'] == 'true')
61
60
  CIRCLE
62
- elsif ENV['CODEBUILD_CI'] == 'true'
63
- CODEBUILD
64
61
  elsif (ENV['CI'] == 'true') && (ENV['CI_NAME'] == 'codeship')
65
62
  CODESHIP
66
63
  elsif ((ENV['CI'] == 'true') || (ENV['CI'] == 'drone')) && (ENV['DRONE'] == 'true')
67
64
  DRONEIO
68
- elsif (ENV['CI'] == 'true') && (ENV['GITHUB_ACTIONS'] == 'true')
69
- GITHUB
70
65
  elsif !ENV['GITLAB_CI'].nil?
71
66
  GITLAB
72
67
  elsif ENV['HEROKU_TEST_RUN_ID']
@@ -160,15 +155,6 @@ class SimpleCov::Formatter::Codecov
160
155
  params[:pr] = ENV['CIRCLE_PR_NUMBER']
161
156
  params[:branch] = ENV['CIRCLE_BRANCH']
162
157
  params[:commit] = ENV['CIRCLE_SHA1']
163
- when CODEBUILD
164
- # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
165
- params[:service] = 'codebuild'
166
- params[:branch] = ENV['CODEBUILD_WEBHOOK_HEAD_REF'].split('/')[2]
167
- params[:build] = ENV['CODEBUILD_BUILD_ID']
168
- params[:commit] = ENV['CODEBUILD_RESOLVED_SOURCE_VERSION']
169
- params[:job] = ENV['CODEBUILD_BUILD_ID']
170
- params[:slug] = ENV['CODEBUILD_SOURCE_REPO_URL'].match(/.*github.com\/(?<slug>.*).git/)['slug']
171
- params[:pr] = ENV['CODEBUILD_SOURCE_VERSION'].match(/pr\/(?<pr>.*)/)['pr'] if ENV['CODEBUILD_SOURCE_VERSION']
172
158
  when CODESHIP
173
159
  # https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
174
160
  params[:service] = 'codeship'
@@ -186,15 +172,6 @@ class SimpleCov::Formatter::Codecov
186
172
  params[:build_url] = ENV['DRONE_BUILD_LINK'] || ENV['DRONE_BUILD_URL'] || ENV['CI_BUILD_URL']
187
173
  params[:pr] = ENV['DRONE_PULL_REQUEST']
188
174
  params[:tag] = ENV['DRONE_TAG']
189
- when GITHUB
190
- # https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
191
- params[:service] = 'github-actions'
192
- params[:branch] = ENV['GITHUB_HEAD_REF'] || ENV['GITHUB_REF'].sub('refs/head/', '')
193
- # PR refs are in the format: refs/pull/7/merge for pull_request events
194
- params[:pr] = ENV['GITHUB_REF'].split('/')[2] unless ENV['GITHUB_HEAD_REF'].nil? || ENV['GITHUB_HEAD_REF'].empty?
195
- params[:slug] = ENV['GITHUB_REPOSITORY']
196
- params[:build] = ENV['GITHUB_RUN_ID']
197
- params[:commit] = ENV['GITHUB_SHA']
198
175
  when GITLAB
199
176
  # http://doc.gitlab.com/ci/examples/README.html#environmental-variables
200
177
  # https://gitlab.com/gitlab-org/gitlab-ci-runner/blob/master/lib/build.rb#L96
@@ -303,21 +280,20 @@ class SimpleCov::Formatter::Codecov
303
280
  retries = 3
304
281
  begin
305
282
  response = https.request(req)
306
- rescue Timeout::Error, SocketError => e
283
+ rescue Timeout::Error => e
307
284
  retries -= 1
308
285
 
309
286
  if retries.zero?
310
- puts 'Timeout or connection error uploading coverage reports to Codecov. Out of retries.'
287
+ puts 'Timeout error uploading coverage reports to Codecov. Out of retries.'
311
288
  puts e
312
289
  return response
313
290
  end
314
291
 
315
- puts 'Timeout or connection error uploading coverage reports to Codecov. Retrying...'
292
+ puts 'Timeout error uploading coverage reports to Codecov. Retrying...'
316
293
  puts e
317
294
  retry
318
295
  rescue StandardError => e
319
296
  puts 'Error uploading coverage reports to Codecov. Sorry'
320
- puts e.class.name
321
297
  puts e
322
298
  return response
323
299
  end
@@ -328,7 +304,7 @@ class SimpleCov::Formatter::Codecov
328
304
  def create_report(report)
329
305
  result = {
330
306
  'meta' => {
331
- 'version' => 'codecov-ruby/v' + VERSION
307
+ 'version' => 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION
332
308
  }
333
309
  }
334
310
  result.update(result_to_codecov(report))
@@ -338,17 +314,14 @@ class SimpleCov::Formatter::Codecov
338
314
  def gzip_report(report)
339
315
  puts ['==>'.green, 'Gzipping contents'].join(' ')
340
316
 
341
- io = StringIO.new
342
- gzip = Zlib::GzipWriter.new(io)
317
+ gzip = Zlib::GzipWriter.new(StringIO.new)
343
318
  gzip << report
344
- gzip.close
345
319
 
346
- io.string
320
+ gzip.close.string
347
321
  end
348
322
 
349
323
  def upload_to_codecov(ci, report)
350
324
  url = ENV['CODECOV_URL'] || 'https://codecov.io'
351
- is_enterprise = url != 'https://codecov.io'
352
325
 
353
326
  params = build_params(ci)
354
327
  params_secret_token = params.clone
@@ -366,12 +339,7 @@ class SimpleCov::Formatter::Codecov
366
339
  puts " url: #{url}"
367
340
  puts " query: #{query_without_token}"
368
341
 
369
- response = false
370
- unless is_enterprise
371
- response = upload_to_v4(url, gzipped_report, query, query_without_token)
372
- return false if response == false
373
- end
374
-
342
+ response = upload_to_v4(url, gzipped_report, query, query_without_token)
375
343
  response || upload_to_v2(url, gzipped_report, query, query_without_token)
376
344
  end
377
345
 
@@ -381,7 +349,7 @@ class SimpleCov::Formatter::Codecov
381
349
  https.use_ssl = !url.match(/^https/).nil?
382
350
 
383
351
  puts ['-> '.green, 'Pinging Codecov'].join(' ')
384
- puts "#{url}#{uri.path}?#{query_without_token}"
352
+ puts "#{url}/#{uri.path}?#{query_without_token}"
385
353
 
386
354
  req = Net::HTTP::Post.new(
387
355
  "#{uri.path}?#{query}",
@@ -392,10 +360,8 @@ class SimpleCov::Formatter::Codecov
392
360
  }
393
361
  )
394
362
  response = retry_request(req, https)
395
- if !response&.code || response.code == '400'
396
- puts response&.body&.red
397
- return false
398
- end
363
+
364
+ return unless response.code == '200'
399
365
 
400
366
  reports_url = response.body.lines[0]
401
367
  s3target = response.body.lines[1]
@@ -436,12 +402,11 @@ class SimpleCov::Formatter::Codecov
436
402
  https.use_ssl = !url.match(/^https/).nil?
437
403
 
438
404
  puts ['-> '.green, 'Uploading to Codecov'].join(' ')
439
- puts "#{url}#{uri.path}?#{query_without_token}"
405
+ puts "#{url}/#{uri.path}?#{query_without_token}"
440
406
 
441
407
  req = Net::HTTP::Post.new(
442
408
  "#{uri.path}?#{query}",
443
409
  {
444
- 'Accept' => 'application/json',
445
410
  'Content-Encoding' => 'gzip',
446
411
  'Content-Type' => 'text/plain',
447
412
  'X-Content-Encoding' => 'gzip'
@@ -460,22 +425,17 @@ class SimpleCov::Formatter::Codecov
460
425
  end
461
426
  end
462
427
 
463
- def format(result, disable_net_blockers = true)
464
- net_blockers(:off) if disable_net_blockers
428
+ def format(result)
429
+ net_blockers(:off)
465
430
 
466
431
  display_header
467
432
  ci = detect_ci
468
433
  report = create_report(result)
469
434
  response = upload_to_codecov(ci, report)
470
- if response == false
471
- report['result'] = { 'uploaded' => false }
472
- return report
473
- end
474
435
 
475
436
  report['result'] = JSON.parse(response)
476
437
  handle_report_response(report)
477
-
478
- net_blockers(:on) if disable_net_blockers
438
+ net_blockers(:on)
479
439
  report
480
440
  end
481
441
 
@@ -598,23 +558,3 @@ class SimpleCov::Formatter::Codecov
598
558
  true
599
559
  end
600
560
  end
601
-
602
- # https://stackoverflow.com/a/11482430/5769383
603
- class String
604
- # colorization
605
- def colorize(color_code)
606
- "\e[#{color_code}m#{self}\e[0m"
607
- end
608
-
609
- def black
610
- colorize(30)
611
- end
612
-
613
- def red
614
- colorize(31)
615
- end
616
-
617
- def green
618
- colorize(32)
619
- end
620
- end
@@ -3,44 +3,14 @@
3
3
  require 'helper'
4
4
 
5
5
  class TestCodecov < Minitest::Test
6
- CI = SimpleCov::Formatter::Codecov.new.detect_ci
7
-
8
- REALENV =
9
- if CI == SimpleCov::Formatter::Codecov::CIRCLE
10
- {
11
- 'CIRCLECI' => ENV['CIRCLECI'],
12
- 'CIRCLE_BUILD_NUM' => ENV['CIRCLE_BUILD_NUM'],
13
- 'CIRCLE_NODE_INDEX' => ENV['CIRCLE_NODE_INDEX'],
14
- 'CIRCLE_PROJECT_REPONAME' => ENV['CIRCLE_PROJECT_REPONAME'],
15
- 'CIRCLE_PROJECT_USERNAME' => ENV['CIRCLE_PROJECT_USERNAME'],
16
- 'CIRCLE_REPOSITORY_URL' => ENV['CIRCLE_REPOSITORY_URL'],
17
- 'CIRCLE_PR_NUMBER' => ENV['CIRCLE_PR_NUMBER'],
18
- 'CIRCLE_BRANCH' => ENV['CIRCLE_BRANCH'],
19
- 'CIRCLE_SHA1' => ENV['CIRCLE_SHA1']
20
- }
21
- elsif CI == SimpleCov::Formatter::Codecov::GITHUB
22
- {
23
- 'GITHUB_ACTIONS' => ENV['GITHUB_ACTIONS'],
24
- 'GITHUB_HEAD_REF' => ENV['GITHUB_HEAD_REF'],
25
- 'GITHUB_REF' => ENV['GITHUB_REF'],
26
- 'GITHUB_REPOSITORY' => ENV['GITHUB_REPOSITORY'],
27
- 'GITHUB_RUN_ID' => ENV['GITHUB_RUN_ID'],
28
- 'GITHUB_SHA' => ENV['GITHUB_SHA']
29
- }
30
- elsif CI == SimpleCov::Formatter::Codecov::TRAVIS
31
- {
32
- 'TRAVIS' => ENV['TRAVIS'],
33
- 'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'],
34
- 'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'],
35
- 'TRAVIS_REPO_SLUG' => ENV['TRAVIS_REPO_SLUG'],
36
- 'TRAVIS_JOB_NUMBER' => ENV['TRAVIS_JOB_NUMBER'],
37
- 'TRAVIS_PULL_REQUEST' => ENV['TRAVIS_PULL_REQUEST'],
38
- 'TRAVIS_JOB_ID' => ENV['TRAVIS_JOB_ID']
39
- }
40
- else
41
- {}
42
- end.freeze
43
-
6
+ REALENV = {
7
+ 'TRAVIS_BRANCH' => ENV['TRAVIS_BRANCH'],
8
+ 'TRAVIS_COMMIT' => ENV['TRAVIS_COMMIT'],
9
+ 'TRAVIS_REPO_SLUG' => ENV['TRAVIS_REPO_SLUG'],
10
+ 'TRAVIS_JOB_NUMBER' => ENV['TRAVIS_JOB_NUMBER'],
11
+ 'TRAVIS_PULL_REQUEST' => ENV['TRAVIS_PULL_REQUEST'],
12
+ 'TRAVIS_JOB_ID' => ENV['TRAVIS_JOB_ID']
13
+ }.freeze
44
14
  def url
45
15
  ENV['CODECOV_URL'] || 'https://codecov.io'
46
16
  end
@@ -62,38 +32,16 @@ class TestCodecov < Minitest::Test
62
32
  stub('SimpleCov::SourceFile', filename: filename, lines: lines)
63
33
  end
64
34
 
65
- def upload(success = true)
66
- WebMock.enable!
35
+ def upload
67
36
  formatter = SimpleCov::Formatter::Codecov.new
68
37
  result = stub('SimpleCov::Result', files: [
69
38
  stub_file('/path/lib/something.rb', [1, 0, 0, nil, 1, nil]),
70
39
  stub_file('/path/lib/somefile.rb', [1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
71
40
  ])
72
41
  SimpleCov.stubs(:root).returns('/path')
73
- success_stubs if success
74
- data = formatter.format(result, false)
42
+ data = formatter.format(result)
75
43
  puts data
76
44
  puts data['params']
77
- assert_successful_upload(data) if success
78
- WebMock.reset!
79
- data
80
- end
81
-
82
- def success_stubs
83
- stub_request(:post, %r{https:\/\/codecov.io\/upload\/v4})
84
- .to_return(
85
- status: 200,
86
- body: "https://codecov.io/gh/fake\n" \
87
- 'https://storage.googleapis.com/codecov/fake'
88
- )
89
- stub_request(:put, %r{https:\/\/storage.googleapis.com\/})
90
- .to_return(
91
- status: 200,
92
- body: ''
93
- )
94
- end
95
-
96
- def assert_successful_upload(data)
97
45
  assert_equal(data['result']['uploaded'], true)
98
46
  assert_equal(data['result']['message'], 'Coverage reports upload successfully')
99
47
  assert_equal(data['meta']['version'], 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION)
@@ -101,12 +49,11 @@ class TestCodecov < Minitest::Test
101
49
  'lib/something.rb' => [nil, 1, 0, 0, nil, 1, nil],
102
50
  'lib/somefile.rb' => [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil]
103
51
  }.to_json)
52
+ data
104
53
  end
105
54
 
106
55
  def setup
107
56
  ENV['CI'] = nil
108
- ENV['CIRCLECI'] = nil
109
- ENV['GITHUB_ACTIONS'] = nil
110
57
  ENV['TRAVIS'] = nil
111
58
  end
112
59
 
@@ -167,12 +114,6 @@ class TestCodecov < Minitest::Test
167
114
  ENV['CIRCLE_PROJECT_USERNAME'] = nil
168
115
  ENV['CIRCLE_SHA1'] = nil
169
116
  ENV['CIRCLECI'] = nil
170
- ENV['CODEBUILD_CI'] = nil
171
- ENV['CODEBUILD_BUILD_ID'] = nil
172
- ENV['CODEBUILD_RESOLVED_SOURCE_VERSION'] = nil
173
- ENV['CODEBUILD_WEBHOOK_HEAD_REF'] = nil
174
- ENV['CODEBUILD_SOURCE_VERSION'] = nil
175
- ENV['CODEBUILD_SOURCE_REPO_URL'] = nil
176
117
  ENV['CODECOV_ENV'] = nil
177
118
  ENV['CODECOV_SLUG'] = nil
178
119
  ENV['CODECOV_TOKEN'] = nil
@@ -187,12 +128,6 @@ class TestCodecov < Minitest::Test
187
128
  ENV['ghprbSourceBranch'] = nil
188
129
  ENV['GIT_BRANCH'] = nil
189
130
  ENV['GIT_COMMIT'] = nil
190
- ENV['GITHUB_ACTIONS'] = nil
191
- ENV['GITHUB_REF'] = nil
192
- ENV['GITHUB_HEAD_REF'] = nil
193
- ENV['GITHUB_REPOSITORY'] = nil
194
- ENV['GITHUB_RUN_ID'] = nil
195
- ENV['GITHUB_SHA'] = nil
196
131
  ENV['GITLAB_CI'] = nil
197
132
  ENV['HEROKU_TEST_RUN_ID'] = nil
198
133
  ENV['HEROKU_TEST_RUN_BRANCH'] = nil
@@ -208,13 +143,13 @@ class TestCodecov < Minitest::Test
208
143
  ENV['SEMAPHORE_REPO_SLUG'] = nil
209
144
  ENV['SHIPPABLE'] = nil
210
145
  ENV['TF_BUILD'] = nil
211
- ENV['TRAVIS'] = nil
212
- ENV['TRAVIS_BRANCH'] = nil
213
- ENV['TRAVIS_COMMIT'] = nil
214
- ENV['TRAVIS_JOB_ID'] = nil
215
- ENV['TRAVIS_JOB_NUMBER'] = nil
216
- ENV['TRAVIS_PULL_REQUEST'] = nil
217
- ENV['TRAVIS_REPO_SLUG'] = nil
146
+ ENV['TRAVIS'] = 'true'
147
+ ENV['TRAVIS_BRANCH'] = REALENV['TRAVIS_BRANCH']
148
+ ENV['TRAVIS_COMMIT'] = REALENV['TRAVIS_COMMIT']
149
+ ENV['TRAVIS_JOB_ID'] = REALENV['TRAVIS_JOB_ID']
150
+ ENV['TRAVIS_JOB_NUMBER'] = REALENV['TRAVIS_JOB_NUMBER']
151
+ ENV['TRAVIS_PULL_REQUEST'] = REALENV['TRAVIS_PULL_REQUEST']
152
+ ENV['TRAVIS_REPO_SLUG'] = REALENV['TRAVIS_REPO_SLUG']
218
153
  ENV['VCS_COMMIT_ID'] = nil
219
154
  ENV['WERCKER_GIT_BRANCH'] = nil
220
155
  ENV['WERCKER_GIT_COMMIT'] = nil
@@ -222,8 +157,6 @@ class TestCodecov < Minitest::Test
222
157
  ENV['WERCKER_GIT_REPOSITORY'] = nil
223
158
  ENV['WERCKER_MAIN_PIPELINE_STARTED'] = nil
224
159
  ENV['WORKSPACE'] = nil
225
-
226
- REALENV.each_pair { |k, v| ENV[k] = v }
227
160
  end
228
161
 
229
162
  def test_git
@@ -235,23 +168,6 @@ class TestCodecov < Minitest::Test
235
168
  assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
236
169
  end
237
170
 
238
- def test_enterprise
239
- stub = stub_request(:post, %r{https:\/\/example.com\/upload\/v2})
240
- .to_return(
241
- status: 200,
242
- body: "{\"id\": \"12345678-1234-abcd-ef12-1234567890ab\", \"message\": \"Coverage reports upload successfully\", \"meta\": { \"status\": 200 }, \"queued\": true, \"uploaded\": true, \"url\": \"https://example.com/github/codecov/codecov-bash/commit/2f6b51562b93e72c610671644fe2a303c5c0e8e5\"}"
243
- )
244
-
245
- ENV['CODECOV_URL'] = 'https://example.com'
246
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
247
- result = upload
248
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
249
- assert_equal('12345678-1234-abcd-ef12-1234567890ab', result['result']['id'])
250
- branch = `git rev-parse --abbrev-ref HEAD`.strip
251
- assert_equal(branch != 'HEAD' ? branch : 'master', result['params'][:branch])
252
- assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
253
- end
254
-
255
171
  def test_travis
256
172
  ENV['CI'] = 'true'
257
173
  ENV['TRAVIS'] = 'true'
@@ -462,44 +378,6 @@ class TestCodecov < Minitest::Test
462
378
  assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
463
379
  end
464
380
 
465
- def test_github_pull_request
466
- ENV['CI'] = 'true'
467
- ENV['GITHUB_ACTIONS'] = 'true'
468
- ENV['GITHUB_HEAD_REF'] = 'patch-2'
469
- ENV['GITHUB_REF'] = 'refs/pull/7/merge'
470
- ENV['GITHUB_REPOSITORY'] = 'codecov/ci-repo'
471
- ENV['GITHUB_RUN_ID'] = '1'
472
- ENV['GITHUB_SHA'] = 'c739768fcac68144a3a6d82305b9c4106934d31a'
473
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
474
- result = upload
475
- assert_equal('github-actions', result['params'][:service])
476
- assert_equal('c739768fcac68144a3a6d82305b9c4106934d31a', result['params'][:commit])
477
- assert_equal('codecov/ci-repo', result['params'][:slug])
478
- assert_equal('1', result['params'][:build])
479
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
480
- assert_equal('patch-2', result['params'][:branch])
481
- assert_equal('7', result['params'][:pr])
482
- end
483
-
484
- def test_github_push
485
- ENV['CI'] = 'true'
486
- ENV['GITHUB_ACTIONS'] = 'true'
487
- ENV['GITHUB_HEAD_REF'] = nil
488
- ENV['GITHUB_REF'] = 'refs/head/master'
489
- ENV['GITHUB_REPOSITORY'] = 'codecov/ci-repo'
490
- ENV['GITHUB_RUN_ID'] = '1'
491
- ENV['GITHUB_SHA'] = 'c739768fcac68144a3a6d82305b9c4106934d31a'
492
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
493
- result = upload
494
- assert_equal('github-actions', result['params'][:service])
495
- assert_equal('c739768fcac68144a3a6d82305b9c4106934d31a', result['params'][:commit])
496
- assert_equal('codecov/ci-repo', result['params'][:slug])
497
- assert_equal('1', result['params'][:build])
498
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
499
- assert_equal('master', result['params'][:branch])
500
- assert_equal(false, result['params'].key?(:pr))
501
- end
502
-
503
381
  def test_gitlab
504
382
  ENV['GITLAB_CI'] = 'true'
505
383
  ENV['CI_BUILD_REF_NAME'] = 'master'
@@ -618,27 +496,6 @@ class TestCodecov < Minitest::Test
618
496
  assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
619
497
  end
620
498
 
621
- def test_codebuild
622
- ENV['CODEBUILD_CI'] = "true"
623
- ENV['CODEBUILD_BUILD_ID'] = "codebuild-project:458dq3q8-7354-4513-8702-ea7b9c81efb3"
624
- ENV['CODEBUILD_RESOLVED_SOURCE_VERSION'] = 'd653b934ed59c1a785cc1cc79d08c9aaa4eba73b'
625
- ENV['CODEBUILD_WEBHOOK_HEAD_REF'] = 'refs/heads/master'
626
- ENV['CODEBUILD_SOURCE_VERSION'] = 'pr/123'
627
- ENV['CODEBUILD_SOURCE_REPO_URL'] = 'https://github.com/owner/repo.git'
628
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
629
-
630
- result = upload
631
-
632
- assert_equal("codebuild", result['params'][:service])
633
- assert_equal("d653b934ed59c1a785cc1cc79d08c9aaa4eba73b", result['params'][:commit])
634
- assert_equal("codebuild-project:458dq3q8-7354-4513-8702-ea7b9c81efb3", result['params'][:build])
635
- assert_equal("codebuild-project:458dq3q8-7354-4513-8702-ea7b9c81efb3", result['params'][:job])
636
- assert_equal("owner/repo", result['params'][:slug])
637
- assert_equal("master", result['params'][:branch])
638
- assert_equal("123", result['params'][:pr])
639
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
640
- end
641
-
642
499
  def test_filenames_are_shortened_correctly
643
500
  ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
644
501
 
@@ -656,20 +513,4 @@ class TestCodecov < Minitest::Test
656
513
  'path/lib/path_somefile.rb' => [nil]
657
514
  }.to_json)
658
515
  end
659
-
660
- def test_invalid_token
661
- stub_request(:post, %r{https:\/\/codecov.io\/upload})
662
- .to_return(
663
- status: 400,
664
- body: "HTTP 400\n" \
665
- 'Provided token is not a UUID.'
666
- )
667
-
668
- ENV['CODECOV_TOKEN'] = 'fake'
669
- result = upload(false)
670
- assert_equal(false, result['result']['uploaded'])
671
- branch = `git rev-parse --abbrev-ref HEAD`.strip
672
- assert_equal(branch != 'HEAD' ? branch : 'master', result['params'][:branch])
673
- assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
674
- end
675
516
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - codecov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-26 00:00:00.000000000 Z
11
+ date: 2020-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: json
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: simplecov
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,13 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest-ci
56
+ name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: webmock
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
111
  description: hosted code coverage
126
112
  email:
127
113
  - hello@codecov.io
@@ -143,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
129
  requirements:
144
130
  - - ">="
145
131
  - !ruby/object:Gem::Version
146
- version: '2.4'
132
+ version: '0'
147
133
  required_rubygems_version: !ruby/object:Gem::Requirement
148
134
  requirements:
149
135
  - - ">="