Skip to content

Commit 3e26040

Browse files
fix: add docs and copy over dist (#1752)
1 parent 0da7aa6 commit 3e26040

File tree

2 files changed

+77
-65
lines changed

2 files changed

+77
-65
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,22 @@ Codecov's Action supports inputs from the user. These inputs, along with their d
108108

109109
| Input | Description | Required |
110110
| :--- | :--- | :---: |
111+
| `base_sha` | 'The base SHA to select. This is only used in the "pr-base-picking" run command' | Optional
111112
| `binary` | The file location of a pre-downloaded version of the CLI. If specified, integrity checking will be bypassed. | Optional
112113
| `codecov_yml_path` | The location of the codecov.yml file. This is currently ONLY used for automated test selection (https://docs.codecov.com/docs/getting-started-with-ats). Note that for all other cases, the Codecov yaml will need to be located as described here: https://docs.codecov.com/docs/codecov-yaml#can-i-name-the-file-codecovyml | Optional
113114
| `commit_parent` | SHA (with 40 chars) of what should be the parent of this commit. | Optional
114115
| `directory` | Folder to search for coverage files. Default to the current working directory | Optional
115116
| `disable_file_fixes` | Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets). Read more here https://docs.codecov.com/docs/fixing-reports | Optional
116117
| `disable_search` | Disable search for coverage files. This is helpful when specifying what files you want to upload with the files option. | Optional
117118
| `disable_safe_directory` | Disable setting safe directory. Set to true to disable. | Optional
119+
| `disable_telem` | Disable sending telemetry data to Codecov. Set to true to disable. | Optional
118120
| `dry_run` | Don't upload files to Codecov | Optional
119121
| `env_vars` | Environment variables to tag the upload with (e.g. PYTHON \| OS,PYTHON) | Optional
120122
| `exclude` | Comma-separated list of folders to exclude from search. | Optional
121123
| `fail_ci_if_error` | On error, exit with non-zero code | Optional
122124
| `files` | Comma-separated explicit list of files to upload. These will be added to the coverage files found for upload. If you wish to only upload the specified files, please consider using "disable-search" to disable uploading other files. | Optional
123125
| `flags` | Comma-separated list of flags to upload to group coverage metrics. | Optional
126+
| `force` | Only used for empty-upload run command | Optional
124127
| `git_service` | Override the git_service (e.g. github_enterprise) | Optional
125128
| `gcov_args` | Extra arguments to pass to gcov | Optional
126129
| `gcov_executable` | gcov executable to run. Defaults to 'gcov' | Optional
@@ -141,13 +144,15 @@ Codecov's Action supports inputs from the user. These inputs, along with their d
141144
| `report_code` | The code of the report if using local upload. If unsure, leave unset. Read more here https://docs.codecov.com/docs/the-codecov-cli#how-to-use-local-upload | Optional
142145
| `report_type` | The type of file to upload, coverage by default. Possible values are "testing", "coverage". | Optional
143146
| `root_dir` | Root folder from which to consider paths on the network section. Defaults to current working directory. | Optional
147+
| `run_command` | Choose which CLI command to run. Options are "upload-coverage", "empty-upload", "pr-base-picking", "send-notifications". "upload-coverage" is run by default.' | Optional
144148
| `skip_validation` | Skip integrity checking of the CLI. This is NOT recommended. | Optional
145149
| `slug` | [Required when using the org token] Set to the owner/repo slug used instead of the private repo token. Only applicable to some Enterprise users. | Optional
146150
| `swift_project` | Specify the swift project name. Useful for optimization. | Optional
147151
| `token` | Repository Codecov token. Used to authorize report uploads | Optional
148152
| `url` | Set to the Codecov instance URl. Used by Dedicated Enterprise Cloud customers. | Optional
149153
| `use_legacy_upload_endpoint` | Use the legacy upload endpoint. | Optional
150154
| `use_oidc` | Use OIDC instead of token. This will ignore any token supplied | Optional
155+
| `use_pypi` | Use the pypi version of the CLI instead of from cli.codecov.io | Optional
151156
| `verbose` | Enable verbose logging | Optional
152157
| `version` | Which version of the Codecov CLI to use (defaults to 'latest') | Optional
153158
| `working-directory` | Directory in which to execute codecov.sh | Optional

dist/codecov.sh

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
CC_WRAPPER_VERSION="0.0.34"
2+
CC_WRAPPER_VERSION="0.1.0"
33
set +u
44
say() {
55
echo -e "$1"
@@ -47,7 +47,7 @@ say " _____ _
4747
"
4848
CC_VERSION="${CC_VERSION:-latest}"
4949
CC_FAIL_ON_ERROR="${CC_FAIL_ON_ERROR:-false}"
50-
CC_RUN_COMMAND="${CC_RUN_COMMAND:-upload-coverage}"
50+
CC_RUN_CMD="${CC_RUN_CMD:-upload-coverage}"
5151
if [ -n "$CC_BINARY" ];
5252
then
5353
if [ -f "$CC_BINARY" ];
@@ -57,6 +57,13 @@ then
5757
else
5858
exit_if_error "Could not find binary file $CC_BINARY"
5959
fi
60+
elif [ "$CC_USE_PYPI" == "true" ];
61+
then
62+
if ! pip install codecov-cli"$([ "$CC_VERSION" == "latest" ] && echo "" || echo "==$CC_VERSION" )"; then
63+
exit_if_error "Could not install via pypi."
64+
exit
65+
fi
66+
cc_command="codecovcli"
6067
else
6168
if [ -n "$CC_OS" ];
6269
then
@@ -82,16 +89,16 @@ else
8289
cc_url="$cc_url/${CC_VERSION}"
8390
cc_url="$cc_url/${CC_OS}/${cc_filename}"
8491
say "$g ->$x Downloading $b${cc_url}$x"
85-
curl -Os "$cc_url"
92+
curl -O --retry 5 --retry-delay 2 "$cc_url"
8693
say "$g==>$x Finishing downloading $b${CC_OS}:${CC_VERSION}$x"
8794
version_url="https://cli.codecov.io/api/${CC_OS}/${CC_VERSION}"
8895
version=$(curl -s "$version_url" -H "Accept:application/json" | tr \{ '\n' | tr , '\n' | tr \} '\n' | grep "\"version\"" | awk -F'"' '{print $4}' | tail -1)
8996
say " Version: $b$version$x"
9097
say " "
9198
fi
92-
if [ "$CC_SKIP_VALIDATION" = "true" ] || [ -n "$CC_BINARY" ];
99+
if [ "$CC_SKIP_VALIDATION" == "true" ] || [ -n "$CC_BINARY" ] || [ "$CC_USE_PYPI" == "true" ];
93100
then
94-
say "$r==>$x Bypassing validation as requested by user"
101+
say "$r==>$x Bypassing validation..."
95102
else
96103
CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
97104
echo "${CC_PUBLIC_PGP_KEY}" | \
@@ -117,6 +124,7 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
117124
fi
118125
say "$g==>$x CLI integrity verified"
119126
say
127+
chmod +x "$cc_command"
120128
fi
121129
if [ -n "$CC_BINARY_LOCATION" ];
122130
then
@@ -151,101 +159,100 @@ then
151159
token_str+=" -t <redacted>"
152160
token_arg+=( " -t " "$token")
153161
fi
154-
if [ "$CC_RUN_COMMAND" == "upload-coverage" ]; then
155-
cc_run_args=()
162+
if [ "$CC_RUN_CMD" == "upload-coverage" ]; then
163+
cc_args=()
156164
# Args for create commit
157-
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
158-
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
159-
cc_run_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
160-
cc_run_args+=( $(k_arg PR) $(v_arg PR))
161-
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
162-
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
165+
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
166+
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
167+
cc_args+=( $(k_arg PARENT_SHA) $(v_arg PARENT_SHA))
168+
cc_args+=( $(k_arg PR) $(v_arg PR))
169+
cc_args+=( $(k_arg SHA) $(v_arg SHA))
170+
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
163171
# Args for create report
164-
cc_run_args+=( $(k_arg CODE) $(v_arg CODE))
172+
cc_args+=( $(k_arg CODE) $(v_arg CODE))
165173
# Args for do upload
166-
cc_run_args+=( $(k_arg ENV) $(v_arg ENV))
174+
cc_args+=( $(k_arg ENV) $(v_arg ENV))
167175
OLDIFS=$IFS;IFS=,
168-
cc_run_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
169-
cc_run_args+=( $(k_arg BUILD) $(v_arg BUILD))
170-
cc_run_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
171-
cc_run_args+=( $(k_arg DIR) $(v_arg DIR))
172-
cc_run_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) )
173-
cc_run_args+=( $(write_truthy_args CC_DISABLE_SEARCH) )
174-
cc_run_args+=( $(write_truthy_args CC_DRY_RUN) )
176+
cc_args+=( $(k_arg BRANCH) $(v_arg BRANCH))
177+
cc_args+=( $(k_arg BUILD) $(v_arg BUILD))
178+
cc_args+=( $(k_arg BUILD_URL) $(v_arg BUILD_URL))
179+
cc_args+=( $(k_arg DIR) $(v_arg DIR))
180+
cc_args+=( $(write_truthy_args CC_DISABLE_FILE_FIXES) )
181+
cc_args+=( $(write_truthy_args CC_DISABLE_SEARCH) )
182+
cc_args+=( $(write_truthy_args CC_DRY_RUN) )
175183
if [ -n "$CC_EXCLUDES" ];
176184
then
177185
for directory in $CC_EXCLUDES; do
178-
cc_run_args+=( "--exclude" "$directory" )
186+
cc_args+=( "--exclude" "$directory" )
179187
done
180188
fi
181189
if [ -n "$CC_FILES" ];
182190
then
183191
for file in $CC_FILES; do
184-
cc_run_args+=( "--file" "$file" )
192+
cc_args+=( "--file" "$file" )
185193
done
186194
fi
187195
if [ -n "$CC_FLAGS" ];
188196
then
189197
for flag in $CC_FLAGS; do
190-
cc_run_args+=( "--flag" "$flag" )
198+
cc_args+=( "--flag" "$flag" )
191199
done
192200
fi
193-
cc_run_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
194-
cc_run_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
195-
cc_run_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
196-
cc_run_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
197-
cc_run_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
198-
cc_run_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
199-
cc_run_args+=( $(write_truthy_args CC_LEGACY) )
201+
cc_args+=( $(k_arg GCOV_ARGS) $(v_arg GCOV_ARGS))
202+
cc_args+=( $(k_arg GCOV_EXECUTABLE) $(v_arg GCOV_EXECUTABLE))
203+
cc_args+=( $(k_arg GCOV_IGNORE) $(v_arg GCOV_IGNORE))
204+
cc_args+=( $(k_arg GCOV_INCLUDE) $(v_arg GCOV_INCLUDE))
205+
cc_args+=( $(write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
206+
cc_args+=( $(k_arg JOB_CODE) $(v_arg JOB_CODE))
207+
cc_args+=( $(write_truthy_args CC_LEGACY) )
200208
if [ -n "$CC_NAME" ];
201209
then
202-
cc_run_args+=( "--name" "$CC_NAME" )
210+
cc_args+=( "--name" "$CC_NAME" )
203211
fi
204-
cc_run_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
205-
cc_run_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
206-
cc_run_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
212+
cc_args+=( $(k_arg NETWORK_FILTER) $(v_arg NETWORK_FILTER))
213+
cc_args+=( $(k_arg NETWORK_PREFIX) $(v_arg NETWORK_PREFIX))
214+
cc_args+=( $(k_arg NETWORK_ROOT_FOLDER) $(v_arg NETWORK_ROOT_FOLDER))
207215
if [ -n "$CC_PLUGINS" ];
208216
then
209217
for plugin in $CC_PLUGINS; do
210-
cc_run_args+=( "--plugin" "$plugin" )
218+
cc_args+=( "--plugin" "$plugin" )
211219
done
212220
fi
213-
cc_run_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
214-
cc_run_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
221+
cc_args+=( $(k_arg REPORT_TYPE) $(v_arg REPORT_TYPE))
222+
cc_args+=( $(k_arg SWIFT_PROJECT) $(v_arg SWIFT_PROJECT))
215223
IFS=$OLDIFS
216-
elif [ "$CC_RUN_COMMAND" == "empty-upload" ]; then
217-
cc_run_args=()
218-
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
219-
cc_run_args+=( $(write_truthy_args CC_FORCE) )
220-
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
221-
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
222-
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
223-
elif [ "$CC_RUN_COMMAND" == "pr-base-picking" ]; then
224-
cc_run_args=()
225-
cc_run_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
226-
cc_run_args+=( $(k_arg PR) $(v_arg PR))
227-
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
228-
cc_run_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
229-
elif [ "$CC_RUN_COMMAND" == "send-notifications" ]; then
230-
cc_run_args=()
231-
cc_run_args+=( $(k_arg SHA) $(v_arg SHA))
232-
cc_run_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
233-
cc_run_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
234-
cc_run_args+=( $(k_arg SLUG) $(v_arg SLUG))
224+
elif [ "$CC_RUN_CMD" == "empty-upload" ]; then
225+
cc_args=()
226+
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
227+
cc_args+=( $(write_truthy_args CC_FORCE) )
228+
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
229+
cc_args+=( $(k_arg SHA) $(v_arg SHA))
230+
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
231+
elif [ "$CC_RUN_CMD" == "pr-base-picking" ]; then
232+
cc_args=()
233+
cc_args+=( $(k_arg BASE_SHA) $(v_arg BASE_SHA))
234+
cc_args+=( $(k_arg PR) $(v_arg PR))
235+
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
236+
cc_args+=( $(k_arg SERVICE) $(v_arg SERVICE))
237+
elif [ "$CC_RUN_CMD" == "send-notifications" ]; then
238+
cc_args=()
239+
cc_args+=( $(k_arg SHA) $(v_arg SHA))
240+
cc_args+=( $(write_truthy_args CC_FAIL_ON_ERROR) )
241+
cc_args+=( $(k_arg GIT_SERVICE) $(v_arg GIT_SERVICE))
242+
cc_args+=( $(k_arg SLUG) $(v_arg SLUG))
235243
else
236-
exit_if_error "Invalid run command specified: $CC_RUN_COMMAND"
244+
exit_if_error "Invalid run command specified: $CC_RUN_CMD"
237245
exit
238246
fi
239247
unset NODE_OPTIONS
240248
# See https://github.com/codecov/uploader/issues/475
241-
chmod +x "$cc_command"
242-
say "$g==>$x Running $CC_RUN_COMMAND"
243-
say " $b$cc_command $(echo "${cc_cli_args[@]}")$CC_RUN_COMMAND$token_str $(echo "${cc_run_args[@]}")$x"
249+
say "$g==>$x Running $CC_RUN_CMD"
250+
say " $b$cc_command $(echo "${cc_cli_args[@]}")$CC_RUN_CMD$token_str $(echo "${cc_args[@]}")$x"
244251
if ! $cc_command \
245252
${cc_cli_args[*]} \
246-
${CC_RUN_COMMAND} \
253+
${CC_RUN_CMD} \
247254
${token_arg[*]} \
248-
"${cc_run_args[@]}";
255+
"${cc_args[@]}";
249256
then
250-
exit_if_error "Failed to run $CC_RUN_COMMAND"
257+
exit_if_error "Failed to run $CC_RUN_CMD"
251258
fi

0 commit comments

Comments
 (0)