codecov 0.2.12 → 0.2.13

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 +8 -4
  3. metadata +36 -51
  4. data/test/test_codecov.rb +0 -696
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98728653c21cce7decd7a9b031e54e950da789d70c464bb61e53e1964372ac1d
4
- data.tar.gz: 8d45300d929ff5bd39cb5cfb562960ef1bf3b36b1f51754376f25c8ac8ae3a31
3
+ metadata.gz: 75ab24dda77623328bb256121c146e749bf1e603d11cf9e09fd221a53e2de72c
4
+ data.tar.gz: 58a176feaa17140c94356f46d6cba02c1aea7a581ce4f870fe707569bb769793
5
5
  SHA512:
6
- metadata.gz: bdd1f35739f17cc5110ea0c2fa51bf4939812b96ff96009311dfb52ea67b63107cdbfbb8ad6e9b76f1cdc1104a136407bf1f9e89d1509c717131d9b03e62a986
7
- data.tar.gz: 84673f1a411a1b7746b04448a79aa9a84b3e5606d14f7c70b6adee66be765f66ba2caed073cda2dc837788b7a67cc3a0c6c232655533e1170ea0865b30f77c93
6
+ metadata.gz: a47d3113eef1bee9492dcf8b6513f1be2aaa9d397167153bd6f2903786c7d60de82325475c1ff94acb152cae8619720edc0aee6f5280632dbd44621e040a2385
7
+ data.tar.gz: 7949c0bce5c9fd2caf25547fdb4c431e63eb495848534e993ceac98b649b35713e8b4764822e8d99147e9a0e8da1d3356c8323ed5a17dff73f709ca03aa22f90
@@ -7,7 +7,7 @@ require 'simplecov'
7
7
  require 'zlib'
8
8
 
9
9
  class SimpleCov::Formatter::Codecov
10
- VERSION = '0.2.12'
10
+ VERSION = '0.2.13'
11
11
 
12
12
  ### CIs
