codecov 0.2.10 → 0.2.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d552ab878cd45e8246a35a2535e30db5db427032fef0f50a2d65404b2f39592
4
- data.tar.gz: cf43553c8aad22ddff422a6e5ac33b2787234e3a2a6c8c6974dee9c4839dc9fb
3
+ metadata.gz: 85521bfddce47e0bea574c2ad37daac2f5ad37531ab7fb52fd17061f3a485bae
4
+ data.tar.gz: 16a6e6657c28a3575dbce4c8a55de32faff1ab1e0d60490943e952af4d14b54b
5
5
  SHA512:
6
- metadata.gz: de09d13c2647752336f5ef3a9cae4306d057e2244a39cb9adbd410072255463200a58efe223b23155164a19be08fb9f3a619a890098b06c355e76dcaefe766fa
7
- data.tar.gz: abba86de852c8f76df3ec4966cbf001337c389e46e84aef6604990c8af710c1c17f71d9561da5709c0535c9b9fc0f90d5e02037264cfc502b03489b751289c68
6
+ metadata.gz: 2924a697d2a0c0b51f157ddc4e8f5b7d235c886d20757fa27203f155316a090b66ceb156c1a1ddd55e9315b0ec87e6e9e68b134e8141c0859ff27d078e1bb13e
7
+ data.tar.gz: 4dd840917cefb25b835e9477af2969f9c698d772b2765ce4bd6efd4b82ae7152ae10dd7125483564bb753d509030da09f6607a789ccc6c7f76ea85a009a88e93
@@ -6,9 +6,9 @@ require 'net/http'
6
6
  require 'simplecov'
7
7
  require 'zlib'
8
8
 
9
- class SimpleCov::Formatter::Codecov
10
- VERSION = '0.2.10'
9
+ require_relative 'codecov/version'
11
10
 
11
+ class SimpleCov::Formatter::Codecov
12
12
  ### CIs
13
13
  RECOGNIZED_CIS = [
14
14
  APPVEYOR = 'Appveyor CI',
@@ -41,7 +41,7 @@ class SimpleCov::Formatter::Codecov
41
41
  '| | / _ \ / _\`|/ _ \/ __/ _ \ \ / /',
42
42
  '| |___| (_) | (_| | __/ (_| (_) \ V /',
43
43
  ' \_____\___/ \__,_|\___|\___\___/ \_/',
44
- " Ruby-#{VERSION}",
44
+ " Ruby-#{::Codecov::VERSION}",
45
45
  ''
46
46
  ].join("\n")
47
47
  end
@@ -100,7 +100,7 @@ class SimpleCov::Formatter::Codecov
100
100
  params = {
101
101
  'token' => ENV['CODECOV_TOKEN'],
102
102
  'flags' => ENV['CODECOV_FLAG'] || ENV['CODECOV_FLAGS'],
103
- 'package' => "ruby-#{VERSION}"
103
+ 'package' => "ruby-#{::Codecov::VERSION}"
104
104
  }
105
105
 
106
106
  case ci
@@ -168,7 +168,10 @@ class SimpleCov::Formatter::Codecov
168
168
  params[:commit] = ENV['CODEBUILD_RESOLVED_SOURCE_VERSION']
169
169
  params[:job] = ENV['CODEBUILD_BUILD_ID']
170
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']
171
+ params[:pr] = if ENV['CODEBUILD_SOURCE_VERSION']
172
+ matched = ENV['CODEBUILD_SOURCE_VERSION'].match(%r{pr/(?<pr>.*)})
173
+ matched.nil? ? ENV['CODEBUILD_SOURCE_VERSION'] : matched['pr']
174
+ end
172
175
  when CODESHIP
173
176
  # https://www.codeship.io/documentation/continuous-integration/set-environment-variables/
174
177
  params[:service] = 'codeship'
@@ -189,9 +192,13 @@ class SimpleCov::Formatter::Codecov
189
192
  when GITHUB
190
193
  # https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
191
194
  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
+ if (ENV['GITHUB_HEAD_REF'] || '').empty?
196
+ params[:branch] = ENV['GITHUB_REF'].sub('refs/heads/', '')
197
+ else
198
+ params[:branch] = ENV['GITHUB_HEAD_REF']
199
+ # PR refs are in the format: refs/pull/7/merge for pull_request events
200
+ params[:pr] = ENV['GITHUB_REF'].split('/')[2]
201
+ end
195
202
  params[:slug] = ENV['GITHUB_REPOSITORY']
