mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-09 20:47:26 +00:00
Implement passthrough of codecov bash uploader arguments.
Slightly optimized code for truthy check for fail_ci_if_error.
This commit is contained in:
parent
053cb696d1
commit
191f7acbf3
2 changed files with 21 additions and 12 deletions
|
|
@ -26,6 +26,9 @@ steps:
|
|||
name: codecov-umbrella # optional
|
||||
fail_ci_if_error: true # optional (default = false)
|
||||
verbose: true # optional (default = false)
|
||||
bash_args: |
|
||||
-P 123
|
||||
-J "TestApp"
|
||||
```
|
||||
>**Note**: This assumes that you've set your Codecov token inside *Settings > Secrets* as `CODECOV_TOKEN`. If not, you can [get an upload token](https://docs.codecov.io/docs/frequently-asked-questions#section-where-is-the-repository-upload-token-found-) for your specific repo on [codecov.io](https://www.codecov.io). Keep in mind that secrets are *not* available to forks of repositories.
|
||||
|
||||
|
|
@ -47,6 +50,7 @@ Codecov's Action currently supports a number of inputs, along with their descrip
|
|||
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
|
||||
| `path_to_write_report` | Write upload file to path before uploading | Optional
|
||||
| `verbose` | Specify whether the Codecov output should be verbose | Optional
|
||||
| `bash_args` | Extra arguments to pass into the codecov bash script. [List of possible arguments](https://docs.codecov.io/docs/about-the-codecov-bash-uploader#arguments). To add multiple arguments, refer to the example workflows. | Optional
|
||||
|
||||
### Example `workflow.yml` with Codecov Action
|
||||
|
||||
|
|
@ -86,6 +90,9 @@ jobs:
|
|||
fail_ci_if_error: true
|
||||
path_to_write_report: ./coverage/codecov_report.gz
|
||||
verbose: true
|
||||
bash_args: |
|
||||
-J 'TestApp'
|
||||
-P 123
|
||||
```
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
26
index.js
26
index.js
|
|
@ -15,19 +15,11 @@ try {
|
|||
const write_path = core.getInput("path_to_write_report");
|
||||
const verbose = core.getInput("verbose");
|
||||
|
||||
fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
|
||||
const truthy = ["yes","y","true","t","1"];
|
||||
fail_ci = truthy.includes(core.getInput("fail_ci_if_error").toLowerCase());
|
||||
|
||||
if (
|
||||
fail_ci === "yes" ||
|
||||
fail_ci === "y" ||
|
||||
fail_ci === "true" ||
|
||||
fail_ci === "t" ||
|
||||
fail_ci === "1"
|
||||
) {
|
||||
fail_ci = true;
|
||||
} else {
|
||||
fail_ci = false;
|
||||
}
|
||||
const bash_args = core.getInput("bash_args");
|
||||
const bash_args_clean = bash_args.split(/[\n]+/).map(s => s.trim()).filter(i => i !== '');
|
||||
|
||||
request({
|
||||
json: false,
|
||||
|
|
@ -133,6 +125,16 @@ try {
|
|||
);
|
||||
}
|
||||
|
||||
if (bash_args_clean.length) {
|
||||
for(const x of bash_args_clean) {
|
||||
const arg = x.slice(0,2);
|
||||
const val = x.slice(2).trim();
|
||||
execArgs.push(
|
||||
`${arg}`, `${val}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exec.exec("bash", execArgs, options)
|
||||
.catch(err => {
|
||||
if (fail_ci) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue