From 191f7acbf3c0d788d1ec3cc72d695e0ae20d63ce Mon Sep 17 00:00:00 2001 From: Kenneth Tran Date: Thu, 22 Oct 2020 21:00:46 -0700 Subject: [PATCH] Implement passthrough of codecov bash uploader arguments. Slightly optimized code for truthy check for fail_ci_if_error. --- README.md | 7 +++++++ index.js | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a22b6f6..be18095 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/index.js b/index.js index 27e5192..6507a94 100644 --- a/index.js +++ b/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) {