196
203
  params[:build] = ENV['GITHUB_RUN_ID']
197
204
  params[:commit] = ENV['GITHUB_SHA']
@@ -329,7 +336,7 @@ class SimpleCov::Formatter::Codecov
329
336
  def create_report(report)
330
337
  result = {
331
338
  'meta' => {
332
- 'version' => 'codecov-ruby/v' + VERSION
339
+ 'version' => 'codecov-ruby/v' + ::Codecov::VERSION
333
340
  }
334
341
  }
335
342
  result.update(result_to_codecov(report))
@@ -512,7 +519,8 @@ class SimpleCov::Formatter::Codecov
512
519
  'node_modules/',
513
520
  'public/',
514
521
  'storage/',
515
- 'tmp/'
522
+ 'tmp/',
523
+ 'vendor/'
516
524
  ]
517
525
 
518
526
  puts [green('==>'), 'Appending file network'].join(' ')
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Codecov
4
+ VERSION = '0.2.15'
5
+ end
metadata CHANGED
@@ -1,128 +1,121 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
- - codecov
8
- autorequire:
7
+ - Steve Peak
8
+ - Tom Hu
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-09-04 00:00:00.000000000 Z
12
+ date: 2020-12-22 00:00:00.000000000 Z
12
13
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
14
  - !ruby/object:Gem::Dependency
28
15
  name: simplecov
29
16
  requirement: !ruby/object:Gem::Requirement
30
17
  requirements:
31
18
  - - ">="
32
19
  - !ruby/object:Gem::Version
33
- version: '0'
20
+ version: '0.15'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '0.21'
34
24
  type: :runtime
35
25
  prerelease: false
36
26
  version_requirements: !ruby/object:Gem::Requirement
37
27
  requirements:
38
28
  - - ">="
39
29
  - !ruby/object:Gem::Version
40
- version: '0'
30
+ version: '0.15'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.21'
41
34
  - !ruby/object:Gem::Dependency
42
35
  name: minitest
43
36
  requirement: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - ">="
38
+ - - "~>"
46
39
  - !ruby/object:Gem::Version
47
- version: '0'
40
+ version: '5.0'
48
41
  type: :development
49
42
  prerelease: false
50
43
  version_requirements: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ">="
45
+ - - "~>"
53
46
  - !ruby/object:Gem::Version
54
- version: '0'
47
+ version: '5.0'
55
48
  - !ruby/object:Gem::Dependency
56
49
  name: minitest-ci
57
50
  requirement: !ruby/object:Gem::Requirement
58
51
  requirements:
59
- - - ">="
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '3.0'
62
55
  type: :development
63
56
  prerelease: false
64
57
  version_requirements: !ruby/object:Gem::Requirement
65
58
  requirements:
66
- - - ">="
59
+ - - "~>"
67
60
  - !ruby/object:Gem::Version
68
- version: '0'
61
+ version: '3.0'
69
62
  - !ruby/object:Gem::Dependency
70
63
  name: mocha
71
64
  requirement: !ruby/object:Gem::Requirement
72
65
  requirements:
73
- - - ">="
66
+ - - "~>"
74
67
  - !ruby/object:Gem::Version
75
- version: '0'
68
+ version: '1.0'
76
69
  type: :development
77
70
  prerelease: false
78
71
  version_requirements: !ruby/object:Gem::Requirement
79
72
  requirements:
80
- - - ">="
73
+ - - "~>"
81
74
  - !ruby/object:Gem::Version
82
- version: '0'
75
+ version: '1.0'
83
76
  - !ruby/object:Gem::Dependency
84
77
  name: rake
85
78
  requirement: !ruby/object:Gem::Requirement
86
79
  requirements:
87
- - - ">="
80
+ - - "~>"
88
81
  - !ruby/object:Gem::Version
89
- version: '0'
82
+ version: '13.0'
90
83
  type: :development
91
84
  prerelease: false
92
85
  version_requirements: !ruby/object:Gem::Requirement
93
86
  requirements:
94
- - - ">="
87
+ - - "~>"
95
88
  - !ruby/object:Gem::Version
96
- version: '0'
89
+ version: '13.0'
97
90
  - !ruby/object:Gem::Dependency
98
91
  name: rubocop
99
92
  requirement: !ruby/object:Gem::Requirement
100
93
  requirements:
