@@ -37,10 +37,11 @@ g="\033[0;32m" # info/debug
37
37
r=" \033[0;31m" # errors
38
38
x=" \033[0m"
39
39
retry=" --retry 5 --retry-delay 2"
40
- CC_WRAPPER_VERSION=" 0.2.4 "
40
+ CC_WRAPPER_VERSION=" 0.2.7 "
41
41
CC_VERSION=" ${CC_VERSION:- latest} "
42
42
CC_FAIL_ON_ERROR=" ${CC_FAIL_ON_ERROR:- false} "
43
43
CC_RUN_CMD=" ${CC_RUN_CMD:- upload-coverage} "
44
+ CC_CLI_TYPE=${CC_CLI_TYPE:- " codecov-cli" }
44
45
say " _____ _
45
46
/ ____| | |
46
47
| | ___ __| | ___ ___ _____ __
@@ -49,22 +50,26 @@ say " _____ _
49
50
\\ _____\\ ___/ \\ __,_|\\ ___|\\ ___\\ ___/ \\ _/
50
51
$r Wrapper-$CC_WRAPPER_VERSION$x
51
52
"
53
+ if [[ " $CC_CLI_TYPE " != " codecov-cli" && " $CC_CLI_TYPE " != " sentry-prevent-cli" ]]; then
54
+ echo " Invalid CC_CLI_TYPE: '$CC_CLI_TYPE '. Must be 'codecov-cli' or 'sentry-prevent-cli'"
55
+ exit 1
56
+ fi
52
57
if [ -n " $CC_BINARY " ];
53
58
then
54
59
if [ -f " $CC_BINARY " ];
55
60
then
56
- c_filename =$CC_BINARY
57
- c_command =$CC_BINARY
61
+ CC_FILENAME =$CC_BINARY
62
+ CC_COMMAND =$CC_BINARY
58
63
else
59
64
exit_if_error " Could not find binary file $CC_BINARY "
60
65
fi
61
66
elif [ " $CC_USE_PYPI " == " true" ];
62
67
then
63
- if ! pip install codecov-cli " $ ( [ " $CC_VERSION " == " latest" ] && echo " " || echo " ==$CC_VERSION " ) " ; then
68
+ if ! pip install " ${CC_CLI_TYPE} $ ( [ " $CC_VERSION " == " latest" ] && echo " " || echo " ==$CC_VERSION " ) " ; then
64
69
exit_if_error " Could not install via pypi."
65
70
exit
66
71
fi
67
- c_command= " codecovcli "
72
+ CC_COMMAND= " ${CC_CLI_TYPE} "
68
73
else
69
74
if [ -n " $CC_OS " ];
70
75
then
80
85
[[ $( arch) == " aarch64" && $family == " linux" ]] && CC_OS+=" -arm64"
81
86
say " $g ==>$x Detected $b ${CC_OS} $x "
82
87
fi
83
- c_filename= " codecov "
84
- [[ $CC_OS == " windows" ]] && c_filename +=" .exe"
85
- c_command =" ./$c_filename "
88
+ CC_FILENAME= " ${CC_CLI_TYPE % -cli} "
89
+ [[ $CC_OS == " windows" ]] && CC_FILENAME +=" .exe"
90
+ CC_COMMAND =" ./$CC_FILENAME "
86
91
[[ $CC_OS == " macos" ]] && \
87
92
! command -v gpg 2>&1 > /dev/null && \
88
93
HOMEBREW_NO_AUTO_UPDATE=1 brew install gpg
89
- c_url =" ${CC_CLI_URL:- https:// cli.codecov.io} "
90
- c_url =" $c_url /${CC_VERSION} "
91
- c_url =" $c_url /${CC_OS} /${c_filename } "
92
- say " $g ->$x Downloading $b ${c_url } $x "
93
- curl -O $retry " $c_url "
94
+ CC_URL =" ${CC_CLI_URL:- https:// cli.codecov.io} "
95
+ CC_URL =" $CC_URL /${CC_VERSION} "
96
+ CC_URL =" $CC_URL /${CC_OS} /${CC_FILENAME } "
97
+ say " $g ->$x Downloading $b ${CC_URL } $x "
98
+ curl -O $retry " $CC_URL "
94
99
say " $g ==>$x Finishing downloading $b ${CC_OS} :${CC_VERSION} $x "
95
100
v_url=" https://cli.codecov.io/api/${CC_OS} /${CC_VERSION} "
96
101
v=$( curl $retry --retry-all-errors -s " $v_url " -H " Accept:application/json" | tr \{ ' \n' | tr , ' \n' | tr \} ' \n' | grep " \" version\" " | awk -F' "' ' {print $4}' | tail -1)
@@ -100,161 +105,165 @@ fi
100
105
if [ " $CC_SKIP_VALIDATION " == " true" ] || [ -n " $CC_BINARY " ] || [ " $CC_USE_PYPI " == " true" ];
101
106
then
102
107
say " $r ==>$x Bypassing validation..."
108
+ if [ " $CC_SKIP_VALIDATION " == " true" ];
109
+ then
110
+ chmod +x " $CC_COMMAND "
111
+ fi
103
112
else
104
- CC_PUBLIC_PGP_KEY=$( curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
105
- echo " ${CC_PUBLIC_PGP_KEY} " | \
113
+ echo " $( curl -s https://keybase.io/codecovsecurity/pgp_keys.asc) " | \
106
114
gpg --no-default-keyring --import
107
115
# One-time step
108
116
say " $g ==>$x Verifying GPG signature integrity"
109
117
sha_url=" https://cli.codecov.io"
110
118
sha_url=" ${sha_url} /${CC_VERSION} /${CC_OS} "
111
- sha_url=" ${sha_url} /${c_filename } .SHA256SUM"
119
+ sha_url=" ${sha_url} /${CC_FILENAME } .SHA256SUM"
112
120
say " $g ->$x Downloading $b ${sha_url} $x "
113
121
say " $g ->$x Downloading $b ${sha_url} .sig$x "
114
122
say " "
115
123
curl -Os $retry --connect-timeout 2 " $sha_url "
116
124
curl -Os $retry --connect-timeout 2 " ${sha_url} .sig"
117
- if ! gpg --verify " ${c_filename } .SHA256SUM.sig" " ${c_filename } .SHA256SUM" ;
125
+ if ! gpg --verify " ${CC_FILENAME } .SHA256SUM.sig" " ${CC_FILENAME } .SHA256SUM" ;
118
126
then
119
127
exit_if_error " Could not verify signature. Please contact Codecov if problem continues"
120
128
fi
121
- if ! (shasum -a 256 -c " ${c_filename } .SHA256SUM" 2> /dev/null || \
122
- sha256sum -c " ${c_filename } .SHA256SUM" );
129
+ if ! (shasum -a 256 -c " ${CC_FILENAME } .SHA256SUM" 2> /dev/null || \
130
+ sha256sum -c " ${CC_FILENAME } .SHA256SUM" );
123
131
then
124
132
exit_if_error " Could not verify SHASUM. Please contact Codecov if problem continues"
125
133
fi
126
134
say " $g ==>$x CLI integrity verified"
127
135
say
128
- chmod +x " $c_command "
136
+ chmod +x " $CC_COMMAND "
129
137
fi
130
138
if [ -n " $CC_BINARY_LOCATION " ];
131
139
then
132
- mkdir -p " $CC_BINARY_LOCATION " && mv " $c_filename " $_
133
- say " $g ==>$x Codecov binary moved to ${CC_BINARY_LOCATION} "
140
+ mkdir -p " $CC_BINARY_LOCATION " && mv " $CC_FILENAME " $_
141
+ say " $g ==>$x ${CC_CLI_TYPE} binary moved to ${CC_BINARY_LOCATION} "
134
142
fi
135
143
if [ " $CC_DOWNLOAD_ONLY " = " true" ];
136
144
then
137
- say " $g ==>$x Codecov download only called. Exiting..."
145
+ say " $g ==>$x ${CC_CLI_TYPE} download only called. Exiting..."
146
+ exit
138
147
fi
139
- c_cli_args =()
140
- c_cli_args +=( $( k_arg AUTO_LOAD_PARAMS_FROM) $( v_arg AUTO_LOAD_PARAMS_FROM) )
141
- c_cli_args +=( $( k_arg ENTERPRISE_URL) $( v_arg ENTERPRISE_URL) )
148
+ CC_CLI_ARGS =()
149
+ CC_CLI_ARGS +=( $( k_arg AUTO_LOAD_PARAMS_FROM) $( v_arg AUTO_LOAD_PARAMS_FROM) )
150
+ CC_CLI_ARGS +=( $( k_arg ENTERPRISE_URL) $( v_arg ENTERPRISE_URL) )
142
151
if [ -n " $CC_YML_PATH " ]
143
152
then
144
- c_cli_args+=( " --codecov-yml-path" )
145
- c_cli_args+=( " $CC_YML_PATH " )
146
- fi
147
- c_cli_args+=( $( write_bool_args CC_DISABLE_TELEM) )
148
- c_cli_args+=( $( write_bool_args CC_VERBOSE) )
149
- if [ -n " $CC_TOKEN_VAR " ];
150
- then
151
- token=" $( eval echo \$ $CC_TOKEN_VAR ) "
152
- else
153
- token=" $( eval echo $CC_TOKEN ) "
154
- fi
155
- say " $g ->$x Token length: ${# token} "
156
- token_str=" "
157
- token_arg=()
158
- if [ -n " $token " ];
159
- then
160
- token_str+=" -t <redacted>"
161
- token_arg+=( " -t " " $token " )
153
+ CC_CLI_ARGS+=( " --codecov-yml-path" )
154
+ CC_CLI_ARGS+=( " $CC_YML_PATH " )
162
155
fi
163
- c_args=()
156
+ CC_CLI_ARGS+=( $( write_bool_args CC_DISABLE_TELEM) )
157
+ CC_CLI_ARGS+=( $( write_bool_args CC_VERBOSE) )
158
+ CC_ARGS=()
164
159
if [ " $CC_RUN_CMD " == " upload-coverage" ]; then
165
160
# Args for create commit
166
- c_args +=( $( write_bool_args CC_FAIL_ON_ERROR) )
167
- c_args +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
168
- c_args +=( $( k_arg PARENT_SHA) $( v_arg PARENT_SHA) )
169
- c_args +=( $( k_arg PR) $( v_arg PR) )
170
- c_args +=( $( k_arg SHA) $( v_arg SHA) )
171
- c_args +=( $( k_arg SLUG) $( v_arg SLUG) )
161
+ CC_ARGS +=( $( write_bool_args CC_FAIL_ON_ERROR) )
162
+ CC_ARGS +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
163
+ CC_ARGS +=( $( k_arg PARENT_SHA) $( v_arg PARENT_SHA) )
164
+ CC_ARGS +=( $( k_arg PR) $( v_arg PR) )
165
+ CC_ARGS +=( $( k_arg SHA) $( v_arg SHA) )
166
+ CC_ARGS +=( $( k_arg SLUG) $( v_arg SLUG) )
172
167
# Args for create report
173
- c_args +=( $( k_arg CODE) $( v_arg CODE) )
168
+ CC_ARGS +=( $( k_arg CODE) $( v_arg CODE) )
174
169
# Args for do upload
175
- c_args +=( $( k_arg ENV) $( v_arg ENV) )
170
+ CC_ARGS +=( $( k_arg ENV) $( v_arg ENV) )
176
171
OLDIFS=$IFS ; IFS=,
177
- c_args +=( $( k_arg BRANCH) $( v_arg BRANCH) )
178
- c_args +=( $( k_arg BUILD) $( v_arg BUILD) )
179
- c_args +=( $( k_arg BUILD_URL) $( v_arg BUILD_URL) )
180
- c_args +=( $( k_arg DIR) $( v_arg DIR) )
181
- c_args +=( $( write_bool_args CC_DISABLE_FILE_FIXES) )
182
- c_args +=( $( write_bool_args CC_DISABLE_SEARCH) )
183
- c_args +=( $( write_bool_args CC_DRY_RUN) )
172
+ CC_ARGS +=( $( k_arg BRANCH) $( v_arg BRANCH) )
173
+ CC_ARGS +=( $( k_arg BUILD) $( v_arg BUILD) )
174
+ CC_ARGS +=( $( k_arg BUILD_URL) $( v_arg BUILD_URL) )
175
+ CC_ARGS +=( $( k_arg DIR) $( v_arg DIR) )
176
+ CC_ARGS +=( $( write_bool_args CC_DISABLE_FILE_FIXES) )
177
+ CC_ARGS +=( $( write_bool_args CC_DISABLE_SEARCH) )
178
+ CC_ARGS +=( $( write_bool_args CC_DRY_RUN) )
184
179
if [ -n " $CC_EXCLUDES " ];
185
180
then
186
181
for directory in $CC_EXCLUDES ; do
187
- c_args +=( " --exclude" " $directory " )
182
+ CC_ARGS +=( " --exclude" " $directory " )
188
183
done
189
184
fi
190
185
if [ -n " $CC_FILES " ];
191
186
then
192
187
for file in $CC_FILES ; do
193
- c_args +=( " --file" " $file " )
188
+ CC_ARGS +=( " --file" " $file " )
194
189
done
195
190
fi
196
191
if [ -n " $CC_FLAGS " ];
197
192
then
198
193
for flag in $CC_FLAGS ; do
199
- c_args +=( " --flag" " $flag " )
194
+ CC_ARGS +=( " --flag" " $flag " )
200
195
done
201
196
fi
202
- c_args +=( $( k_arg GCOV_ARGS) $( v_arg GCOV_ARGS) )
203
- c_args +=( $( k_arg GCOV_EXECUTABLE) $( v_arg GCOV_EXECUTABLE) )
204
- c_args +=( $( k_arg GCOV_IGNORE) $( v_arg GCOV_IGNORE) )
205
- c_args +=( $( k_arg GCOV_INCLUDE) $( v_arg GCOV_INCLUDE) )
206
- c_args +=( $( write_bool_args CC_HANDLE_NO_REPORTS_FOUND) )
207
- c_args +=( $( write_bool_args CC_RECURSE_SUBMODULES) )
208
- c_args +=( $( k_arg JOB_CODE) $( v_arg JOB_CODE) )
209
- c_args +=( $( write_bool_args CC_LEGACY) )
197
+ CC_ARGS +=( $( k_arg GCOV_ARGS) $( v_arg GCOV_ARGS) )
198
+ CC_ARGS +=( $( k_arg GCOV_EXECUTABLE) $( v_arg GCOV_EXECUTABLE) )
199
+ CC_ARGS +=( $( k_arg GCOV_IGNORE) $( v_arg GCOV_IGNORE) )
200
+ CC_ARGS +=( $( k_arg GCOV_INCLUDE) $( v_arg GCOV_INCLUDE) )
201
+ CC_ARGS +=( $( write_bool_args CC_HANDLE_NO_REPORTS_FOUND) )
202
+ CC_ARGS +=( $( write_bool_args CC_RECURSE_SUBMODULES) )
203
+ CC_ARGS +=( $( k_arg JOB_CODE) $( v_arg JOB_CODE) )
204
+ CC_ARGS +=( $( write_bool_args CC_LEGACY) )
210
205
if [ -n " $CC_NAME " ];
211
206
then
212
- c_args +=( " --name" " $CC_NAME " )
207
+ CC_ARGS +=( " --name" " $CC_NAME " )
213
208
fi
214
- c_args +=( $( k_arg NETWORK_FILTER) $( v_arg NETWORK_FILTER) )
215
- c_args +=( $( k_arg NETWORK_PREFIX) $( v_arg NETWORK_PREFIX) )
216
- c_args +=( $( k_arg NETWORK_ROOT_FOLDER) $( v_arg NETWORK_ROOT_FOLDER) )
209
+ CC_ARGS +=( $( k_arg NETWORK_FILTER) $( v_arg NETWORK_FILTER) )
210
+ CC_ARGS +=( $( k_arg NETWORK_PREFIX) $( v_arg NETWORK_PREFIX) )
211
+ CC_ARGS +=( $( k_arg NETWORK_ROOT_FOLDER) $( v_arg NETWORK_ROOT_FOLDER) )
217
212
if [ -n " $CC_PLUGINS " ];
218
213
then
219
214
for plugin in $CC_PLUGINS ; do
220
- c_args +=( " --plugin" " $plugin " )
215
+ CC_ARGS +=( " --plugin" " $plugin " )
221
216
done
222
217
fi
223
- c_args +=( $( k_arg REPORT_TYPE) $( v_arg REPORT_TYPE) )
224
- c_args +=( $( k_arg SWIFT_PROJECT) $( v_arg SWIFT_PROJECT) )
218
+ CC_ARGS +=( $( k_arg REPORT_TYPE) $( v_arg REPORT_TYPE) )
219
+ CC_ARGS +=( $( k_arg SWIFT_PROJECT) $( v_arg SWIFT_PROJECT) )
225
220
IFS=$OLDIFS
226
221
elif [ " $CC_RUN_CMD " == " empty-upload" ]; then
227
- c_args +=( $( k_arg BRANCH) $( v_arg BRANCH) )
228
- c_args +=( $( write_bool_args CC_FAIL_ON_ERROR) )
229
- c_args +=( $( write_bool_args CC_FORCE) )
230
- c_args +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
231
- c_args +=( $( k_arg PARENT_SHA) $( v_arg PARENT_SHA) )
232
- c_args +=( $( k_arg PR) $( v_arg PR) )
233
- c_args +=( $( k_arg SHA) $( v_arg SHA) )
234
- c_args +=( $( k_arg SLUG) $( v_arg SLUG) )
222
+ CC_ARGS +=( $( k_arg BRANCH) $( v_arg BRANCH) )
223
+ CC_ARGS +=( $( write_bool_args CC_FAIL_ON_ERROR) )
224
+ CC_ARGS +=( $( write_bool_args CC_FORCE) )
225
+ CC_ARGS +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
226
+ CC_ARGS +=( $( k_arg PARENT_SHA) $( v_arg PARENT_SHA) )
227
+ CC_ARGS +=( $( k_arg PR) $( v_arg PR) )
228
+ CC_ARGS +=( $( k_arg SHA) $( v_arg SHA) )
229
+ CC_ARGS +=( $( k_arg SLUG) $( v_arg SLUG) )
235
230
elif [ " $CC_RUN_CMD " == " pr-base-picking" ]; then
236
- c_args +=( $( k_arg BASE_SHA) $( v_arg BASE_SHA) )
237
- c_args +=( $( k_arg PR) $( v_arg PR) )
238
- c_args +=( $( k_arg SLUG) $( v_arg SLUG) )
239
- c_args +=( $( k_arg SERVICE) $( v_arg SERVICE) )
231
+ CC_ARGS +=( $( k_arg BASE_SHA) $( v_arg BASE_SHA) )
232
+ CC_ARGS +=( $( k_arg PR) $( v_arg PR) )
233
+ CC_ARGS +=( $( k_arg SLUG) $( v_arg SLUG) )
234
+ CC_ARGS +=( $( k_arg SERVICE) $( v_arg SERVICE) )
240
235
elif [ " $CC_RUN_CMD " == " send-notifications" ]; then
241
- c_args +=( $( k_arg SHA) $( v_arg SHA) )
242
- c_args +=( $( write_bool_args CC_FAIL_ON_ERROR) )
243
- c_args +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
244
- c_args +=( $( k_arg SLUG) $( v_arg SLUG) )
236
+ CC_ARGS +=( $( k_arg SHA) $( v_arg SHA) )
237
+ CC_ARGS +=( $( write_bool_args CC_FAIL_ON_ERROR) )
238
+ CC_ARGS +=( $( k_arg GIT_SERVICE) $( v_arg GIT_SERVICE) )
239
+ CC_ARGS +=( $( k_arg SLUG) $( v_arg SLUG) )
245
240
else
246
241
exit_if_error " Invalid run command specified: $CC_RUN_CMD "
247
242
exit
248
243
fi
249
244
unset NODE_OPTIONS
250
245
# github.com/codecov/uploader/issues/475
246
+ if [ -n " $CC_TOKEN_VAR " ];
247
+ then
248
+ token=" $( eval echo \$ $CC_TOKEN_VAR ) "
249
+ else
250
+ token=" $( eval echo $CC_TOKEN ) "
251
+ fi
252
+ say " $g ->$x Token length: ${# token} "
253
+ token_str=" "
254
+ token_arg=()
255
+ if [ -n " $token " ];
256
+ then
257
+ token_str+=" -t <redacted>"
258
+ token_arg+=( " -t " " $token " )
259
+ fi
251
260
say " $g ==>$x Running $CC_RUN_CMD "
252
- say " $b$c_command $( echo " ${c_cli_args [@]} " ) $CC_RUN_CMD$token_str $( echo " ${c_args [@]} " ) $x "
253
- if ! $c_command \
254
- ${c_cli_args [*]} \
261
+ say " $b$CC_COMMAND $( echo " ${CC_CLI_ARGS [@]} " ) $CC_RUN_CMD$token_str $( echo " ${CC_ARGS [@]} " ) $x "
262
+ if ! $CC_COMMAND \
263
+ ${CC_CLI_ARGS [*]} \
255
264
${CC_RUN_CMD} \
256
265
${token_arg[*]} \
257
- " ${c_args [@]} " ;
266
+ " ${CC_ARGS [@]} " ;
258
267
then
259
268
exit_if_error " Failed to run $CC_RUN_CMD "
260
269
fi
0 commit comments