Skip to content

Commit

Permalink
Add all the bash params
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasrockhu committed Jan 2, 2021
1 parent 5b42a30 commit 8323165
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 213 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 1.2.0

#### Features
- #185 [Placeholder]

#### Fixes
- #185 [Placeholder]

### 1.1.1

#### Fixes
Expand Down
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ steps:
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
file: ./coverage.xml # optional
files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional
name: codecov-umbrella # optional
Expand All @@ -36,16 +35,42 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`,
| Input | Description | Usage |
| :---: | :---: | :---: |
| `token` | Used to authorize coverage report uploads | *Required for private repos* |
| `file` | Path to the coverage report(s) | Optional
| `files` | Comma-separated paths to the coverage report(s) | Optional
| `directory` | Directory to search for coverage reports. | Optional
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
| | |
| `aws_curl_args` | Extra curl arguments to communicate with AWS. | Optional
| `codecov_curl_args` | Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" | Optional
| `commit_parent` | The commit SHA of the parent for which you are uploading coverage. If not present, the parent will be determined using the API of your repository provider. When using the repository provider's API, the parent is determined via finding the closest ancestor to the commit. | Optional
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
| `name` | Custom defined name for the upload | Optional
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
| `functionalities` | Toggle functionalities | Optional
| | `coveragepy` Disable python coverage |
| | `fix` Disable report fixing |
| | `gcov` Disable gcov |
| | `gcovout` Disable gcov output |
| | `html` Enable coverage for HTML files |
| | `network` Disable uploading the file network |
| | `recursesubs` Enable recurse submodules in git projects when searching for source files | |
| | `search` Disable searching for reports |
| | `xcode` Disable xcode processing |
| `gcov path_include` | Paths to include during gcov gathering (as a glob) | Optional
| `gcov_args` | extra arguments to pass to gcov | Optional
| `gcov_executable` | gcov executable to run. Defaults to 'gcov' | Optional
| `gcov_path_exclude` | Paths to ignore during gcov gathering (as a glob) | Optional
| `gcov_prefix` | Prefix filepaths to help resolve path fixing | Optional
| `gcov_root_dir` | Project root directory, also used when preparing gcov | Optional
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
| `name` | Custom defined name for the upload | Optional
| `override_branch` | Specify the branch name | Optional
| `override_build` | Specify the build number | Optional
| `override_commit` | Specify the commit SHA | Optional
| `override_pr` | Specify the pull request number | Optional
| `override_tag` | Specify the git tag | Optional
| `path_to_write_report` | Write upload file to path before uploading | Optional
| `root_dir` | Used when not in git/hg project to identify project root directory | Optional
| `verbose` | Specify whether the Codecov output should be verbose | Optional
| `working-directory` | Directory in which to execute `codecov.sh` | Optional
| `working_directory` | Directory in which to execute `codecov.sh` | Optional
| `xcode_derived_data` | Custom Derived Data Path for Coverage.profdata and gcov processing | Optional
| `xcode_package` | Specify packages to build coverage. Uploader will only build these packages. This can significantly reduces time to build coverage reports. -J 'MyAppName' Will match "MyAppName" and "MyAppNameTests" -J '^ExampleApp$' Will match only "ExampleApp" not "ExampleAppTests" | Optional

Expand Down Expand Up @@ -78,7 +103,6 @@ jobs:
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
files: ./coverage1.xml,./coverage2.xml
directory: ./coverage/reports/
flags: unittests
Expand Down
174 changes: 71 additions & 103 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2519,47 +2519,50 @@ const exec = __webpack_require__(986);
const fs = __webpack_require__(747);
const request = __webpack_require__(335);

let fail_ci;
let verbose;
try {
let isTrue = (variable) => {
const lowercase = variable.toLowerCase();
return (
lowercase === "1" ||
lowercase === "t" ||
lowercase === "true" ||
lowercase === "y" ||
lowercase === "yes"
);
}

const env_vars = core.getInput("env_vars");
const fail_ci = isTrue(core.getInput("fail_ci_if_error"));
const files = core.getInput("files");
const flags = core.getInput("flags");
const functionalities = core.getInput("functionalities");
const name = core.getInput("name");
const search_dir = core.getInput("directory");
const token = core.getInput("token");
const flags = core.getInput("flags");
const file = core.getInput("file");
const files = core.getInput("files");
const env_vars = core.getInput("env_vars");
const dir = core.getInput("directory");
const verbose = isTrue(core.getInput("verbose"));
const working_dir = core.getInput("working_directory");
const write_path = core.getInput("path_to_write_report");
const working_dir = core.getInput("working-directory");
const xcode_derived_data = core.getInput("xcode_derived_data");
const xcode_package = core.getInput("xcode_package");

fail_ci = core.getInput("fail_ci_if_error").toLowerCase();
verbose = core.getInput("verbose").toLowerCase();

if (
fail_ci === "yes" ||
fail_ci === "y" ||
fail_ci === "true" ||
fail_ci === "t" ||
fail_ci === "1"
) {
fail_ci = true;
} else {
fail_ci = false;
}

if (
verbose === "yes" ||
verbose === "y" ||
verbose === "true" ||
verbose === "t" ||
verbose === "1"
) {
verbose = true;
} else {
verbose = false;
}
const commit_parent = core.getInput("commit_parent");
const root_dir = core.getInput("root_dir");
const clean = core.getInput("move_coverage_to_trash");
const gcov_exclude = core.getInput("gcov_path_exclude");
const gcov_include = core.getInput("gcov_path_include");
const gcov_dir = core.getInput("gcov_root_dir");
const gcov_prefix = core.getInput("gcov_prefix");
const gcov_exec = core.getInput("gcov_executable");
const gcov_args = core.getInput("gcov_args");

const override_commit = core.getInput("override_commit");
const override_branch = core.getInput("override_branch");
const override_pr = core.getInput("override_pr");
const override_build = core.getInput("override_build");
const override_tag = core.getInput("override_tag");

const curl_codecov_args = core.getInput("codecov_curl_args");
const curl_aws_args = core.getInput("aws_curl_args");

request({
json: false,
Expand All @@ -2574,7 +2577,10 @@ try {
core.warning(`Codecov warning: ${error.message}`);
}

fs.writeFile("codecov.sh", body, err => {
filepath = working_dir ?
working_dir + "/codecov.sh" : "codecov.sh"

fs.writeFile(filepath, body, err => {
if (err && fail_ci) {
throw err;
} else if (err) {
Expand Down Expand Up @@ -2615,73 +2621,35 @@ try {
}
}

const execArgs = ["codecov.sh"];
execArgs.push("-Q", "github-action");

if (file) {
execArgs.push(
"-f", `${file}`
);
}

if (files) {
files.split(',').forEach(f => {
execArgs.push(
"-f", `${f}`
);
});
}

if (dir) {
execArgs.push(
"-s", `${dir}`
);
}

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

if (fail_ci) {
execArgs.push(
"-Z"
);
}

if (env_vars_arg.length) {
execArgs.push(
"-e", env_vars_arg.join(",")
);
}

if (write_path) {
execArgs.push(
"-q", `${write_path}`
);
}

if (verbose) {
execArgs.push(
"-v"
);
}

if (working_dir) {
options.cwd = working_dir;
}

if (xcode_derived_data) {
execArgs.push(
"-D", `${xcode_derived_data}`
);
}

if (xcode_package) {
execArgs.push(
"-J", `${xcode_package}`
);
}
const execArgs = [filepath];
execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" );

if (clean) { execArgs.push( "-c"); }
if (commit_parent) { execArgs.push( "-N", `${commit_parent}`); }
if (curl_aws_args) { execArgs.push( "-A", `${curl_aws_args}`); }
if (curl_codecov_args) { execArgs.push( "-U", `${curl_codecov_args}`); }
if (env_vars_arg.length) { execArgs.push( "-e", env_vars_arg.join(",")); }
if (fail_ci) { execArgs.push( "-Z"); }
if (files) { files.split(',').forEach(f => { execArgs.push( "-f", `${f}`); }); }
if (functionalities) { functionalities.split(',').forEach(f => { execArgs.push( "-X", `${f}`); }); }
if (gcov_args) { execArgs.push( "-a", `${gcov_args}`); }
if (gcov_dir) { execArgs.push( "-p", `${gcov_dir}`); }
if (gcov_exclude) { execArgs.push( "-g", `${gcov_exclude}`); }
if (gcov_exec) { execArgs.push( "-x", `${gcov_exec}`); }
if (gcov_include) { execArgs.push( "-G", `${gcov_include}`); }
if (gcov_prefix) { execArgs.push( "-k", `${gcov_prefix}`); }
if (override_branch) { execArgs.push( "-B", `${override_branch}`); }
if (override_build) { execArgs.push( "-b", `${override_build}`); }
if (override_commit) { execArgs.push( "-C", `${override_commit}`); }
if (override_pr) { execArgs.push( "-P", `${override_pr}`); }
if (override_tag) { execArgs.push( "-T", `${override_tag}`); }
if (root_dir) { execArgs.push( "-N", `${root_dir}`); }
if (search_dir) { execArgs.push( "-s", `${search_dir}`); }
if (verbose) { execArgs.push( "-v"); }
if (working_dir) { options.cwd = working_dir; }
if (write_path) { execArgs.push( "-q", `${write_path}`); }
if (xcode_derived_data) { execArgs.push( "-D", `${xcode_derived_data}`); }
if (xcode_package) { execArgs.push( "-J", `${xcode_package}`); }

exec.exec("bash", execArgs, options)
.catch(err => {
Expand All @@ -2698,7 +2666,7 @@ try {
});

const unlinkFile = () => {
fs.unlink("codecov.sh", err => {
fs.unlink(filepath, err => {
if (err && fail_ci) {
throw err;
} else if (err) {
Expand Down
1 change: 1 addition & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
npm i --package-lock-only
npm run build
git add dist/index.js
git add package-lock.json

0 comments on commit 8323165

Please sign in to comment.