Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Passthrough of Bash Uploader Arguments #156

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Expand Up @@ -26,12 +26,15 @@ 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.

## Arguments

Codecov's Action currently supports five inputs from the user: `token`, `file`, `flags`,`name`, and `fail_ci_if_error`. These inputs, along with their descriptions and usage contexts, are listed in the table below:
Codecov's Action currently supports a number of inputs, along with their descriptions and usage contexts, listed in the table below:

>**Update**: We've removed the `yml` parameter with the latest release of this action. Please put your custom codecov yaml file at the root of the repo because other locations will no longer be supported in the future.

Expand All @@ -47,6 +50,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
| `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

Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -32,6 +32,9 @@ inputs:
verbose:
description: 'Specify whether the Codecov output should be verbose'
required: false
bash_args:
description: 'Extra arguments to pass into the codecov bash script. One argument per line.'
required: false
branding:
color: 'red'
icon: 'umbrella'
Expand Down
41 changes: 25 additions & 16 deletions dist/index.js
Expand Up @@ -2531,19 +2531,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,
Expand Down Expand Up @@ -2620,10 +2612,17 @@ try {
);
}

execArgs.push(
"-n", `${name}`,
"-F", `${flags}`
);
if (name) {
execArgs.push(
"-n", `${name}`
);
}

if (flags) {
execArgs.push(
"-F", `${flags}`
);
}

if (fail_ci) {
execArgs.push(
Expand All @@ -2649,6 +2648,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) {
Expand Down
43 changes: 26 additions & 17 deletions index.js
Expand Up @@ -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();

if (
fail_ci === "yes" ||
fail_ci === "y" ||
fail_ci === "true" ||
fail_ci === "t" ||
fail_ci === "1"
) {
fail_ci = true;
} else {
fail_ci = false;
}
const truthy = ["yes","y","true","t","1"];
fail_ci = truthy.includes(core.getInput("fail_ci_if_error").toLowerCase());

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,
Expand Down Expand Up @@ -104,10 +96,17 @@ try {
);
}

execArgs.push(
"-n", `${name}`,
"-F", `${flags}`
);
if (name) {
execArgs.push(
"-n", `${name}`
);
}

if (flags) {
execArgs.push(
"-F", `${flags}`
);
}

if (fail_ci) {
execArgs.push(
Expand All @@ -133,6 +132,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) {
Expand Down