-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathprovider_template.ts
154 lines (144 loc) · 4.03 KB
/
provider_template.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import { IServiceParams, UploaderEnvs, UploaderInputs } from '../types'
/**
* Detects if this CI provider is being used
*
* @param {*} envs an object of enviromental variable key/value pairs
* @returns boolean
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function detect(envs: UploaderEnvs): boolean {
return false
}
/**
* Determine the build number, based on args and envs
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
function _getBuild(inputs: UploaderInputs): string {
const { args } = inputs
return args.build || ''
}
/**
* Determine the build URL for use in the Codecov UI
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function _getBuildURL(inputs: UploaderInputs): string {
return ''
}
/**
* Determine the branch of the repository, based on args and envs
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
function _getBranch(inputs: UploaderInputs): string {
const { args } = inputs
try {
return args.branch || ''
} catch (error) {
throw new Error(
`There was an error getting the branch name from git: ${error}`,
)
}
}
/**
* Determine the job number, based on args or envs
*
* @param {*} envs an object of enviromental variable key/value pairs
* @returns {string}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function _getJob(envs: UploaderEnvs): string {
return ''
}
/**
* Determine the PR number, based on args and envs
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function _getPR(inputs: UploaderInputs): string {
const { args } = inputs
try {
return args.pr || ''
} catch (error) {
throw new Error(`There was an error getting the pr number: ${error}`)
}
}
/**
* The CI service name that gets sent to the Codecov uploader as part of the query string
*
* @returns {string}
*/
function _getService(): string {
return ''
}
/**
* The CI Service name that gets displayed when running the uploader
*
* @returns
*/
export function getServiceName(): string {
return ''
}
/**
* Determine the commit SHA that is being uploaded, based on args or envs
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
function _getSHA(inputs: UploaderInputs): string {
const { args } = inputs
try {
return args.sha || ''
} catch (error) {
throw new Error(
`There was an error getting the commit SHA from git: ${error}`,
)
}
}
/**
* Determine the slug (org/repo) based on args or envs
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {string}
*/
function _getSlug(inputs: UploaderInputs): string {
const { args } = inputs
try {
return args.slug || ''
} catch (error) {
throw new Error(`There was an error getting the slug from git: ${error}`)
}
}
/**
* Generates and return the serviceParams object
*
* @param {args: {}, envs: {}} inputs an object of arguments and enviromental variable key/value pairs
* @returns {{ branch: string, build: string, buildURL: string, commit: string, job: string, pr: string, service: string, slug: string }}
*/
export async function getServiceParams(inputs: UploaderInputs): Promise<IServiceParams> {
return {
branch: _getBranch(inputs),
build: _getBuild(inputs),
buildURL: _getBuildURL(inputs),
commit: _getSHA(inputs),
job: _getJob(inputs.envs),
pr: _getPR(inputs),
service: _getService(),
slug: _getSlug(inputs),
}
}
/**
* Returns all the environment variables used by the provider
*
* @returns [{string}]
*/
export function getEnvVarNames(): string[] {
return []
}