13
13
  RECOGNIZED_CIS = [
@@ -192,9 +192,13 @@ class SimpleCov::Formatter::Codecov
192
192
  when GITHUB
193
193
  # https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
194
194
  params[:service] = 'github-actions'
195
- params[:branch] = ENV['GITHUB_HEAD_REF'] || ENV['GITHUB_REF'].sub('refs/head/', '')
196
- # PR refs are in the format: refs/pull/7/merge for pull_request events
197
- 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
198
202
  params[:slug] = ENV['GITHUB_REPOSITORY']
199
203
  params[:build] = ENV['GITHUB_RUN_ID']
200
204
  params[:commit] = ENV['GITHUB_SHA']
metadata CHANGED
@@ -1,128 +1,115 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codecov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
- - codecov
7
+ - Steve Peak
8
+ - Tom Hu
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-10-09 00:00:00.000000000 Z
12
+ date: 2020-12-10 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.18.0
34
21
  type: :runtime
35
22
  prerelease: false
36
23
  version_requirements: !ruby/object:Gem::Requirement
37
24
  requirements:
38
- - - ">="
25
+ - - "~>"
39
26
  - !ruby/object:Gem::Version
40
- version: '0'
27
+ version: 0.18.0
41
28
  - !ruby/object:Gem::Dependency
42
29
  name: minitest
43
30
  requirement: !ruby/object:Gem::Requirement
44
31
  requirements:
45
- - - ">="
32
+ - - "~>"
46
33
  - !ruby/object:Gem::Version
47
- version: '0'
34
+ version: '5.0'
48
35
  type: :development
49
36
  prerelease: false
50
37
  version_requirements: !ruby/object:Gem::Requirement
51
38
  requirements:
52
- - - ">="
39
+ - - "~>"
53
40
  - !ruby/object:Gem::Version
54
- version: '0'
41
+ version: '5.0'
55
42
  - !ruby/object:Gem::Dependency
56
43
  name: minitest-ci
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
59
- - - ">="
46
+ - - "~>"
60
47
  - !ruby/object:Gem::Version
61
- version: '0'
48
+ version: '3.0'
62
49
  type: :development
63
50
  prerelease: false
64
51
  version_requirements: !ruby/object:Gem::Requirement
65
52
  requirements:
66
- - - ">="
53
+ - - "~>"
67
54
  - !ruby/object:Gem::Version
68
- version: '0'
55
+ version: '3.0'
69
56
  - !ruby/object:Gem::Dependency
70
57
  name: mocha
71
58
  requirement: !ruby/object:Gem::Requirement
72
59
  requirements:
73
- - - ">="
60
+ - - "~>"
74
61
  - !ruby/object:Gem::Version
75
- version: '0'
62
+ version: '1.0'
76
63
  type: :development
77
64
  prerelease: false
78
65
  version_requirements: !ruby/object:Gem::Requirement
79
66
  requirements:
80
- - - ">="
67
+ - - "~>"
81
68
  - !ruby/object:Gem::Version
82
- version: '0'
69
+ version: '1.0'
83
70
  - !ruby/object:Gem::Dependency
84
71
  name: rake
85
72
  requirement: !ruby/object:Gem::Requirement
86
73
  requirements:
87
- - - ">="
74
+ - - "~>"
88
75
  - !ruby/object:Gem::Version
89
- version: '0'
76
+ version: '13.0'
90
77
  type: :development
91
78
  prerelease: false
92
79
  version_requirements: !ruby/object:Gem::Requirement
93
80
  requirements:
94
- - - ">="
81
+ - - "~>"
95
82
  - !ruby/object:Gem::Version
96
- version: '0'
83
+ version: '13.0'
97
84
  - !ruby/object:Gem::Dependency
98
85
  name: rubocop
99
86
  requirement: !ruby/object:Gem::Requirement
100
87
  requirements:
101
- - - ">="
88
+ - - "~>"
102
89
  - !ruby/object:Gem::Version
103
- version: '0'
90
+ version: '1.0'
104
91
  type: :development
105
92
  prerelease: false
106
93
  version_requirements: !ruby/object:Gem::Requirement
107
94
  requirements:
108
- - - ">="
95
+ - - "~>"
109
96
  - !ruby/object:Gem::Version
110
- version: '0'
97
+ version: '1.0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: webmock
113
100
  requirement: !ruby/object:Gem::Requirement
114
101
  requirements:
115
- - - ">="
102
+ - - "~>"
116
103
  - !ruby/object:Gem::Version
117
- version: '0'
104
+ version: '3.0'
118
105
  type: :development
119
106
  prerelease: false
120
107
  version_requirements: !ruby/object:Gem::Requirement
121
108
  requirements:
122
- - - ">="
109
+ - - "~>"
123
110
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description: hosted code coverage
111
+ version: '3.0'
112
+ description: Hosted code coverage Ruby reporter.
126
113
  email:
127
114
  - hello@codecov.io
128
115
  executables: []
@@ -130,7 +117,6 @@ extensions: []
130
117
  extra_rdoc_files: []
131
118
  files:
132
119
  - lib/codecov.rb
133
- - test/test_codecov.rb
134
120
  homepage: https://github.com/codecov/codecov-ruby
135
121
  licenses:
136
122
  - MIT
@@ -141,7 +127,7 @@ require_paths:
141
127
  - lib
142
128
  required_ruby_version: !ruby/object:Gem::Requirement
143
129
  requirements:
144
- - - ">="
130
+ - - "~>"
145
131
  - !ruby/object:Gem::Version
146
132
  version: '2.4'
147
133
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -153,6 +139,5 @@ requirements: []
153
139
  rubygems_version: 3.0.3
154
140
  signing_key:
155
141
  specification_version: 4
156
- summary: hosted code coverage ruby/rails reporter
157
- test_files:
158
- - test/test_codecov.rb
142
+ summary: Hosted code coverage
143
+ test_files: []
@@ -1,696 +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_codebuild_source_version_is_other_than_pr_number
643
- ENV['CODEBUILD_CI'] = 'true'
644
- ENV['CODEBUILD_BUILD_ID'] = 'codebuild-project:458dq3q8-7354-4513-8702-ea7b9c81efb3'
645
- ENV['CODEBUILD_RESOLVED_SOURCE_VERSION'] = 'd653b934ed59c1a785cc1cc79d08c9aaa4eba73b'
646
- ENV['CODEBUILD_WEBHOOK_HEAD_REF'] = 'refs/heads/master'
647
- ENV['CODEBUILD_SOURCE_VERSION'] = 'git-commit-hash-12345'
648
- ENV['CODEBUILD_SOURCE_REPO_URL'] = 'https://github.com/owner/repo.git'
649
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
650
-
651
- result = upload
652
-
653
- assert_equal('codebuild', result['params'][:service])
654
- assert_equal('d653b934ed59c1a785cc1cc79d08c9aaa4eba73b', result['params'][:commit])
655
- assert_equal('codebuild-project:458dq3q8-7354-4513-8702-ea7b9c81efb3', result['params'][:build])
656
- assert_equal('git-commit-hash-12345', result['params'][:pr])
657
- assert_equal('owner/repo', result['params'][:slug])
658
- assert_equal('master', result['params'][:branch])
659
- assert_equal('git-commit-hash-12345', result['params'][:pr])
660
- assert_equal('f881216b-b5c0-4eb1-8f21-b51887d1d506', result['params']['token'])
661
- end
662
-
663
- def test_filenames_are_shortened_correctly
664
- ENV['CODECOV_TOKEN'] = 'f881216b-b5c0-4eb1-8f21-b51887d1d506'
665
-
666
- formatter = SimpleCov::Formatter::Codecov.new
667
- result = stub('SimpleCov::Result', files: [
668
- stub_file('/path/lib/something.rb', []),
669
- stub_file('/path/path/lib/path_somefile.rb', [])
670
- ])
671
- SimpleCov.stubs(:root).returns('/path')
672
- data = formatter.format(result)
673
- puts data
674
- puts data['params']
675
- assert_equal(data['coverage'].to_json, {
676
- 'lib/something.rb' => [nil],
677
- 'path/lib/path_somefile.rb' => [nil]
678
- }.to_json)
679
- end
680
-
681
- def test_invalid_token
682
- stub_request(:post, %r{https:\/\/codecov.io\/upload})
683
- .to_return(
684
- status: 400,
685
- body: "HTTP 400\n" \
686
- 'Provided token is not a UUID.'
687
- )
688
-
689
- ENV['CODECOV_TOKEN'] = 'fake'
690
- result = upload(false)
691
- assert_equal(false, result['result']['uploaded'])
692
- branch = `git rev-parse --abbrev-ref HEAD`.strip
693
- assert_equal(branch != 'HEAD' ? branch : 'master', result['params'][:branch])
694
- assert_equal(`git rev-parse HEAD`.strip, result['params'][:commit])
695
- end
696
- end