Skip to content

Commit 7ba8b19

Browse files
Merge pull request #367 from codecov/wip/build-url
Fix encoding of `buildURL`
2 parents 6b330f7 + a6e3abf commit 7ba8b19

11 files changed

+25
-25
lines changed

src/ci_providers/provider_appveyorci.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function detect(envs: UploaderEnvs): boolean {
99

1010
function _getBuild(inputs: UploaderInputs) {
1111
const { args, environment: envs } = inputs
12-
return args.build || encodeURIComponent(envs.APPVEYOR_JOB_ID || '')
12+
return args.build || envs.APPVEYOR_JOB_ID || ''
1313
}
1414

1515
function _getBuildURL(inputs: UploaderInputs) {
@@ -20,8 +20,8 @@ function _getBuildURL(inputs: UploaderInputs) {
2020
envs.APPVEYOR_BUILD_ID &&
2121
envs.APPVEYOR_JOB_ID
2222
) {
23-
return encodeURIComponent(
24-
`${envs.APPVEYOR_URL}/project/${envs.APPVEYOR_REPO_NAME}/builds/${envs.APPVEYOR_BUILD_ID}/job/${envs.APPVEYOR_JOB_ID}`,
23+
return (
24+
`${envs.APPVEYOR_URL}/project/${envs.APPVEYOR_REPO_NAME}/builds/${envs.APPVEYOR_BUILD_ID}/job/${envs.APPVEYOR_JOB_ID}`
2525
)
2626
}
2727
return ''

src/ci_providers/provider_azurepipelines.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ function _getBuild(inputs: UploaderInputs): string {
1414
function _getBuildURL(inputs: UploaderInputs): string {
1515
const { environment: envs } = inputs
1616
if (envs.SYSTEM_TEAMPROJECT && envs.BUILD_BUILDID) {
17-
return encodeURIComponent(
18-
`${envs.SYSTEM_TEAMFOUNDATIONSERVERURI}${envs.SYSTEM_TEAMPROJECT}/_build/results?buildId=${envs.BUILD_BUILDID}`,
17+
return (
18+
`${envs.SYSTEM_TEAMFOUNDATIONSERVERURI}${envs.SYSTEM_TEAMPROJECT}/_build/results?buildId=${envs.BUILD_BUILDID}`
1919
)
2020
}
2121
return ''

src/ci_providers/provider_circleci.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function detect(envs: UploaderEnvs): boolean {
66

77
// eslint-disable-next-line no-unused-vars
88
function _getBuildURL(inputs: UploaderInputs): string {
9-
return ''
9+
return inputs.environment['CIRCLE_BUILD_URL'] ?? ''
1010
}
1111

1212
// This is the value that gets passed to the Codecov uploader

src/ci_providers/provider_githubactions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ function _getBuild(inputs: UploaderInputs): string {
1414

1515
function _getBuildURL(inputs: UploaderInputs): string {
1616
const { environment: envs } = inputs
17-
return encodeURIComponent(
17+
return (
1818
`${envs.GITHUB_SERVER_URL}/${_getSlug(inputs)}/actions/runs/${_getBuild(
1919
inputs,
20-
)}`,
20+
)}`
2121
)
2222
}
2323

@@ -37,7 +37,7 @@ function _getBranch(inputs: UploaderInputs): string {
3737
}
3838

3939
function _getJob(envs: UploaderEnvs): string {
40-
return encodeURIComponent(envs.GITHUB_WORKFLOW || '')
40+
return (envs.GITHUB_WORKFLOW || '')
4141
}
4242

4343
function _getPR(inputs: UploaderInputs): number {

src/ci_providers/provider_jenkinsci.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function _getBuild(inputs: UploaderInputs): string {
1212

1313
function _getBuildURL(inputs: UploaderInputs): string {
1414
const { environment: envs } = inputs
15-
return envs.BUILD_URL ? encodeURIComponent(envs.BUILD_URL) : ''
15+
return envs.BUILD_URL ? (envs.BUILD_URL) : ''
1616
}
1717

1818
function _getBranch(inputs: UploaderInputs): string {

src/helpers/web.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ export function generateQuery(queryParams: IServiceParams): string {
114114
if (queryParams.pr === 0 || isNaN(Number(queryParams.pr))) {
115115
queryParams.pr = ''
116116
}
117-
return Object.entries(queryParams)
118-
.map(([key, value]) => `${snakeCase(key)}=${value}`)
119-
.join('&')
117+
return new URLSearchParams(Object.entries(queryParams)
118+
.map(([key, value]) => [snakeCase(key), value])
119+
).toString()
120120
}
121121

122122
export function parsePOSTResults(uploadURL: string): {

test/helpers/web.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('Web Helpers', () => {
8989
job: '6',
9090
}
9191
expect(generateQuery(queryParams)).toBe(
92-
'branch=testBranch&commit=commitSHA&build=4&build_url=https://ci-providor.local/job/xyz&name=testName&tag=tagV1&slug=testOrg/testRepo&service=testingCI&flags=unit,uploader&pr=2&job=6',
92+
'branch=testBranch&commit=commitSHA&build=4&build_url=https%3A%2F%2Fci-providor.local%2Fjob%2Fxyz&name=testName&tag=tagV1&slug=testOrg%2FtestRepo&service=testingCI&flags=unit%2Cuploader&pr=2&job=6',
9393
)
9494
})
9595

@@ -108,7 +108,7 @@ describe('Web Helpers', () => {
108108
job: '6',
109109
}
110110
expect(generateQuery(queryParams)).toBe(
111-
'branch=testBranch&commit=commitSHA&build=4&build_url=https://ci-providor.local/job/xyz&name=testName&tag=tagV1&slug=testOrg/testRepo&service=testingCI&flags=unit,uploader&pr=&job=6',
111+
'branch=testBranch&commit=commitSHA&build=4&build_url=https%3A%2F%2Fci-providor.local%2Fjob%2Fxyz&name=testName&tag=tagV1&slug=testOrg%2FtestRepo&service=testingCI&flags=unit%2Cuploader&pr=&job=6',
112112
)
113113
})
114114

test/providers/provider_appveyorci.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('AppveyorCI Params', () => {
8080
branch: 'main',
8181
build: '1',
8282
buildURL:
83-
'https%3A%2F%2Fappveyor.com%2Fproject%2FtestOrg%2FtestRepo%2Fbuilds%2F2%2Fjob%2F1',
83+
'https://appveyor.com/project/testOrg/testRepo/builds/2/job/1',
8484
commit: 'testingsha',
8585
job: 'testOrg%2FtestRepo%2F3',
8686
pr: 4,

test/providers/provider_azurepipelines.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('Jenkins CI Params', () => {
6464
branch: 'main',
6565
build: '1',
6666
buildURL:
67-
'https%3A%2F%2Fexample.azure.comtestOrg%2F_build%2Fresults%3FbuildId%3D2',
67+
'https://example.azure.comtestOrg/_build/results?buildId=2',
6868
commit: 'testingsha',
6969
job: '2',
7070
pr: 3,
@@ -100,7 +100,7 @@ describe('Jenkins CI Params', () => {
100100
branch: 'main',
101101
build: '1',
102102
buildURL:
103-
'https%3A%2F%2Fexample.azure.comtestOrg%2F_build%2Fresults%3FbuildId%3D2',
103+
'https://example.azure.comtestOrg/_build/results?buildId=2',
104104
commit: 'testingsha',
105105
job: '2',
106106
pr: 3,
@@ -136,7 +136,7 @@ describe('Jenkins CI Params', () => {
136136
branch: 'main',
137137
build: '1',
138138
buildURL:
139-
'https%3A%2F%2Fexample.azure.comtestOrg%2F_build%2Fresults%3FbuildId%3D2',
139+
'https://example.azure.comtestOrg/_build/results?buildId=2',
140140
commit: 'testingmergecommitsha2345678901234567890',
141141
job: '2',
142142
pr: 3,

test/providers/provider_githubactions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('GitHub Actions Params', () => {
6161
branch: 'master',
6262
build: '2',
6363
buildURL:
64-
'https%3A%2F%2Fgithub.com%2FtestOrg%2FtestRepo%2Factions%2Fruns%2F2',
64+
'https://github.com/testOrg/testRepo/actions/runs/2',
6565
commit: 'testingsha',
6666
job: 'testWorkflow',
6767
pr: 0,
@@ -95,7 +95,7 @@ describe('GitHub Actions Params', () => {
9595
branch: 'branch',
9696
build: '2',
9797
buildURL:
98-
'https%3A%2F%2Fgithub.com%2FtestOrg%2FtestRepo%2Factions%2Fruns%2F2',
98+
'https://github.com/testOrg/testRepo/actions/runs/2',
9999
commit: 'testingsha',
100100
job: 'testWorkflow',
101101
pr: 1,
@@ -136,7 +136,7 @@ describe('GitHub Actions Params', () => {
136136
branch: 'branch',
137137
build: '2',
138138
buildURL:
139-
'https%3A%2F%2Fgithub.com%2FtestOrg%2FtestRepo%2Factions%2Fruns%2F2',
139+
'https://github.com/testOrg/testRepo/actions/runs/2',
140140
commit: 'testingmergecommitsha2345678901234567890',
141141
job: 'testWorkflow',
142142
pr: 1,
@@ -177,7 +177,7 @@ describe('GitHub Actions Params', () => {
177177
branch: 'branch',
178178
build: '3',
179179
buildURL:
180-
'https%3A%2F%2Fgithub.com%2FtestOrg%2FtestRepo%2Factions%2Fruns%2F3',
180+
'https://github.com/testOrg/testRepo/actions/runs/3',
181181
commit: 'testsha',
182182
job: '',
183183
pr: 2,
@@ -216,7 +216,7 @@ describe('GitHub Actions Params', () => {
216216
branch: 'branch',
217217
build: '2',
218218
buildURL:
219-
'https%3A%2F%2Fgithub.com%2FtestOrg%2FtestRepo%2Factions%2Fruns%2F2',
219+
'https://github.com/testOrg/testRepo/actions/runs/2',
220220
commit: 'testingsha',
221221
job: 'testWorkflow',
222222
pr: 1,

0 commit comments

Comments
 (0)