101
- - - ">="
94
+ - - "~>"
102
95
  - !ruby/object:Gem::Version
103
- version: '0'
96
+ version: '1.0'
104
97
  type: :development
105
98
  prerelease: false
106
99
  version_requirements: !ruby/object:Gem::Requirement
107
100
  requirements:
108
- - - ">="
101
+ - - "~>"
109
102
  - !ruby/object:Gem::Version
110
- version: '0'
103
+ version: '1.0'
111
104
  - !ruby/object:Gem::Dependency
112
105
  name: webmock
113
106
  requirement: !ruby/object:Gem::Requirement
114
107
  requirements:
115
- - - ">="
108
+ - - "~>"
116
109
  - !ruby/object:Gem::Version
117
- version: '0'
110
+ version: '3.0'
118
111
  type: :development
119
112
  prerelease: false
120
113
  version_requirements: !ruby/object:Gem::Requirement
121
114
  requirements:
122
- - - ">="
115
+ - - "~>"
123
116
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description: hosted code coverage
117
+ version: '3.0'
118
+ description: Hosted code coverage Ruby reporter.
126
119
  email:
127
120
  - hello@codecov.io
128
121
  executables: []
@@ -130,18 +123,18 @@ extensions: []
130
123
  extra_rdoc_files: []
131
124
  files:
132
125
  - lib/codecov.rb
133
- - test/test_codecov.rb
126
+ - lib/codecov/version.rb
134
127
  homepage: https://github.com/codecov/codecov-ruby
135
128
  licenses:
136
129
  - MIT
137
130
  metadata: {}
138
- post_install_message:
131
+ post_install_message:
139
132
  rdoc_options: []
140
133
  require_paths:
141
134
  - lib
142
135
  required_ruby_version: !ruby/object:Gem::Requirement
143
136
  requirements:
144
- - - ">="
137
+ - - "~>"
145
138
  - !ruby/object:Gem::Version
146
139
  version: '2.4'
147
140
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -150,9 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
143
  - !ruby/object:Gem::Version
151
144
  version: '0'
152
145
  requirements: []
153
- rubygems_version: 3.1.2
154
- signing_key:
146
+ rubygems_version: 3.0.3
147
+ signing_key:
155
148
  specification_version: 4
156
- summary: hosted code coverage ruby/rails reporter
157
- test_files:
158
- - test/test_codecov.rb
149
+ summary: Hosted code coverage
150
+ test_files: []
@@ -1,675 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'helper'
4
-
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
-
44
- def url
45
- ENV['CODECOV_URL'] || 'https://codecov.io'
46
- end
47
-
48
- def test_defined
49
- assert defined?(SimpleCov::Formatter::Codecov)
50
- assert defined?(SimpleCov::Formatter::Codecov::VERSION)
51
- end
52
-
53
- def stub_file(filename, coverage)
54
- lines = coverage.each_with_index.map do |cov, i|
55
- skipped = false
56
- if cov == :skipped
57
- skipped = true
58
- cov = 0
59
- end
60
- stub('SimpleCov::SourceFile::Line', skipped?: skipped, line_number: i + 1, coverage: cov)
61
- end
62
- stub('SimpleCov::SourceFile', filename: filename, lines: lines)
63
- end
64
-
65
- def upload(success = true)
66
- WebMock.enable!
67
- formatter = SimpleCov::Formatter::Codecov.new
68
- result = stub('SimpleCov::Result', files: [
69
- stub_file('/path/lib/something.rb', [1, 0, 0, nil, 1, nil]),
70
- stub_file('/path/lib/somefile.rb', [1, nil, 1, 1, 1, 0, 0, nil, 1, nil])
71
- ])
72
- SimpleCov.stubs(:root).returns('/path')
73
- success_stubs if success
74
- data = formatter.format(result, false)
75
- puts data
76
- 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
- assert_equal(data['result']['uploaded'], true)
98
- assert_equal(data['result']['message'], 'Coverage reports upload successfully')
99
- assert_equal(data['meta']['version'], 'codecov-ruby/v' + SimpleCov::Formatter::Codecov::VERSION)
100
- assert_equal(data['coverage'].to_json, {
101
- 'lib/something.rb' => [nil, 1, 0, 0, nil, 1, nil],
102
- 'lib/somefile.rb' => [nil, 1, nil, 1, 1, 1, 0, 0, nil, 1, nil]
103
- }.to_json)
104
- end
105
-
106
- def setup
107
- ENV['CI'] = nil
108
- ENV['CIRCLECI'] = nil
109
- ENV['GITHUB_ACTIONS'] = nil
110
- ENV['TRAVIS'] = nil
111
- end
112
-
113
- def teardown
114
- # needed for sending this projects coverage
115
- ENV['APPVEYOR'] = nil
116
- ENV['APPVEYOR_ACCOUNT_NAME'] = nil
117
- ENV['APPVEYOR_BUILD_VERSION'] = nil
118
- ENV['APPVEYOR_JOB_ID'] = nil
119
- ENV['APPVEYOR_PROJECT_SLUG'] = nil
120
- ENV['APPVEYOR_PULL_REQUEST_NUMBER'] = nil
121
- ENV['APPVEYOR_REPO_BRANCH'] = nil
122
- ENV['APPVEYOR_REPO_COMMIT'] = nil
123
- ENV['APPVEYOR_REPO_NAME'] = nil
124
- ENV['BITBUCKET_BRANCH'] = nil
125
- ENV['BITBUCKET_BUILD_NUMBER'] = nil
126
- ENV['BITBUCKET_COMMIT'] = nil
127
- ENV['BITRISE_BUILD_NUMBER'] = nil
128
- ENV['BITRISE_BUILD_URL'] = nil
129
- ENV['BITRISE_GIT_BRANCH'] = nil
130
- ENV['BITRISE_GIT_COMMIT'] = nil
131
- ENV['BITRISE_IO'] = nil
132
- ENV['BITRISE_PULL_REQUEST'] = nil
133
- ENV['BITRISEIO_GIT_REPOSITORY_OWNER'] = nil
134
- ENV['BITRISEIO_GIT_REPOSITORY_SLUG'] = nil
135
- ENV['BRANCH'] = nil
136
- ENV['BRANCH_NAME'] = nil
137
- ENV['BUILD_ID'] = nil
138
- ENV['BUILD_NUMBER'] = nil
139
- ENV['BUILD_NUMBER'] = nil
140
- ENV['BUILD_URL'] = nil
141
- ENV['BUILDKITE'] = nil
142
- ENV['BUILDKITE_BRANCH'] = nil
143
- ENV['BUILDKITE_JOB_ID'] = nil
144
- ENV['BUILDKITE_BUILD_NUMBER'] = nil
145
- ENV['BUILDKITE_BUILD_URL'] = nil
146
- ENV['BUILDKITE_PROJECT_SLUG'] = nil
147
- ENV['BUILDKITE_COMMIT'] = nil
148
- ENV['CI'] = 'true'
149
- ENV['CI_BRANCH'] = nil
150
- ENV['CI_BUILD_ID'] = nil
151
- ENV['CI_BUILD_NUMBER'] = nil
152
- ENV['CI_BUILD_REF'] = nil
153
- ENV['CI_BUILD_REF_NAME'] = nil
154
- ENV['CI_BUILD_REPO'] = nil
155
- ENV['CI_BUILD_URL'] = nil
156
- ENV['CI_COMMIT'] = nil
157
- ENV['CI_COMMIT_ID'] = nil
158
- ENV['CI_NAME'] = nil
159
- ENV['CI_PROJECT_DIR'] = nil
160
- ENV['CI_SERVER_NAME'] = nil
161
- ENV['CI_SERVER_NAME'] = nil
162
- ENV['CIRCLE_BRANCH'] = nil
163
- ENV['CIRCLE_BUILD_NUM'] = nil
164
- ENV['CIRCLE_NODE_INDEX'] = nil
165
- ENV['CIRCLE_PR_NUMBER'] = nil
166
- ENV['CIRCLE_PROJECT_REPONAME'] = nil
167
- ENV['CIRCLE_PROJECT_USERNAME'] = nil
168
- ENV['CIRCLE_SHA1'] = nil
169
- 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
- ENV['CODECOV_ENV'] = nil
177
- ENV['CODECOV_SLUG'] = nil
178
- ENV['CODECOV_TOKEN'] = nil
179
- ENV['CODECOV_URL'] = nil
180
- ENV['COMMIT'] = nil
181
- ENV['DRONE'] = nil
182
- ENV['DRONE_BRANCH'] = nil
183
- ENV['DRONE_BUILD_URL'] = nil
184
- ENV['DRONE_COMMIT'] = nil
185
- ENV['ghprbActualCommit'] = nil
186
- ENV['ghprbPullId'] = nil
187
- ENV['ghprbSourceBranch'] = nil
188
- ENV['GIT_BRANCH'] = nil
189
- 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
- ENV['GITLAB_CI'] = nil
197
- ENV['HEROKU_TEST_RUN_ID'] = nil
198
- ENV['HEROKU_TEST_RUN_BRANCH'] = nil
199
- ENV['HEROKU_TEST_RUN_COMMIT_VERSION'] = nil
200
- ENV['JENKINS_URL'] = nil
201
- ENV['MAGNUM'] = nil
202
- ENV['PULL_REQUEST'] = nil
203
- ENV['REPO_NAME'] = nil
204
- ENV['REVISION'] = nil
205
- ENV['SEMAPHORE'] = nil
206
- ENV['SEMAPHORE_BUILD_NUMBER'] = nil
207
- ENV['SEMAPHORE_CURRENT_THREAD'] = nil
208
- ENV['SEMAPHORE_REPO_SLUG'] = nil
209
- ENV['SHIPPABLE'] = nil
210
- 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
218
- ENV['VCS_COMMIT_ID'] = nil
219
- ENV['WERCKER_GIT_BRANCH'] = nil
220
- ENV['WERCKER_GIT_COMMIT'] = nil
221
- ENV['WERCKER_GIT_OWNER'] = nil
222
- ENV['WERCKER_GIT_REPOSITORY'] = nil
223
- ENV['WERCKER_MAIN_PIPELINE_STARTED'] = nil
224
- ENV['WORKSPACE'] = nil
225
-
226
- REALENV.each_pair { |k, v| ENV[k] = v }
227
- end
228
-
229
- def test_git
230
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
231
- result = upload
232
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
233
- branch = `git rev-parse --abbrev-ref HEAD`.strip
234
- assert_equal(branch != 'HEAD' ? branch : 'master', result['params'][:branch])
235
- assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
236
- end
237
-
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
- def test_travis
256
- ENV['CI'] = 'true'
257
- ENV['TRAVIS'] = 'true'
258
- ENV['TRAVIS_BRANCH'] = 'master'
259
- ENV['TRAVIS_COMMIT'] = 'c739768fcac68144a3a6d82305b9c4106934d31a'
260
- ENV['TRAVIS_JOB_ID'] = '33116958'
261
- ENV['TRAVIS_PULL_REQUEST'] = 'false'
262
- ENV['TRAVIS_JOB_NUMBER'] = '1'
263
- ENV['TRAVIS_REPO_SLUG'] = 'codecov/ci-repo'
264
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
265
- result = upload
266
- assert_equal('travis', result['params'][:service])
267
- assert_equal('c739768fcac68144a3a6d82305b9c4106934d31a', result['params'][:commit])
268
- assert_equal('codecov/ci-repo', result['params'][:slug])
269
- assert_equal('1', result['params'][:build])
270
- assert_equal('33116958', result['params'][:job])
271
- assert_equal('false', result['params'][:pull_request])
272
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
273
- end
274
-
275
- def test_codeship
276
- ENV['CI'] = 'true'
277
- ENV['CI_NAME'] = 'codeship'
278
- ENV['CI_BRANCH'] = 'master'
279
- ENV['CI_BUILD_NUMBER'] = '1'
280
- ENV['CI_COMMIT_ID'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
281
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
282
- result = upload
283
- assert_equal('codeship', result['params'][:service])
284
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
285
- assert_equal('1', result['params'][:build])
286
- assert_equal('master', result['params'][:branch])
287
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
288
- end
289
-
290
- def test_buildkite
291
- ENV['CI'] = 'true'
292
- ENV['BUILDKITE'] = 'true'
293
- ENV['BUILDKITE_BRANCH'] = 'master'
294
- ENV['BUILDKITE_BUILD_NUMBER'] = '1'
295
- ENV['BUILDKITE_JOB_ID'] = '2'
296
- ENV['BUILDKITE_BUILD_URL'] = 'http://demo'
297
- ENV['BUILDKITE_PROJECT_SLUG'] = 'owner/repo'
298
- ENV['BUILDKITE_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
299
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
300
- result = upload
301
- assert_equal('buildkite', result['params'][:service])
302
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
303
- assert_equal('1', result['params'][:build])
304
- assert_equal('2', result['params'][:job])
305
- assert_equal('master', result['params'][:branch])
306
- assert_equal('owner/repo', result['params'][:slug])
307
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
308
- end
309
-
310
- def test_jenkins
311
- ENV['JENKINS_URL'] = 'true'
312
- ENV['ghprbSourceBranch'] = 'master'
313
- ENV['BUILD_NUMBER'] = '1'
314
- ENV['ghprbActualCommit'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
315
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
316
- ENV['BUILD_URL'] = 'https://jenkins'
317
- ENV['ghprbPullId'] = '1'
318
- result = upload
319
- assert_equal('jenkins', result['params'][:service])
320
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
321
- assert_equal('1', result['params'][:build])
322
- assert_equal('1', result['params'][:pr])
323
- assert_equal('master', result['params'][:branch])
324
- assert_equal('https://jenkins', result['params'][:build_url])
325
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
326
- end
327
-
328
- def test_jenkins_2
329
- ENV['JENKINS_URL'] = 'true'
330
- ENV['GIT_BRANCH'] = 'master'
331
- ENV['BUILD_NUMBER'] = '1'
332
- ENV['GIT_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
333
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
334
- ENV['BUILD_URL'] = 'https://jenkins'
335
- result = upload
336
- assert_equal('jenkins', result['params'][:service])
337
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
338
- assert_equal('1', result['params'][:build])
339
- assert_equal('master', result['params'][:branch])
340
- assert_equal('https://jenkins', result['params'][:build_url])
341
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
342
- end
343
-
344
- def test_shippable
345
- ENV['CI'] = 'true'
346
- ENV['SHIPPABLE'] = 'true'
347
- ENV['BRANCH'] = 'master'
348
- ENV['BUILD_NUMBER'] = '1'
349
- ENV['BUILD_URL'] = 'http://shippable.com/...'
350
- ENV['PULL_REQUEST'] = 'false'
351
- ENV['REPO_NAME'] = 'owner/repo'
352
- ENV['COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
353
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
354
- result = upload
355
- assert_equal('shippable', result['params'][:service])
356
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
357
- assert_equal('false', result['params'][:pull_request])
358
- assert_equal('1', result['params'][:build])
359
- assert_equal('http://shippable.com/...', result['params'][:build_url])
360
- assert_equal('master', result['params'][:branch])
361
- assert_equal('owner/repo', result['params'][:slug])
362
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
363
- end
364
-
365
- def test_appveyor
366
- ENV['CI'] = 'True'
367
- ENV['APPVEYOR'] = 'True'
368
- ENV['APPVEYOR_REPO_BRANCH'] = 'master'
369
- ENV['APPVEYOR_JOB_ID'] = 'build'
370
- ENV['APPVEYOR_PULL_REQUEST_NUMBER'] = '1'
371
- ENV['APPVEYOR_ACCOUNT_NAME'] = 'owner'
372
- ENV['APPVEYOR_PROJECT_SLUG'] = 'repo'
373
- ENV['APPVEYOR_BUILD_VERSION'] = 'job'
374
- ENV['APPVEYOR_REPO_NAME'] = 'owner/repo'
375
- ENV['APPVEYOR_REPO_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
376
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
377
- result = upload
378
- assert_equal('appveyor', result['params'][:service])
379
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
380
- assert_equal('master', result['params'][:branch])
381
- assert_equal('owner/repo', result['params'][:slug])
382
- assert_equal('1', result['params'][:pr])
383
- assert_equal('build', result['params'][:build])
384
- assert_equal('owner/repo/job', result['params'][:job])
385
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
386
- end
387
-
388
- def test_circleci
389
- ENV['CI'] = 'true'
390
- ENV['CIRCLECI'] = 'true'
391
- ENV['CIRCLE_BRANCH'] = 'master'
392
- ENV['CIRCLE_BUILD_NUM'] = '1'
393
- ENV['CIRCLE_NODE_INDEX'] = '2'
394
- ENV['CIRCLE_PR_NUMBER'] = '3'
395
- ENV['CIRCLE_PROJECT_USERNAME'] = 'owner'
396
- ENV['CIRCLE_PROJECT_REPONAME'] = 'repo'
397
- ENV['CIRCLE_SHA1'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
398
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
399
- result = upload
400
- assert_equal('circleci', result['params'][:service])
401
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
402
- assert_equal('1', result['params'][:build])
403
- assert_equal('2', result['params'][:job])
404
- assert_equal('3', result['params'][:pr])
405
- assert_equal('master', result['params'][:branch])
406
- assert_equal('owner/repo', result['params'][:slug])
407
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
408
- end
409
-
410
- def test_semaphore
411
- ENV['CI'] = 'true'
412
- ENV['SEMAPHORE'] = 'true'
413
- ENV['BRANCH_NAME'] = 'master'
414
- ENV['SEMAPHORE_REPO_SLUG'] = 'owner/repo'
415
- ENV['SEMAPHORE_BUILD_NUMBER'] = '1'
416
- ENV['SEMAPHORE_CURRENT_THREAD'] = '2'
417
- ENV['REVISION'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
418
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
419
- result = upload
420
- assert_equal('semaphore', result['params'][:service])
421
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
422
- assert_equal('1', result['params'][:build])
423
- assert_equal('2', result['params'][:job])
424
- assert_equal('master', result['params'][:branch])
425
- assert_equal('owner/repo', result['params'][:slug])
426
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
427
- end
428
-
429
- def test_drone
430
- ENV['CI'] = 'true'
431
- ENV['DRONE'] = 'true'
432
- ENV['DRONE_BRANCH'] = 'master'
433
- ENV['DRONE_BUILD_NUMBER'] = '1'
434
- ENV['DRONE_BUILD_URL'] = 'https://drone.io/...'
435
- ENV['DRONE_COMMIT'] = '1123566'
436
- ENV['CODECOV_SLUG'] = 'codecov/ci-repo'
437
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
438
- result = upload
439
- assert_equal('drone.io', result['params'][:service])
440
- assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
441
- assert_equal('1', result['params'][:build])
442
- assert_equal('https://drone.io/...', result['params'][:build_url])
443
- assert_equal('codecov/ci-repo', result['params'][:slug])
444
- assert_equal('master', result['params'][:branch])
445
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
446
- end
447
-
448
- def test_wercker
449
- ENV['CI'] = 'true'
450
- ENV['WERCKER_GIT_BRANCH'] = 'master'
451
- ENV['WERCKER_MAIN_PIPELINE_STARTED'] = '1'
452
- ENV['WERCKER_GIT_OWNER'] = 'owner'
453
- ENV['WERCKER_GIT_REPOSITORY'] = 'repo'
454
- ENV['WERCKER_GIT_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
455
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
456
- result = upload
457
- assert_equal('wercker', result['params'][:service])
458
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
459
- assert_equal('1', result['params'][:build])
460
- assert_equal('master', result['params'][:branch])
461
- assert_equal('owner/repo', result['params'][:slug])
462
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
463
- end
464
-
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
- def test_gitlab
504
- ENV['GITLAB_CI'] = 'true'
505
- ENV['CI_BUILD_REF_NAME'] = 'master'
506
- ENV['CI_BUILD_ID'] = '1'
507
- ENV['CI_BUILD_REPO'] = 'https://gitlab.com/owner/repo.git'
508
- ENV['CI_BUILD_REF'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
509
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
510
- result = upload
511
- assert_equal('gitlab', result['params'][:service])
512
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
513
- assert_equal('1', result['params'][:build])
514
- assert_equal('master', result['params'][:branch])
515
- assert_equal('owner/repo', result['params'][:slug])
516
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
517
- end
518
-
519
- def test_bitrise
520
- ENV['CI'] = 'true'
521
- ENV['BITRISE_IO'] = 'true'
522
- ENV['BITRISE_BUILD_NUMBER'] = '1'
523
- ENV['BITRISE_BUILD_URL'] = 'https://app.bitrise.io/build/123'
524
- ENV['BITRISE_GIT_BRANCH'] = 'master'
525
- ENV['BITRISE_PULL_REQUEST'] = '2'
526
- ENV['BITRISEIO_GIT_REPOSITORY_OWNER'] = 'owner'
527
- ENV['BITRISEIO_GIT_REPOSITORY_SLUG'] = 'repo'
528
- ENV['BITRISE_GIT_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
529
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
530
- result = upload
531
- assert_equal('bitrise', result['params'][:service])
532
- assert_equal('1', result['params'][:build])
533
- assert_equal('https://app.bitrise.io/build/123', result['params'][:build_url])
534
- assert_equal('master', result['params'][:branch])
535
- assert_equal('2', result['params'][:pr])
536
- assert_equal('owner/repo', result['params'][:slug])
537
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
538
- end
539
-
540
- def test_teamcity
541
- ENV['CI_SERVER_NAME'] = 'TeamCity'
542
- ENV['TEAMCITY_BUILD_BRANCH'] = 'master'
543
- ENV['TEAMCITY_BUILD_ID'] = '1'
544
- ENV['TEAMCITY_BUILD_URL'] = 'http://teamcity/...'
545
- ENV['TEAMCITY_BUILD_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
546
- ENV['TEAMCITY_BUILD_REPOSITORY'] = 'https://github.com/owner/repo.git'
547
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
548
- result = upload
549
- assert_equal('teamcity', result['params'][:service])
550
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
551
- assert_equal('1', result['params'][:build])
552
- assert_equal('master', result['params'][:branch])
553
- assert_equal('owner/repo', result['params'][:slug])
554
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
555
- end
556
-
557
- def test_azure_pipelines
558
- ENV['TF_BUILD'] = '1'
559
- ENV['BUILD_SOURCEBRANCH'] = 'master'
560
- ENV['SYSTEM_JOBID'] = '92a2fa25-f940-5df6-a185-81eb9ae2031d'
561
- ENV['BUILD_BUILDID'] = '1'
562
- ENV['SYSTEM_TEAMFOUNDATIONSERVERURI'] = 'https://dev.azure.com/codecov/'
563
- ENV['SYSTEM_TEAMPROJECT'] = 'repo'
564
- ENV['BUILD_SOURCEVERSION'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
565
- ENV['BUILD_REPOSITORY_ID'] = 'owner/repo'
566
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
567
- result = upload
568
- assert_equal('azure_pipelines', result['params'][:service])
569
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
570
- assert_equal('1', result['params'][:build])
571
- assert_equal('master', result['params'][:branch])
572
- assert_equal('owner/repo', result['params'][:slug])
573
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
574
- end
575
-
576
- def test_heroku
577
- ENV['HEROKU_TEST_RUN_ID'] = '454f5dc9-afa4-433f-bb28-84678a00fd98'
578
- ENV['HEROKU_TEST_RUN_BRANCH'] = 'master'
579
- ENV['HEROKU_TEST_RUN_COMMIT_VERSION'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
580
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
581
-
582
- result = upload
583
- assert_equal('heroku', result['params'][:service])
584
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
585
- assert_equal('454f5dc9-afa4-433f-bb28-84678a00fd98', result['params'][:build])
586
- assert_equal('master', result['params'][:branch])
587
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
588
- end
589
-
590
- def test_bitbucket_pr
591
- ENV['CI'] = 'true'
592
- ENV['BITBUCKET_BUILD_NUMBER'] = '100'
593
- ENV['BITBUCKET_BRANCH'] = 'master'
594
- ENV['BITBUCKET_COMMIT'] = '743b04806ea67'
595
- ENV['VCS_COMMIT_ID'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
596
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
597
-
598
- result = upload
599
- assert_equal('bitbucket', result['params'][:service])
600
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
601
- assert_equal('100', result['params'][:build])
602
- assert_equal('master', result['params'][:branch])
603
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
604
- end
605
-
606
- def test_bitbucket
607
- ENV['CI'] = 'true'
608
- ENV['BITBUCKET_BUILD_NUMBER'] = '100'
609
- ENV['BITBUCKET_BRANCH'] = 'master'
610
- ENV['BITBUCKET_COMMIT'] = '743b04806ea677403aa2ff26c6bdeb85005de658'
611
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
612
-
613
- result = upload
614
- assert_equal('bitbucket', result['params'][:service])
615
- assert_equal('743b04806ea677403aa2ff26c6bdeb85005de658', result['params'][:commit])
616
- assert_equal('100', result['params'][:build])
617
- assert_equal('master', result['params'][:branch])
618
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
619
- end
620
-
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
- def test_filenames_are_shortened_correctly
643
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
644
-
645
- formatter = SimpleCov::Formatter::Codecov.new
646
- result = stub('SimpleCov::Result', files: [
647
- stub_file('/path/lib/something.rb', []),
648
- stub_file('/path/path/lib/path_somefile.rb', [])
649
- ])
650
- SimpleCov.stubs(:root).returns('/path')
651
- data = formatter.format(result)
652
- puts data
653
- puts data['params']
654
- assert_equal(data['coverage'].to_json, {
655
- 'lib/something.rb' => [nil],
656
- 'path/lib/path_somefile.rb' => [nil]
657
- }.to_json)
658
- 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
- end