From 83231650328f11695dfb754ca0f540516f188d27 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 14:03:30 -0500 Subject: [PATCH 01/23] Add all the bash params --- CHANGELOG.md | 8 +++ README.md | 34 +++++++-- dist/index.js | 174 +++++++++++++++++++--------------------------- hooks/pre-commit | 1 + index.js | 174 +++++++++++++++++++--------------------------- package-lock.json | 3 +- 6 files changed, 181 insertions(+), 213 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d416f2ef5..dfb0da808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### 1.2.0 + +#### Features +- #185 [Placeholder] + +#### Fixes +- #185 [Placeholder] + ### 1.1.1 #### Fixes diff --git a/README.md b/README.md index 4025d1308..c523faaff 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 diff --git a/dist/index.js b/dist/index.js index 3677daaab..17a04b07b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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, @@ -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) { @@ -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 => { @@ -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) { diff --git a/hooks/pre-commit b/hooks/pre-commit index ea68e88de..034f5ff65 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -3,3 +3,4 @@ npm i --package-lock-only npm run build git add dist/index.js +git add package-lock.json diff --git a/index.js b/index.js index a17123377..ba4813c4a 100644 --- a/index.js +++ b/index.js @@ -3,47 +3,50 @@ const exec = require("@actions/exec"); const fs = require("fs"); const request = require('requestretry'); -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, @@ -58,7 +61,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) { @@ -99,73 +105,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 => { @@ -182,7 +150,7 @@ try { }); const unlinkFile = () => { - fs.unlink("codecov.sh", err => { + fs.unlink(filepath, err => { if (err && fail_ci) { throw err; } else if (err) { diff --git a/package-lock.json b/package-lock.json index 2b6d6770d..773ae3ea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2351,8 +2351,7 @@ "is-docker": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz", - "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==", - "optional": true + "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==" }, "is-extendable": { "version": "0.1.1", From 25b873867a4d9c029691df2b437b0c7c7ba410cd Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 14:03:30 -0500 Subject: [PATCH 02/23] Add all the bash params --- CHANGELOG.md | 8 ++ README.md | 34 ++++++-- dist/index.js | 174 ++++++++++++++++------------------------ hooks/pre-commit | 1 + index.js | 200 ++++++++++++++++++++-------------------------- package-lock.json | 3 +- 6 files changed, 195 insertions(+), 225 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d416f2ef5..dfb0da808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### 1.2.0 + +#### Features +- #185 [Placeholder] + +#### Fixes +- #185 [Placeholder] + ### 1.1.1 #### Fixes diff --git a/README.md b/README.md index 4025d1308..c523faaff 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 diff --git a/dist/index.js b/dist/index.js index 3677daaab..17a04b07b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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, @@ -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) { @@ -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 => { @@ -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) { diff --git a/hooks/pre-commit b/hooks/pre-commit index ea68e88de..034f5ff65 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -3,3 +3,4 @@ npm i --package-lock-only npm run build git add dist/index.js +git add package-lock.json diff --git a/index.js b/index.js index a17123377..1455ebb97 100644 --- a/index.js +++ b/index.js @@ -3,48 +3,97 @@ const exec = require("@actions/exec"); const fs = require("fs"); const request = require('requestretry'); -let fail_ci; -let verbose; -try { - const name = core.getInput("name"); - const token = core.getInput("token"); - const flags = core.getInput("flags"); +let isTrue = (variable) => { + const lowercase = variable.toLowerCase(); + return ( + lowercase === "1" || + lowercase === "t" || + lowercase === "true" || + lowercase === "y" || + lowercase === "yes" + ); +} + +let buildExec = () => { + const clean = core.getInput("move_coverage_to_trash"); + const commit_parent = core.getInput("commit_parent"); + const curl_aws_args = core.getInput("aws_curl_args"); + const curl_codecov_args = core.getInput("codecov_curl_args"); + const env_vars = core.getInput("env_vars"); + const fail_ci = isTrue(core.getInput("fail_ci_if_error")); const file = core.getInput("file"); const files = core.getInput("files"); - const env_vars = core.getInput("env_vars"); - const dir = core.getInput("directory"); + const flags = core.getInput("flags"); + const functionalities = core.getInput("functionalities"); + const gcov_args = core.getInput("gcov_args"); + const gcov_dir = core.getInput("gcov_root_dir"); + const gcov_exclude = core.getInput("gcov_path_exclude"); + const gcov_exec = core.getInput("gcov_executable"); + const gcov_include = core.getInput("gcov_path_include"); + const gcov_prefix = core.getInput("gcov_prefix"); + const name = core.getInput("name"); + const override_branch = core.getInput("override_branch"); + const override_build = core.getInput("override_build"); + const override_commit = core.getInput("override_commit"); + const override_pr = core.getInput("override_pr"); + const override_tag = core.getInput("override_tag"); + const root_dir = core.getInput("root_dir"); + const search_dir = core.getInput("directory"); + const token = core.getInput("token"); + 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(); + const filepath = working_dir ? + working_dir + "/codecov.sh" : "codecov.sh" - if ( - fail_ci === "yes" || - fail_ci === "y" || - fail_ci === "true" || - fail_ci === "t" || - fail_ci === "1" - ) { - fail_ci = true; - } else { - fail_ci = false; - } + const execArgs = [filepath]; + execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); - if ( - verbose === "yes" || - verbose === "y" || - verbose === "true" || - verbose === "t" || - verbose === "1" - ) { - verbose = true; - } else { - verbose = false; + const env_vars_arg = [] + for (let env_var of env_vars.split(",")) { + let env_var_clean = env_var.trim(); + if (env_var_clean) { + options.env[env_var_clean] = process.env[env_var_clean]; + env_vars_arg.push(env_var_clean) + } } + if (token) { options.env.CODECOV_TOKEN = token } + 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 (file) { execArgs.push("-f", `${file}`); } + 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}`); } + + return execArgs, filepath, fail_ci; +} + +try { request({ json: false, maxAttempts: 10, @@ -52,13 +101,15 @@ try { url: "https://codecov.io/bash" }, (error, response, body) => { try { + const execArgs, filepath, fail_ci = buildExec(); + if (error && fail_ci) { throw error; } else if (error) { core.warning(`Codecov warning: ${error.message}`); } - fs.writeFile("codecov.sh", body, err => { + fs.writeFile(filepath, body, err => { if (err && fail_ci) { throw err; } else if (err) { @@ -86,87 +137,6 @@ try { GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' }); - if(token){ - options.env.CODECOV_TOKEN = token - } - - const env_vars_arg = [] - for (let env_var of env_vars.split(",")) { - let env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean) - } - } - - 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}` - ); - } - exec.exec("bash", execArgs, options) .catch(err => { if (fail_ci) { @@ -182,7 +152,7 @@ try { }); const unlinkFile = () => { - fs.unlink("codecov.sh", err => { + fs.unlink(filepath, err => { if (err && fail_ci) { throw err; } else if (err) { diff --git a/package-lock.json b/package-lock.json index 2b6d6770d..773ae3ea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2351,8 +2351,7 @@ "is-docker": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz", - "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==", - "optional": true + "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==" }, "is-extendable": { "version": "0.1.1", From 8ad88ccc683e24b31eb4cd47f5ce9bfa6bebe1f8 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 16:54:32 -0500 Subject: [PATCH 03/23] Console --- dist/index.js | 1 + index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/index.js b/dist/index.js index 388515fdd..213686e97 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2606,6 +2606,7 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } + console.log(execArgs); return execArgs, filepath, fail_ci; } diff --git a/index.js b/index.js index 3fd43560a..1e025641e 100644 --- a/index.js +++ b/index.js @@ -90,6 +90,7 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } + console.log(execArgs); return execArgs, filepath, fail_ci; } From d9d5217980a69e5c8cf262a36fb78062fc669b72 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 16:56:42 -0500 Subject: [PATCH 04/23] more console --- dist/index.js | 4 +++- index.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 213686e97..ebd31b20c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2606,7 +2606,6 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } - console.log(execArgs); return execArgs, filepath, fail_ci; } @@ -2620,6 +2619,9 @@ try { try { let execArgs, filepath, fail_ci = buildExec(); + console.log(execArgs); + console.log(filepath); + if (error && fail_ci) { throw error; } else if (error) { diff --git a/index.js b/index.js index 1e025641e..814ff17eb 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,6 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } - console.log(execArgs); return execArgs, filepath, fail_ci; } @@ -104,6 +103,9 @@ try { try { let execArgs, filepath, fail_ci = buildExec(); + console.log(execArgs); + console.log(filepath); + if (error && fail_ci) { throw error; } else if (error) { From 56353bc0f0f620a913a81f6236229dc529c7047f Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 17:02:54 -0500 Subject: [PATCH 05/23] js is hard --- dist/index.js | 4 ++-- index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index ebd31b20c..27fdb0f47 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2606,7 +2606,7 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } - return execArgs, filepath, fail_ci; + return { execArgs, filepath, fail_ci }; } try { @@ -2617,7 +2617,7 @@ try { url: "https://codecov.io/bash" }, (error, response, body) => { try { - let execArgs, filepath, fail_ci = buildExec(); + let { execArgs, filepath, fail_ci } = buildExec(); console.log(execArgs); console.log(filepath); diff --git a/index.js b/index.js index 814ff17eb..4b507879d 100644 --- a/index.js +++ b/index.js @@ -90,7 +90,7 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } - return execArgs, filepath, fail_ci; + return { execArgs, filepath, fail_ci }; } try { @@ -101,7 +101,7 @@ try { url: "https://codecov.io/bash" }, (error, response, body) => { try { - let execArgs, filepath, fail_ci = buildExec(); + let { execArgs, filepath, fail_ci } = buildExec(); console.log(execArgs); console.log(filepath); From c0466185ef6cffbf9568d9d4c1c25c9f3c0ff219 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 17:50:17 -0500 Subject: [PATCH 06/23] Add tests --- dist/index.js | 432 ++++++++++++++++++-------------- package-lock.json | 517 ++++++++++++++++++++++++++++++++++++++- package.json | 10 +- src/index.test.ts | 8 + index.js => src/index.ts | 32 +-- tsconfig.json | 5 + 6 files changed, 791 insertions(+), 213 deletions(-) create mode 100644 src/index.test.ts rename index.js => src/index.ts (91%) create mode 100644 tsconfig.json diff --git a/dist/index.js b/dist/index.js index 27fdb0f47..4d8d936fd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -40,7 +40,7 @@ module.exports = /******/ // the startup function /******/ function startup() { /******/ // Load entry module and return exports -/******/ return __webpack_require__(104); +/******/ return __webpack_require__(325); /******/ }; /******/ // initialize runtime /******/ runtime(__webpack_require__); @@ -2511,191 +2511,7 @@ exports.issueCommand = issueCommand; /***/ }), /* 103 */, -/* 104 */ -/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { - -const core = __webpack_require__(470); -const exec = __webpack_require__(986); -const fs = __webpack_require__(747); -const request = __webpack_require__(335); - -let isTrue = (variable) => { - const lowercase = variable.toLowerCase(); - return ( - lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes" - ); -} - -let buildExec = () => { - const clean = core.getInput("move_coverage_to_trash"); - const commit_parent = core.getInput("commit_parent"); - const curl_aws_args = core.getInput("aws_curl_args"); - const curl_codecov_args = core.getInput("codecov_curl_args"); - const env_vars = core.getInput("env_vars"); - const fail_ci = isTrue(core.getInput("fail_ci_if_error")); - const file = core.getInput("file"); - const files = core.getInput("files"); - const flags = core.getInput("flags"); - const functionalities = core.getInput("functionalities"); - const gcov_args = core.getInput("gcov_args"); - const gcov_dir = core.getInput("gcov_root_dir"); - const gcov_exclude = core.getInput("gcov_path_exclude"); - const gcov_exec = core.getInput("gcov_executable"); - const gcov_include = core.getInput("gcov_path_include"); - const gcov_prefix = core.getInput("gcov_prefix"); - const name = core.getInput("name"); - const override_branch = core.getInput("override_branch"); - const override_build = core.getInput("override_build"); - const override_commit = core.getInput("override_commit"); - const override_pr = core.getInput("override_pr"); - const override_tag = core.getInput("override_tag"); - const root_dir = core.getInput("root_dir"); - const search_dir = core.getInput("directory"); - const token = core.getInput("token"); - const verbose = isTrue(core.getInput("verbose")); - const working_dir = core.getInput("working_directory"); - const write_path = core.getInput("path_to_write_report"); - const xcode_derived_data = core.getInput("xcode_derived_data"); - const xcode_package = core.getInput("xcode_package"); - - const filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh" - - const execArgs = [filepath]; - execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); - - const env_vars_arg = [] - for (let env_var of env_vars.split(",")) { - let env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean) - } - } - - if (token) { options.env.CODECOV_TOKEN = token } - 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 (file) { execArgs.push("-f", `${file}`); } - 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}`); } - - return { execArgs, filepath, fail_ci }; -} - -try { - request({ - json: false, - maxAttempts: 10, - timeout: 3000, - url: "https://codecov.io/bash" - }, (error, response, body) => { - try { - let { execArgs, filepath, fail_ci } = buildExec(); - - console.log(execArgs); - console.log(filepath); - - if (error && fail_ci) { - throw error; - } else if (error) { - core.warning(`Codecov warning: ${error.message}`); - } - - fs.writeFile(filepath, body, err => { - if (err && fail_ci) { - throw err; - } else if (err) { - core.warning(`Codecov warning: ${err.message}`); - } - - let output = ""; - let execError = ""; - const options = {}; - options.listeners = { - stdout: data => { - output += data.toString(); - }, - stderr: data => { - execError += data.toString(); - } - }; - - options.env = Object.assign(process.env, { - GITHUB_ACTION: process.env.GITHUB_ACTION, - GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, - GITHUB_REF: process.env.GITHUB_REF, - GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, - GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' - }); - - exec.exec("bash", execArgs, options) - .catch(err => { - if (fail_ci) { - core.setFailed( - `Codecov failed with the following error: ${err.message}` - ); - } else { - core.warning(`Codecov warning: ${err.message}`); - } - }) - .then(() => { - unlinkFile(); - }); - - const unlinkFile = () => { - fs.unlink(filepath, err => { - if (err && fail_ci) { - throw err; - } else if (err) { - core.warning(`Codecov warning: ${err.message}`); - } - }); - }; - }); - } catch (error) { - core.setFailed( - `Codecov failed with the following error: ${error.message}` - ); - } - }); -} catch (error) { - if (fail_ci) { - core.setFailed(`Codecov failed with the following error: ${error.message}`); - } else { - core.warning(`Codecov warning: ${error.message}`); - } -} - - -/***/ }), +/* 104 */, /* 105 */, /* 106 */, /* 107 */ @@ -12476,7 +12292,237 @@ module.exports = {"$id":"log.json#","$schema":"http://json-schema.org/draft-06/s /* 322 */, /* 323 */, /* 324 */, -/* 325 */, +/* 325 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +exports.__esModule = true; +exports.buildExec = void 0; +var core = __webpack_require__(470); +var exec = __webpack_require__(986); +var fs = __webpack_require__(747); +var request = __webpack_require__(335); +var isTrue = function (variable) { + var lowercase = variable.toLowerCase(); + return (lowercase === "1" || + lowercase === "t" || + lowercase === "true" || + lowercase === "y" || + lowercase === "yes"); +}; +var buildExec = function () { + var clean = core.getInput("move_coverage_to_trash"); + var commit_parent = core.getInput("commit_parent"); + var curl_aws_args = core.getInput("aws_curl_args"); + var curl_codecov_args = core.getInput("codecov_curl_args"); + var env_vars = core.getInput("env_vars"); + var fail_ci = isTrue(core.getInput("fail_ci_if_error")); + var file = core.getInput("file"); + var files = core.getInput("files"); + var flags = core.getInput("flags"); + var functionalities = core.getInput("functionalities"); + var gcov_args = core.getInput("gcov_args"); + var gcov_dir = core.getInput("gcov_root_dir"); + var gcov_exclude = core.getInput("gcov_path_exclude"); + var gcov_exec = core.getInput("gcov_executable"); + var gcov_include = core.getInput("gcov_path_include"); + var gcov_prefix = core.getInput("gcov_prefix"); + var name = core.getInput("name"); + var override_branch = core.getInput("override_branch"); + var override_build = core.getInput("override_build"); + var override_commit = core.getInput("override_commit"); + var override_pr = core.getInput("override_pr"); + var override_tag = core.getInput("override_tag"); + var root_dir = core.getInput("root_dir"); + var search_dir = core.getInput("directory"); + var token = core.getInput("token"); + var verbose = isTrue(core.getInput("verbose")); + var working_dir = core.getInput("working_directory"); + var write_path = core.getInput("path_to_write_report"); + var xcode_derived_data = core.getInput("xcode_derived_data"); + var xcode_package = core.getInput("xcode_package"); + var filepath = working_dir ? + working_dir + "/codecov.sh" : "codecov.sh"; + var execArgs = [filepath]; + execArgs.push("-n", "" + name, "-F", "" + flags, "-Q", "github-action"); + var options = {}; + options.env = Object.assign(process.env, { + GITHUB_ACTION: process.env.GITHUB_ACTION, + GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, + GITHUB_REF: process.env.GITHUB_REF, + GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, + GITHUB_SHA: process.env.GITHUB_SHA, + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + }); + var env_vars_arg = []; + for (var _i = 0, _a = env_vars.split(","); _i < _a.length; _i++) { + var env_var = _a[_i]; + var env_var_clean = env_var.trim(); + if (env_var_clean) { + options.env[env_var_clean] = process.env[env_var_clean]; + env_vars_arg.push(env_var_clean); + } + } + if (token) { + options.env.CODECOV_TOKEN = token; + } + 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 (file) { + execArgs.push("-f", "" + file); + } + if (files) { + files.split(',').forEach(function (f) { execArgs.push("-f", "" + f); }); + } + if (functionalities) { + functionalities.split(',').forEach(function (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); + } + return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; +}; +exports.buildExec = buildExec; +var fail_ci; +try { + request({ + json: false, + maxAttempts: 10, + timeout: 3000, + url: "https://codecov.io/bash" + }, function (error, response, body) { + var _a = buildExec(), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; + try { + if (error && fail_ci) { + throw error; + } + else if (error) { + core.warning("Codecov warning: " + error.message); + } + fs.writeFile(filepath, body, function (err) { + if (err && fail_ci) { + throw err; + } + else if (err) { + core.warning("Codecov warning: " + err.message); + } + var output = ""; + var execError = ""; + options.listeners = { + stdout: function (data) { + output += data.toString(); + }, + stderr: function (data) { + execError += data.toString(); + } + }; + exec.exec("bash", execArgs, options)["catch"](function (err) { + if (fail_ci) { + core.setFailed("Codecov failed with the following error: " + err.message); + } + else { + core.warning("Codecov warning: " + err.message); + } + }) + .then(function () { + unlinkFile(); + }); + var unlinkFile = function () { + fs.unlink(filepath, function (err) { + if (err && fail_ci) { + throw err; + } + else if (err) { + core.warning("Codecov warning: " + err.message); + } + }); + }; + }); + } + catch (error) { + core.setFailed("Codecov failed with the following error: " + error.message); + } + }); +} +catch (error) { + if (fail_ci) { + core.setFailed("Codecov failed with the following error: " + error.message); + } + else { + core.warning("Codecov warning: " + error.message); + } +} + + +/***/ }), /* 326 */ /***/ (function(module) { @@ -12533,6 +12579,16 @@ function defaultPromiseFactory(resolver) { return when.promise(resolver); } +function _cloneOptions(options) { + const cloned = {}; + for (let key in options) { + if (options.hasOwnProperty(key)) { + cloned[key] = key === 'agent' ? options[key] : _.cloneDeep(options[key]); + } + } + return cloned; +} + /** * It calls the promiseFactory function passing it the resolver for the promise * @@ -12638,7 +12694,7 @@ Request.prototype._tryUntilFail = function () { err.attempts = this.attempts; } - var mustRetry = await Promise.resolve(this.retryStrategy(err, response, body, _.cloneDeep(this.options))); + var mustRetry = await Promise.resolve(this.retryStrategy(err, response, body, _cloneOptions(this.options))); if (_.isObject(mustRetry) && _.has(mustRetry, 'mustRetry')) { if (_.isObject(mustRetry.options)) { this.options = mustRetry.options; //if retryStrategy supposes different request options for retry diff --git a/package-lock.json b/package-lock.json index 773ae3ea5..38e10a9b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "codecov-action", - "version": "1.1.1", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -389,6 +389,53 @@ "minimist": "^1.2.0" } }, + "@eslint/eslintrc": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.2.tgz", + "integrity": "sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "lodash": "^4.17.19", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + } + } + }, "@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1053,6 +1100,12 @@ "acorn-walk": "^7.1.1" } }, + "acorn-jsx": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", + "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", + "dev": true + }, "acorn-walk": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", @@ -1069,6 +1122,12 @@ "uri-js": "^4.2.2" } }, + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, "ansi-escapes": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", @@ -1153,6 +1212,12 @@ "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" }, + "astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1680,6 +1745,15 @@ "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==" }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "domexception": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", @@ -1722,6 +1796,15 @@ "once": "^1.4.0" } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.1" + } + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -1747,11 +1830,242 @@ "source-map": "~0.6.1" } }, + "eslint": { + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.17.0.tgz", + "integrity": "sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@eslint/eslintrc": "^0.2.2", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.2.0", + "esutils": "^2.0.2", + "file-entry-cache": "^6.0.0", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash": "^4.17.19", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "progress": "^2.0.0", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "table": "^6.0.4", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + } + } + }, + "eslint-visitor-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", + "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", + "dev": true + }, + "espree": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", + "dev": true, + "requires": { + "acorn": "^7.4.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^1.3.0" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + } + } + }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, + "esquery": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.3.1.tgz", + "integrity": "sha512-olpvt9QG0vniUBZspVRN6lwB7hOZoTRtT+jzR+tS4ffYx2mzbw+z0XCOk44aaLYKApNX5nMm+E+P6o25ip/DHQ==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true + } + } + }, "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", @@ -1991,6 +2305,15 @@ "bser": "2.1.1" } }, + "file-entry-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.0.tgz", + "integrity": "sha512-fqoO76jZ3ZnYrXLDRxBR1YvOvc0k844kcOg40bgsPrE25LAb/PDqTY+ho64Xh2c8ZXgIKldchCFHczG2UVRcWA==", + "dev": true, + "requires": { + "flat-cache": "^3.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2008,6 +2331,22 @@ "path-exists": "^4.0.0" } }, + "flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "requires": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + } + }, + "flatted": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.0.tgz", + "integrity": "sha512-tW+UkmtNg/jv9CSofAKvgVcO7c2URjhTdW1ZTkcAritblu8tajiYy7YisnIflEwtKssCtOxpnBRoCB7iap0/TA==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -2057,6 +2396,12 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -2106,6 +2451,15 @@ "path-is-absolute": "^1.0.0" } }, + "glob-parent": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, "globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -2119,7 +2473,8 @@ "growly": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", - "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=" + "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=", + "optional": true }, "har-schema": { "version": "2.0.0", @@ -2236,6 +2591,30 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + } + } + }, "import-local": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.2.tgz", @@ -2351,13 +2730,20 @@ "is-docker": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.1.1.tgz", - "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==" + "integrity": "sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw==", + "optional": true }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=" }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -2368,6 +2754,15 @@ "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==" }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -2405,6 +2800,7 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "optional": true, "requires": { "is-docker": "^2.0.0" } @@ -3981,6 +4377,12 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -4222,6 +4624,7 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.1.tgz", "integrity": "sha512-BvEXF+UmsnAfYfoapKM9nGxnP+Wn7P91YfXmrKnfcYCx6VBeoN5Ez5Ogck6I8Bi5k4RlpqRYaw75pAwzX9OphA==", + "optional": true, "requires": { "growly": "^1.3.0", "is-wsl": "^2.2.0", @@ -4235,6 +4638,7 @@ "version": "7.3.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "optional": true, "requires": { "lru-cache": "^6.0.0" } @@ -4242,12 +4646,14 @@ "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "optional": true }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "optional": true, "requires": { "isexe": "^2.0.0" } @@ -4392,6 +4798,15 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.1.0.tgz", @@ -4480,6 +4895,12 @@ "react-is": "^17.0.1" } }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, "prompts": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.0.tgz", @@ -4555,6 +4976,12 @@ "safe-regex": "^1.1.0" } }, + "regexpp": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -4652,6 +5079,12 @@ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -4905,7 +5338,8 @@ "shellwords": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", - "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==" + "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", + "optional": true }, "signal-exit": { "version": "3.0.3", @@ -4922,6 +5356,17 @@ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==" }, + "slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + } + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -5206,6 +5651,12 @@ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, "supports-color": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", @@ -5228,6 +5679,50 @@ "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==" }, + "table": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/table/-/table-6.0.6.tgz", + "integrity": "sha512-OInCtPmDNieVBkVFi6C8RwU2S2H0h8mF3e3TQK4nreaUNCpooQUkI+A/KuEkm5FawfhWIfNqG+qfelVVR+V00g==", + "dev": true, + "requires": { + "ajv": "^7.0.2", + "lodash": "^4.17.20", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.0" + }, + "dependencies": { + "ajv": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.0.3.tgz", + "integrity": "sha512-R50QRlXSxqXcQP5SvKUrw8VZeypvo12i2IX0EeR5PiZ7bEKeHWgzgo264LDadUsCU42lTJVhFikTqJwNeH34gQ==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "lodash": { + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", + "dev": true + } + } + }, "terminal-link": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", @@ -5247,6 +5742,12 @@ "minimatch": "^3.0.4" } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "throat": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/throat/-/throat-5.0.0.tgz", @@ -5461,6 +5962,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" }, + "v8-compile-cache": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", + "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", + "dev": true + }, "v8-to-istanbul": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-7.0.0.tgz", diff --git a/package.json b/package.json index 8716ed26a..e81355799 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "codecov-action", - "version": "1.1.1", + "version": "1.2.0", "description": "Upload coverage reports to Codecov from GitHub Actions", "main": "index.js", "scripts": { "test": "jest --coverage", "test-calculator": "jest --testPathPattern=src/calculator/ --coverage --coverageDirectory=coverage/calculator", "test-index": "jest --testPathPattern=src/index --coverage --coverageDirectory=coverage/index", - "test-all": "yarn run test && yarn run test-calculator && yarn run test-index", - "build": "ncc build index.js" + "test-all": "yarn run test && yarn run test-calculator && yarn run test-index && eslint", + "build": "ncc build src/index.ts" }, "repository": { "type": "git", @@ -35,5 +35,7 @@ "typescript": "^4.1.3", "yarn": "^1.22.10" }, - "devDependencies": {} + "devDependencies": { + "eslint": "^7.17.0" + } } diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 000000000..d89aae349 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,8 @@ +import { buildExec } from "./index"; + +test('no arguments', () => { + let { execArgs, filepath, fail_ci } = buildExec(); + expect(execArgs).toEqual([]); + expect(filepath).toEqual('codecov.sh'); + expect(fail_ci).toBeFalsy(); +}); diff --git a/index.js b/src/index.ts similarity index 91% rename from index.js rename to src/index.ts index 4b507879d..ebfb97597 100644 --- a/index.js +++ b/src/index.ts @@ -52,6 +52,16 @@ let buildExec = () => { const execArgs = [filepath]; execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); + const options:any = {}; + options.env = Object.assign(process.env, { + GITHUB_ACTION: process.env.GITHUB_ACTION, + GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, + GITHUB_REF: process.env.GITHUB_REF, + GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, + GITHUB_SHA: process.env.GITHUB_SHA, + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + }); + const env_vars_arg = [] for (let env_var of env_vars.split(",")) { let env_var_clean = env_var.trim(); @@ -90,9 +100,10 @@ let buildExec = () => { if (xcode_derived_data) { execArgs.push("-D", `${xcode_derived_data}`); } if (xcode_package) { execArgs.push("-J", `${xcode_package}`); } - return { execArgs, filepath, fail_ci }; + return { execArgs, options, filepath, fail_ci }; } +let fail_ci; try { request({ json: false, @@ -100,12 +111,9 @@ try { timeout: 3000, url: "https://codecov.io/bash" }, (error, response, body) => { - try { - let { execArgs, filepath, fail_ci } = buildExec(); - - console.log(execArgs); - console.log(filepath); + let { execArgs, options, filepath, fail_ci } = buildExec(); + try { if (error && fail_ci) { throw error; } else if (error) { @@ -121,7 +129,6 @@ try { let output = ""; let execError = ""; - const options = {}; options.listeners = { stdout: data => { output += data.toString(); @@ -131,15 +138,6 @@ try { } }; - options.env = Object.assign(process.env, { - GITHUB_ACTION: process.env.GITHUB_ACTION, - GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, - GITHUB_REF: process.env.GITHUB_REF, - GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, - GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' - }); - exec.exec("bash", execArgs, options) .catch(err => { if (fail_ci) { @@ -177,3 +175,5 @@ try { core.warning(`Codecov warning: ${error.message}`); } } + +export { buildExec }; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..dbe3a5aba --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,5 @@ +{ + "include": [ + "src" + ] +} From e16afe2276199315214826e6a97172111f8e6975 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 17:53:08 -0500 Subject: [PATCH 07/23] Fix test --- codecov.sh | 1820 +++++++++++++++++++++++++++++++++++++++++++++ src/index.test.ts | 12 +- 2 files changed, 1830 insertions(+), 2 deletions(-) create mode 100644 codecov.sh diff --git a/codecov.sh b/codecov.sh new file mode 100644 index 000000000..f5cef847d --- /dev/null +++ b/codecov.sh @@ -0,0 +1,1820 @@ +#!/usr/bin/env bash + +# Apache License Version 2.0, January 2004 +# https://github.com/codecov/codecov-bash/blob/master/LICENSE + +set -e +o pipefail + +VERSION="20201231-23d4836" + +codecov_flags=( ) +url="https://codecov.io" +env="$CODECOV_ENV" +service="" +token="" +search_in="" +# shellcheck disable=SC2153 +flags="$CODECOV_FLAGS" +exit_with=0 +curlargs="" +curlawsargs="" +dump="0" +clean="0" +curl_s="-s" +name="$CODECOV_NAME" +include_cov="" +exclude_cov="" +ddp="$HOME/Library/Developer/Xcode/DerivedData" +xp="" +files="" +save_to="" +cacert="$CODECOV_CA_BUNDLE" +gcov_ignore="-not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**'" +gcov_include="" + +ft_gcov="1" +ft_coveragepy="1" +ft_fix="1" +ft_search="1" +ft_s3="1" +ft_network="1" +ft_xcodellvm="1" +ft_xcodeplist="0" +ft_gcovout="1" +ft_html="0" + +_git_root=$(git rev-parse --show-toplevel 2>/dev/null || hg root 2>/dev/null || echo "$PWD") +git_root="$_git_root" +remote_addr="" +if [ "$git_root" = "$PWD" ]; +then + git_root="." +fi + +url_o="" +pr_o="" +build_o="" +commit_o="" +search_in_o="" +tag_o="" +branch_o="" +slug_o="" +prefix_o="" +git_ls_files_recurse_submodules_o="" +package="bash" + +commit="$VCS_COMMIT_ID" +branch="$VCS_BRANCH_NAME" +pr="$VCS_PULL_REQUEST" +slug="$VCS_SLUG" +tag="$VCS_TAG" +build_url="$CI_BUILD_URL" +build="$CI_BUILD_ID" +job="$CI_JOB_ID" + +beta_xcode_partials="" + +proj_root="$git_root" +gcov_exe="gcov" +gcov_arg="" + +b="\033[0;36m" +g="\033[0;32m" +r="\033[0;31m" +e="\033[0;90m" +y="\033[0;33m" +x="\033[0m" + +show_help() { +cat << EOF + + Codecov Bash $VERSION + + Global report uploading tool for Codecov + Documentation at https://docs.codecov.io/docs + Contribute at https://github.com/codecov/codecov-bash + + + -h Display this help and exit + -f FILE Target file(s) to upload + + -f "path/to/file" only upload this file + skips searching unless provided patterns below + + -f '!*.bar' ignore all files at pattern *.bar + -f '*.foo' include all files at pattern *.foo + Must use single quotes. + This is non-exclusive, use -s "*.foo" to match specific paths. + + -s DIR Directory to search for coverage reports. + Already searches project root and artifact folders. + -t TOKEN Set the private repository token + (option) set environment variable CODECOV_TOKEN=:uuid + + -t @/path/to/token_file + -t uuid + + -n NAME Custom defined name of the upload. Visible in Codecov UI + + -e ENV Specify environment variables to be included with this build + Also accepting environment variables: CODECOV_ENV=VAR,VAR2 + + -e VAR,VAR2 + + -X feature Toggle functionalities + + -X gcov Disable gcov + -X coveragepy Disable python coverage + -X fix Disable report fixing + -X search Disable searching for reports + -X xcode Disable xcode processing + -X network Disable uploading the file network + -X gcovout Disable gcov output + -X html Enable coverage for HTML files + -X recursesubs Enable recurse submodules in git projects when searching for source files + + -N 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. + + -R root dir Used when not in git/hg project to identify project root directory + -F flag Flag the upload to group coverage metrics + + -F unittests This upload is only unittests + -F integration This upload is only integration tests + -F ui,chrome This upload is Chrome - UI tests + + -c Move discovered coverage reports to the trash + -Z Exit with 1 if not successful. Default will Exit with 0 + + -- xcode -- + -D Custom Derived Data Path for Coverage.profdata and gcov processing + Default '~/Library/Developer/Xcode/DerivedData' + -J 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" + + -- gcov -- + -g GLOB Paths to ignore during gcov gathering + -G GLOB Paths to include during gcov gathering + -p dir Project root directory + Also used when preparing gcov + -k prefix Prefix filepaths to help resolve path fixing: https://github.com/codecov/support/issues/472 + -x gcovexe gcov executable to run. Defaults to 'gcov' + -a gcovargs extra arguments to pass to gcov + + -- Override CI Environment Variables -- + These variables are automatically detected by popular CI providers + + -B branch Specify the branch name + -C sha Specify the commit sha + -P pr Specify the pull request number + -b build Specify the build number + -T tag Specify the git tag + + -- Enterprise -- + -u URL Set the target url for Enterprise customers + Not required when retrieving the bash uploader from your CCE + (option) Set environment variable CODECOV_URL=https://my-hosted-codecov.com + -r SLUG owner/repo slug used instead of the private repo token in Enterprise + (option) set environment variable CODECOV_SLUG=:owner/:repo + (option) set in your codecov.yml "codecov.slug" + -S PATH File path to your cacert.pem file used to verify ssl with Codecov Enterprise (optional) + (option) Set environment variable: CODECOV_CA_BUNDLE="/path/to/ca.pem" + -U curlargs Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" + -A curlargs Extra curl arguments to communicate with AWS. + + -- Debugging -- + -d Don't upload, but dump upload file to stdout + -q PATH Write upload file to path + -K Remove color from the output + -v Verbose mode + +EOF +} + + +say() { + echo -e "$1" +} + + +urlencode() { + echo "$1" | curl -Gso /dev/null -w "%{url_effective}" --data-urlencode @- "" | cut -c 3- | sed -e 's/%0A//' +} + + +swiftcov() { + _dir=$(dirname "$1" | sed 's/\(Build\).*/\1/g') + for _type in app framework xctest + do + find "$_dir" -name "*.$_type" | while read -r f + do + _proj=${f##*/} + _proj=${_proj%."$_type"} + if [ "$2" = "" ] || [ "$(echo "$_proj" | grep -i "$2")" != "" ]; + then + say " $g+$x Building reports for $_proj $_type" + dest=$([ -f "$f/$_proj" ] && echo "$f/$_proj" || echo "$f/Contents/MacOS/$_proj") + # shellcheck disable=SC2001 + _proj_name=$(echo "$_proj" | sed -e 's/[[:space:]]//g') + # shellcheck disable=SC2086 + xcrun llvm-cov show $beta_xcode_partials -instr-profile "$1" "$dest" > "$_proj_name.$_type.coverage.txt" \ + || say " ${r}x>${x} llvm-cov failed to produce results for $dest" + fi + done + done +} + + +# Credits to: https://gist.github.com/pkuczynski/8665367 +parse_yaml() { + local prefix=$2 + local s='[[:space:]]*' w='[a-zA-Z0-9_]*' + local fs + fs=$(echo @|tr @ '\034') + sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | + awk -F"$fs" '{ + indent = length($1)/2; + vname[indent] = $2; + for (i in vname) {if (i > indent) {delete vname[i]}} + if (length($3) > 0) { + vn=""; if (indent > 0) {vn=(vn)(vname[0])("_")} + printf("%s%s%s=\"%s\"\n", "'"$prefix"'",vn, $2, $3); + } + }' +} + + +if [ $# != 0 ]; +then + while getopts "a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:ZN:-" o + do + codecov_flags+=( "$o" ) + case "$o" in + "-") + echo -e "${r}Long options are not supported${x}" + exit 2 + ;; + "?") + ;; + "N") + parent=$OPTARG + ;; + "a") + gcov_arg=$OPTARG + ;; + "A") + curlawsargs="$OPTARG" + ;; + "b") + build_o="$OPTARG" + ;; + "B") + branch_o="$OPTARG" + ;; + "c") + clean="1" + ;; + "C") + commit_o="$OPTARG" + ;; + "d") + dump="1" + ;; + "D") + ddp="$OPTARG" + ;; + "e") + env="$env,$OPTARG" + ;; + "f") + if [ "${OPTARG::1}" = "!" ]; + then + exclude_cov="$exclude_cov -not -path '${OPTARG:1}'" + + elif [[ "$OPTARG" = *"*"* ]]; + then + include_cov="$include_cov -or -name '$OPTARG'" + + else + ft_search=0 + if [ "$files" = "" ]; + then + files="$OPTARG" + else + files="$files +$OPTARG" + fi + fi + ;; + "F") + if [ "$flags" = "" ]; + then + flags="$OPTARG" + else + flags="$flags,$OPTARG" + fi + ;; + "g") + gcov_ignore="$gcov_ignore -not -path '$OPTARG'" + ;; + "G") + gcov_include="$gcov_include -path '$OPTARG'" + ;; + "h") + show_help + exit 0; + ;; + "J") + ft_xcodellvm="1" + ft_xcodeplist="0" + if [ "$xp" = "" ]; + then + xp="$OPTARG" + else + xp="$xp\|$OPTARG" + fi + ;; + "k") + prefix_o=$(echo "$OPTARG" | sed -e 's:^/*::' -e 's:/*$::') + ;; + "K") + b="" + g="" + r="" + e="" + x="" + ;; + "n") + name="$OPTARG" + ;; + "p") + proj_root="$OPTARG" + ;; + "P") + pr_o="$OPTARG" + ;; + "Q") + # this is only meant for Codecov packages to overwrite + package="$OPTARG" + ;; + "q") + save_to="$OPTARG" + ;; + "r") + slug_o="$OPTARG" + ;; + "R") + git_root="$OPTARG" + ;; + "s") + if [ "$search_in_o" = "" ]; + then + search_in_o="$OPTARG" + else + search_in_o="$search_in_o $OPTARG" + fi + ;; + "S") + # shellcheck disable=SC2089 + cacert="--cacert \"$OPTARG\"" + ;; + "t") + if [ "${OPTARG::1}" = "@" ]; + then + token=$(< "${OPTARG:1}" tr -d ' \n') + else + token="$OPTARG" + fi + ;; + "T") + tag_o="$OPTARG" + ;; + "u") + url_o=$(echo "$OPTARG" | sed -e 's/\/$//') + ;; + "U") + curlargs="$OPTARG" + ;; + "v") + set -x + curl_s="" + ;; + "x") + gcov_exe=$OPTARG + ;; + "X") + if [ "$OPTARG" = "gcov" ]; + then + ft_gcov="0" + elif [ "$OPTARG" = "coveragepy" ] || [ "$OPTARG" = "py" ]; + then + ft_coveragepy="0" + elif [ "$OPTARG" = "gcovout" ]; + then + ft_gcovout="0" + elif [ "$OPTARG" = "xcodellvm" ]; + then + ft_xcodellvm="1" + ft_xcodeplist="0" + elif [ "$OPTARG" = "fix" ] || [ "$OPTARG" = "fixes" ]; + then + ft_fix="0" + elif [ "$OPTARG" = "xcode" ]; + then + ft_xcodellvm="0" + ft_xcodeplist="0" + elif [ "$OPTARG" = "search" ]; + then + ft_search="0" + elif [ "$OPTARG" = "xcodepartials" ]; + then + beta_xcode_partials="-use-color" + elif [ "$OPTARG" = "network" ]; + then + ft_network="0" + elif [ "$OPTARG" = "s3" ]; + then + ft_s3="0" + elif [ "$OPTARG" = "html" ]; + then + ft_html="1" + elif [ "$OPTARG" = "recursesubs" ]; + then + git_ls_files_recurse_submodules_o="--recurse-submodules" + fi + ;; + "Z") + exit_with=1 + ;; + *) + echo -e "${r}Unexpected flag not supported${x}" + ;; + esac + done +fi + +say " + _____ _ + / ____| | | +| | ___ __| | ___ ___ _____ __ +| | / _ \\ / _\` |/ _ \\/ __/ _ \\ \\ / / +| |___| (_) | (_| | __/ (_| (_) \\ V / + \\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/ + Bash-$VERSION + +" + +# check for installed tools +# git/hg +if [ -x "$(command -v git)" ]; +then + say "$b==>$x $(git --version) found" +else + say "$y==>$x git not installed, testing for mercurial" + if [ -x "$(command -v hg)" ]; + then + say "$b==>$x $(hg --version) found" + else + say "$r==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences" + fi +fi +# curl +if [ -x "$(command -v curl)" ]; +then + say "$b==>$x $(curl --version)" +else + say "$r==>$x curl not installed. Exiting." + exit ${exit_with}; +fi + +search_in="$proj_root" + +#shellcheck disable=SC2154 +if [ "$JENKINS_URL" != "" ]; +then + say "$e==>$x Jenkins CI detected." + # https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project + # https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables + service="jenkins" + + # shellcheck disable=SC2154 + if [ "$ghprbSourceBranch" != "" ]; + then + branch="$ghprbSourceBranch" + elif [ "$GIT_BRANCH" != "" ]; + then + branch="$GIT_BRANCH" + elif [ "$BRANCH_NAME" != "" ]; + then + branch="$BRANCH_NAME" + fi + + # shellcheck disable=SC2154 + if [ "$ghprbActualCommit" != "" ]; + then + commit="$ghprbActualCommit" + elif [ "$GIT_COMMIT" != "" ]; + then + commit="$GIT_COMMIT" + fi + + # shellcheck disable=SC2154 + if [ "$ghprbPullId" != "" ]; + then + pr="$ghprbPullId" + elif [ "$CHANGE_ID" != "" ]; + then + pr="$CHANGE_ID" + fi + + build="$BUILD_NUMBER" + # shellcheck disable=SC2153 + build_url=$(urlencode "$BUILD_URL") + +elif [ "$CI" = "true" ] && [ "$TRAVIS" = "true" ] && [ "$SHIPPABLE" != "true" ]; +then + say "$e==>$x Travis CI detected." + # https://docs.travis-ci.com/user/environment-variables/ + service="travis" + commit="${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" + build="$TRAVIS_JOB_NUMBER" + pr="$TRAVIS_PULL_REQUEST" + job="$TRAVIS_JOB_ID" + slug="$TRAVIS_REPO_SLUG" + env="$env,TRAVIS_OS_NAME" + tag="$TRAVIS_TAG" + if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]; + then + branch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" + fi + + language=$(compgen -A variable | grep "^TRAVIS_.*_VERSION$" | head -1) + if [ "$language" != "" ]; + then + env="$env,${!language}" + fi + +elif [ "$CODEBUILD_CI" = "true" ]; +then + say "$e==>$x AWS Codebuild detected." + # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html + service="codebuild" + commit="$CODEBUILD_RESOLVED_SOURCE_VERSION" + build="$CODEBUILD_BUILD_ID" + branch="$(echo "$CODEBUILD_WEBHOOK_HEAD_REF" | sed 's/^refs\/heads\///')" + if [ "${CODEBUILD_SOURCE_VERSION/pr}" = "$CODEBUILD_SOURCE_VERSION" ] ; then + pr="false" + else + pr="$(echo "$CODEBUILD_SOURCE_VERSION" | sed 's/^pr\///')" + fi + job="$CODEBUILD_BUILD_ID" + slug="$(echo "$CODEBUILD_SOURCE_REPO_URL" | sed 's/^.*:\/\/[^\/]*\///' | sed 's/\.git$//')" + +elif [ "$CI" = "true" ] && [ "$CI_NAME" = "codeship" ]; +then + say "$e==>$x Codeship CI detected." + # https://www.codeship.io/documentation/continuous-integration/set-environment-variables/ + service="codeship" + branch="$CI_BRANCH" + build="$CI_BUILD_NUMBER" + build_url=$(urlencode "$CI_BUILD_URL") + commit="$CI_COMMIT_ID" + +elif [ -n "$CF_BUILD_URL" ] && [ -n "$CF_BUILD_ID" ]; +then + say "$e==>$x Codefresh CI detected." + # https://docs.codefresh.io/v1.0/docs/variables + service="codefresh" + branch="$CF_BRANCH" + build="$CF_BUILD_ID" + build_url=$(urlencode "$CF_BUILD_URL") + commit="$CF_REVISION" + +elif [ "$TEAMCITY_VERSION" != "" ]; +then + say "$e==>$x TeamCity CI detected." + # https://confluence.jetbrains.com/display/TCD8/Predefined+Build+Parameters + # https://confluence.jetbrains.com/plugins/servlet/mobile#content/view/74847298 + if [ "$TEAMCITY_BUILD_BRANCH" = '' ]; + then + echo " Teamcity does not automatically make build parameters available as environment variables." + echo " Add the following environment parameters to the build configuration" + echo " env.TEAMCITY_BUILD_BRANCH = %teamcity.build.branch%" + echo " env.TEAMCITY_BUILD_ID = %teamcity.build.id%" + echo " env.TEAMCITY_BUILD_URL = %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%" + echo " env.TEAMCITY_BUILD_COMMIT = %system.build.vcs.number%" + echo " env.TEAMCITY_BUILD_REPOSITORY = %vcsroot..url%" + fi + service="teamcity" + branch="$TEAMCITY_BUILD_BRANCH" + build="$TEAMCITY_BUILD_ID" + build_url=$(urlencode "$TEAMCITY_BUILD_URL") + if [ "$TEAMCITY_BUILD_COMMIT" != "" ]; + then + commit="$TEAMCITY_BUILD_COMMIT" + else + commit="$BUILD_VCS_NUMBER" + fi + remote_addr="$TEAMCITY_BUILD_REPOSITORY" + +elif [ "$CI" = "true" ] && [ "$CIRCLECI" = "true" ]; +then + say "$e==>$x Circle CI detected." + # https://circleci.com/docs/environment-variables + service="circleci" + branch="$CIRCLE_BRANCH" + build="$CIRCLE_BUILD_NUM" + job="$CIRCLE_NODE_INDEX" + if [ "$CIRCLE_PROJECT_REPONAME" != "" ]; + then + slug="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" + else + # git@github.com:owner/repo.git + slug="${CIRCLE_REPOSITORY_URL##*:}" + # owner/repo.git + slug="${slug%%.git}" + fi + pr="${CIRCLE_PULL_REQUEST##*/}" + commit="$CIRCLE_SHA1" + search_in="$search_in $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS" + +elif [ "$BUDDYBUILD_BRANCH" != "" ]; +then + say "$e==>$x buddybuild detected" + # http://docs.buddybuild.com/v6/docs/custom-prebuild-and-postbuild-steps + service="buddybuild" + branch="$BUDDYBUILD_BRANCH" + build="$BUDDYBUILD_BUILD_NUMBER" + build_url="https://dashboard.buddybuild.com/public/apps/$BUDDYBUILD_APP_ID/build/$BUDDYBUILD_BUILD_ID" + # BUDDYBUILD_TRIGGERED_BY + if [ "$ddp" = "$HOME/Library/Developer/Xcode/DerivedData" ]; + then + ddp="/private/tmp/sandbox/${BUDDYBUILD_APP_ID}/bbtest" + fi + +elif [ "${bamboo_planRepository_revision}" != "" ]; +then + say "$e==>$x Bamboo detected" + # https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html#Bamboovariables-Build-specificvariables + service="bamboo" + commit="${bamboo_planRepository_revision}" + # shellcheck disable=SC2154 + branch="${bamboo_planRepository_branch}" + # shellcheck disable=SC2154 + build="${bamboo_buildNumber}" + # shellcheck disable=SC2154 + build_url="${bamboo_buildResultsUrl}" + # shellcheck disable=SC2154 + remote_addr="${bamboo_planRepository_repositoryUrl}" + +elif [ "$CI" = "true" ] && [ "$BITRISE_IO" = "true" ]; +then + # http://devcenter.bitrise.io/faq/available-environment-variables/ + say "$e==>$x Bitrise CI detected." + service="bitrise" + branch="$BITRISE_GIT_BRANCH" + build="$BITRISE_BUILD_NUMBER" + build_url=$(urlencode "$BITRISE_BUILD_URL") + pr="$BITRISE_PULL_REQUEST" + if [ "$GIT_CLONE_COMMIT_HASH" != "" ]; + then + commit="$GIT_CLONE_COMMIT_HASH" + fi + +elif [ "$CI" = "true" ] && [ "$SEMAPHORE" = "true" ]; +then + say "$e==>$x Semaphore CI detected." +# https://docs.semaphoreci.com/ci-cd-environment/environment-variables/#semaphore-related + service="semaphore" + branch="$SEMAPHORE_GIT_BRANCH" + build="$SEMAPHORE_WORKFLOW_NUMBER" + job="$SEMAPHORE_JOB_ID" + pr="$PULL_REQUEST_NUMBER" + slug="$SEMAPHORE_REPO_SLUG" + commit="$REVISION" + env="$env,SEMAPHORE_TRIGGER_SOURCE" + +elif [ "$CI" = "true" ] && [ "$BUILDKITE" = "true" ]; +then + say "$e==>$x Buildkite CI detected." + # https://buildkite.com/docs/guides/environment-variables + service="buildkite" + branch="$BUILDKITE_BRANCH" + build="$BUILDKITE_BUILD_NUMBER" + job="$BUILDKITE_JOB_ID" + build_url=$(urlencode "$BUILDKITE_BUILD_URL") + slug="$BUILDKITE_PROJECT_SLUG" + commit="$BUILDKITE_COMMIT" + if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]]; then + pr="$BUILDKITE_PULL_REQUEST" + fi + tag="$BUILDKITE_TAG" + +elif [ "$CI" = "drone" ] || [ "$DRONE" = "true" ]; +then + say "$e==>$x Drone CI detected." + # http://docs.drone.io/env.html + # drone commits are not full shas + service="drone.io" + branch="$DRONE_BRANCH" + build="$DRONE_BUILD_NUMBER" + build_url=$(urlencode "${DRONE_BUILD_LINK}") + pr="$DRONE_PULL_REQUEST" + job="$DRONE_JOB_NUMBER" + tag="$DRONE_TAG" + +elif [ "$CI" = "true" ] && [ "$HEROKU_TEST_RUN_BRANCH" != "" ]; +then + say "$e==>$x Heroku CI detected." + # https://devcenter.heroku.com/articles/heroku-ci#environment-variables + service="heroku" + branch="$HEROKU_TEST_RUN_BRANCH" + build="$HEROKU_TEST_RUN_ID" + commit="$HEROKU_TEST_RUN_COMMIT_VERSION" + +elif [[ "$CI" = "true" || "$CI" = "True" ]] && [[ "$APPVEYOR" = "true" || "$APPVEYOR" = "True" ]]; +then + say "$e==>$x Appveyor CI detected." + # http://www.appveyor.com/docs/environment-variables + service="appveyor" + branch="$APPVEYOR_REPO_BRANCH" + build=$(urlencode "$APPVEYOR_JOB_ID") + pr="$APPVEYOR_PULL_REQUEST_NUMBER" + job="$APPVEYOR_ACCOUNT_NAME%2F$APPVEYOR_PROJECT_SLUG%2F$APPVEYOR_BUILD_VERSION" + slug="$APPVEYOR_REPO_NAME" + commit="$APPVEYOR_REPO_COMMIT" + build_url=$(urlencode "${APPVEYOR_URL}/project/${APPVEYOR_REPO_NAME}/builds/$APPVEYOR_BUILD_ID/job/${APPVEYOR_JOB_ID}") + +elif [ "$CI" = "true" ] && [ "$WERCKER_GIT_BRANCH" != "" ]; +then + say "$e==>$x Wercker CI detected." + # http://devcenter.wercker.com/articles/steps/variables.html + service="wercker" + branch="$WERCKER_GIT_BRANCH" + build="$WERCKER_MAIN_PIPELINE_STARTED" + slug="$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY" + commit="$WERCKER_GIT_COMMIT" + +elif [ "$CI" = "true" ] && [ "$MAGNUM" = "true" ]; +then + say "$e==>$x Magnum CI detected." + # https://magnum-ci.com/docs/environment + service="magnum" + branch="$CI_BRANCH" + build="$CI_BUILD_NUMBER" + commit="$CI_COMMIT" + +elif [ "$SHIPPABLE" = "true" ]; +then + say "$e==>$x Shippable CI detected." + # http://docs.shippable.com/ci_configure/ + service="shippable" + # shellcheck disable=SC2153 + branch=$([ "$HEAD_BRANCH" != "" ] && echo "$HEAD_BRANCH" || echo "$BRANCH") + build="$BUILD_NUMBER" + build_url=$(urlencode "$BUILD_URL") + pr="$PULL_REQUEST" + slug="$REPO_FULL_NAME" + # shellcheck disable=SC2153 + commit="$COMMIT" + +elif [ "$TDDIUM" = "true" ]; +then + say "Solano CI detected." + # http://docs.solanolabs.com/Setup/tddium-set-environment-variables/ + service="solano" + commit="$TDDIUM_CURRENT_COMMIT" + branch="$TDDIUM_CURRENT_BRANCH" + build="$TDDIUM_TID" + pr="$TDDIUM_PR_ID" + +elif [ "$GREENHOUSE" = "true" ]; +then + say "$e==>$x Greenhouse CI detected." + # http://docs.greenhouseci.com/docs/environment-variables-files + service="greenhouse" + branch="$GREENHOUSE_BRANCH" + build="$GREENHOUSE_BUILD_NUMBER" + build_url=$(urlencode "$GREENHOUSE_BUILD_URL") + pr="$GREENHOUSE_PULL_REQUEST" + commit="$GREENHOUSE_COMMIT" + search_in="$search_in $GREENHOUSE_EXPORT_DIR" + +elif [ "$GITLAB_CI" != "" ]; +then + say "$e==>$x GitLab CI detected." + # http://doc.gitlab.com/ce/ci/variables/README.html + service="gitlab" + branch="${CI_BUILD_REF_NAME:-$CI_COMMIT_REF_NAME}" + build="${CI_BUILD_ID:-$CI_JOB_ID}" + remote_addr="${CI_BUILD_REPO:-$CI_REPOSITORY_URL}" + commit="${CI_BUILD_REF:-$CI_COMMIT_SHA}" + slug="${CI_PROJECT_PATH}" + +elif [ "$GITHUB_ACTIONS" != "" ]; +then + say "$e==>$x GitHub Actions detected." + + # https://github.com/features/actions + service="github-actions" + + # https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables + branch="${GITHUB_REF#refs/heads/}" + if [ "$GITHUB_HEAD_REF" != "" ]; + then + # PR refs are in the format: refs/pull/7/merge + pr="${GITHUB_REF#refs/pull/}" + pr="${pr%/merge}" + branch="${GITHUB_HEAD_REF}" + fi + commit="${GITHUB_SHA}" + slug="${GITHUB_REPOSITORY}" + build="${GITHUB_RUN_ID}" + build_url=$(urlencode "http://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}") + job="${GITHUB_WORKFLOW}" + + # actions/checkout runs in detached HEAD + mc= + if [ -n "$pr" ] && [ "$pr" != false ]; + then + mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") + + if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; + then + mc=$(echo "$mc" | cut -d' ' -f2) + say " Fixing merge commit SHA $commit -> $mc" + commit=$mc + elif [[ "$mc" = "" ]]; + then + say "$r-> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0$x" + fi + fi + +elif [ "$SYSTEM_TEAMFOUNDATIONSERVERURI" != "" ]; +then + say "$e==>$x Azure Pipelines detected." + # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts + # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&viewFallbackFrom=vsts&tabs=yaml + service="azure_pipelines" + commit="$BUILD_SOURCEVERSION" + build="$BUILD_BUILDNUMBER" + if [ -z "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" ]; + then + pr="$SYSTEM_PULLREQUEST_PULLREQUESTID" + else + pr="$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" + fi + project="${SYSTEM_TEAMPROJECT}" + server_uri="${SYSTEM_TEAMFOUNDATIONSERVERURI}" + job="${BUILD_BUILDID}" + branch="${BUILD_SOURCEBRANCH#"refs/heads/"}" + build_url=$(urlencode "${SYSTEM_TEAMFOUNDATIONSERVERURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}") + + # azure/pipelines runs in detached HEAD + mc= + if [ -n "$pr" ] && [ "$pr" != false ]; + then + mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") + + if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; + then + mc=$(echo "$mc" | cut -d' ' -f2) + say " Fixing merge commit SHA $commit -> $mc" + commit=$mc + fi + fi + +elif [ "$CI" = "true" ] && [ "$BITBUCKET_BUILD_NUMBER" != "" ]; +then + say "$e==>$x Bitbucket detected." + # https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html + service="bitbucket" + branch="$BITBUCKET_BRANCH" + build="$BITBUCKET_BUILD_NUMBER" + slug="$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG" + job="$BITBUCKET_BUILD_NUMBER" + pr="$BITBUCKET_PR_ID" + commit="$BITBUCKET_COMMIT" + # See https://jira.atlassian.com/browse/BCLOUD-19393 + if [ "${#commit}" = 12 ]; + then + commit=$(git rev-parse "$BITBUCKET_COMMIT") + fi + +elif [ "$CI" = "true" ] && [ "$BUDDY" = "true" ]; +then + say "$e==>$x Buddy CI detected." + # https://buddy.works/docs/pipelines/environment-variables + service="buddy" + branch="$BUDDY_EXECUTION_BRANCH" + build="$BUDDY_EXECUTION_ID" + build_url=$(urlencode "$BUDDY_EXECUTION_URL") + commit="$BUDDY_EXECUTION_REVISION" + pr="$BUDDY_EXECUTION_PULL_REQUEST_NO" + tag="$BUDDY_EXECUTION_TAG" + slug="$BUDDY_REPO_SLUG" + +elif [ "$CIRRUS_CI" != "" ]; +then + say "$e==>$x Cirrus CI detected." + # https://cirrus-ci.org/guide/writing-tasks/#environment-variables + service="cirrus-ci" + slug="$CIRRUS_REPO_FULL_NAME" + branch="$CIRRUS_BRANCH" + pr="$CIRRUS_PR" + commit="$CIRRUS_CHANGE_IN_REPO" + build="$CIRRUS_TASK_ID" + job="$CIRRUS_TASK_NAME" + +elif [ "$DOCKER_REPO" != "" ]; +then + say "$e==>$x Docker detected." + # https://docs.docker.com/docker-cloud/builds/advanced/ + service="docker" + branch="$SOURCE_BRANCH" + commit="$SOURCE_COMMIT" + slug="$DOCKER_REPO" + tag="$CACHE_TAG" + env="$env,IMAGE_NAME" + +else + say "${r}x>${x} No CI provider detected." + say " Testing inside Docker? ${b}http://docs.codecov.io/docs/testing-with-docker${x}" + say " Testing with Tox? ${b}https://docs.codecov.io/docs/python#section-testing-with-tox${x}" + +fi + +say " ${e}project root:${x} $git_root" + +# find branch, commit, repo from git command +if [ "$GIT_BRANCH" != "" ]; +then + branch="$GIT_BRANCH" + +elif [ "$branch" = "" ]; +then + branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || hg branch 2>/dev/null || echo "") + if [ "$branch" = "HEAD" ]; + then + branch="" + fi +fi + +if [ "$commit_o" = "" ]; +then + if [ "$GIT_COMMIT" != "" ]; + then + commit="$GIT_COMMIT" + elif [ "$commit" = "" ]; + then + commit=$(git log -1 --format="%H" 2>/dev/null || hg id -i --debug 2>/dev/null | tr -d '+' || echo "") + fi +else + commit="$commit_o" +fi + +if [ "$CODECOV_TOKEN" != "" ] && [ "$token" = "" ]; +then + say "${e}-->${x} token set from env" + token="$CODECOV_TOKEN" +fi + +if [ "$CODECOV_URL" != "" ] && [ "$url_o" = "" ]; +then + say "${e}-->${x} url set from env" + url_o=$(echo "$CODECOV_URL" | sed -e 's/\/$//') +fi + +if [ "$CODECOV_SLUG" != "" ]; +then + say "${e}-->${x} slug set from env" + slug_o="$CODECOV_SLUG" + +elif [ "$slug" = "" ]; +then + if [ "$remote_addr" = "" ]; + then + remote_addr=$(git config --get remote.origin.url || hg paths default || echo '') + fi + if [ "$remote_addr" != "" ]; + then + if echo "$remote_addr" | grep -q "//"; then + # https + slug=$(echo "$remote_addr" | cut -d / -f 4,5 | sed -e 's/\.git$//') + else + # ssh + slug=$(echo "$remote_addr" | cut -d : -f 2 | sed -e 's/\.git$//') + fi + fi + if [ "$slug" = "/" ]; + then + slug="" + fi +fi + +yaml=$(cd "$git_root" && \ + git ls-files "*codecov.yml" "*codecov.yaml" 2>/dev/null \ + || hg locate "*codecov.yml" "*codecov.yaml" 2>/dev/null \ + || cd "$proj_root" && find . -maxdepth 1 -type f -name '*codecov.y*ml' 2>/dev/null \ + || echo '') +yaml=$(echo "$yaml" | head -1) + +if [ "$yaml" != "" ]; +then + say " ${e}Yaml found at:${x} $yaml" + if [[ "$yaml" != /* ]]; then + # relative path for yaml file given, assume relative to the repo root + yaml="$git_root/$yaml" + fi + config=$(parse_yaml "$yaml" || echo '') + + # TODO validate the yaml here + + if [ "$(echo "$config" | grep 'codecov_token="')" != "" ] && [ "$token" = "" ]; + then + say "${e}-->${x} token set from yaml" + token="$(echo "$config" | grep 'codecov_token="' | sed -e 's/codecov_token="//' | sed -e 's/"\.*//')" + fi + + if [ "$(echo "$config" | grep 'codecov_url="')" != "" ] && [ "$url_o" = "" ]; + then + say "${e}-->${x} url set from yaml" + url_o="$(echo "$config" | grep 'codecov_url="' | sed -e 's/codecov_url="//' | sed -e 's/"\.*//')" + fi + + if [ "$(echo "$config" | grep 'codecov_slug="')" != "" ] && [ "$slug_o" = "" ]; + then + say "${e}-->${x} slug set from yaml" + slug_o="$(echo "$config" | grep 'codecov_slug="' | sed -e 's/codecov_slug="//' | sed -e 's/"\.*//')" + fi +else + say " ${g}Yaml not found, that's ok! Learn more at${x} ${b}http://docs.codecov.io/docs/codecov-yaml${x}" +fi + +if [ "$branch_o" != "" ]; +then + branch=$(urlencode "$branch_o") +else + branch=$(urlencode "$branch") +fi + +if [ "$slug_o" = "" ]; +then + urlencoded_slug=$(urlencode "$slug") +else + urlencoded_slug=$(urlencode "$slug_o") +fi + +query="branch=$branch\ + &commit=$commit\ + &build=$([ "$build_o" = "" ] && echo "$build" || echo "$build_o")\ + &build_url=$build_url\ + &name=$(urlencode "$name")\ + &tag=$([ "$tag_o" = "" ] && echo "$tag" || echo "$tag_o")\ + &slug=$urlencoded_slug\ + &service=$service\ + &flags=$flags\ + &pr=$([ "$pr_o" = "" ] && echo "${pr##\#}" || echo "${pr_o##\#}")\ + &job=$job\ + &cmd_args=$(IFS=,; echo "${codecov_flags[*]}")" + +if [ -n "$project" ] && [ -n "$server_uri" ]; +then + query=$(echo "$query&project=$project&server_uri=$server_uri" | tr -d ' ') +fi + +if [ "$parent" != "" ]; +then + query=$(echo "parent=$parent&$query" | tr -d ' ') +fi + +if [ "$ft_search" = "1" ]; +then + # detect bower comoponents location + bower_components="bower_components" + bower_rc=$(cd "$git_root" && cat .bowerrc 2>/dev/null || echo "") + if [ "$bower_rc" != "" ]; + then + bower_components=$(echo "$bower_rc" | tr -d '\n' | grep '"directory"' | cut -d'"' -f4 | sed -e 's/\/$//') + if [ "$bower_components" = "" ]; + then + bower_components="bower_components" + fi + fi + + # Swift Coverage + if [ "$ft_xcodellvm" = "1" ] && [ -d "$ddp" ]; + then + say "${e}==>${x} Processing Xcode reports via llvm-cov" + say " DerivedData folder: $ddp" + profdata_files=$(find "$ddp" -name '*.profdata' 2>/dev/null || echo '') + if [ "$profdata_files" != "" ]; + then + # xcode via profdata + if [ "$xp" = "" ]; + then + # xp=$(xcodebuild -showBuildSettings 2>/dev/null | grep -i "^\s*PRODUCT_NAME" | sed -e 's/.*= \(.*\)/\1/') + # say " ${e}->${x} Speed up Xcode processing by adding ${e}-J '$xp'${x}" + say " ${g}hint${x} Speed up Swift processing by using use ${g}-J 'AppName'${x} (regexp accepted)" + say " ${g}hint${x} This will remove Pods/ from your report. Also ${b}https://docs.codecov.io/docs/ignoring-paths${x}" + fi + while read -r profdata; + do + if [ "$profdata" != "" ]; + then + swiftcov "$profdata" "$xp" + fi + done <<< "$profdata_files" + else + say " ${e}->${x} No Swift coverage found" + fi + + # Obj-C Gcov Coverage + if [ "$ft_gcov" = "1" ]; + then + say " ${e}->${x} Running $gcov_exe for Obj-C" + if [ "$ft_gcovout" = "0" ]; + then + # suppress gcov output + bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" >/dev/null 2>&1 || true + else + bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" || true + fi + fi + fi + + if [ "$ft_xcodeplist" = "1" ] && [ -d "$ddp" ]; + then + say "${e}==>${x} Processing Xcode plists" + plists_files=$(find "$ddp" -name '*.xccoverage' 2>/dev/null || echo '') + if [ "$plists_files" != "" ]; + then + while read -r plist; + do + if [ "$plist" != "" ]; + then + say " ${g}Found${x} plist file at $plist" + plutil -convert xml1 -o "$(basename "$plist").plist" -- "$plist" + fi + done <<< "$plists_files" + fi + fi + + # Gcov Coverage + if [ "$ft_gcov" = "1" ]; + then + say "${e}==>${x} Running $gcov_exe in $proj_root ${e}(disable via -X gcov)${x}" + if [ "$ft_gcovout" = "0" ]; + then + # suppress gcov output + bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true + else + bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true + fi + else + say "${e}==>${x} gcov disabled" + fi + + # Python Coverage + if [ "$ft_coveragepy" = "1" ]; + then + if [ ! -f coverage.xml ]; + then + if command -v coverage >/dev/null 2>&1; + then + say "${e}==>${x} Python coveragepy exists ${e}disable via -X coveragepy${x}" + + dotcoverage=$(find "$git_root" -name '.coverage' -or -name '.coverage.*' | head -1 || echo '') + if [ "$dotcoverage" != "" ]; + then + cd "$(dirname "$dotcoverage")" + if [ ! -f .coverage ]; + then + say " ${e}->${x} Running coverage combine" + coverage combine -a + fi + say " ${e}->${x} Running coverage xml" + if [ "$(coverage xml -i)" != "No data to report." ]; + then + files="$files +$PWD/coverage.xml" + else + say " ${r}No data to report.${x}" + fi + cd "$proj_root" + else + say " ${r}No .coverage file found.${x}" + fi + else + say "${e}==>${x} Python coveragepy not found" + fi + fi + else + say "${e}==>${x} Python coveragepy disabled" + fi + + if [ "$search_in_o" != "" ]; + then + # location override + search_in="$search_in_o" + fi + + say "$e==>$x Searching for coverage reports in:" + for _path in $search_in + do + say " ${g}+${x} $_path" + done + + patterns="find $search_in \( \ + -name vendor \ + -or -name htmlcov \ + -or -name virtualenv \ + -or -name js/generated/coverage \ + -or -name .virtualenv \ + -or -name virtualenvs \ + -or -name .virtualenvs \ + -or -name .env \ + -or -name .envs \ + -or -name env \ + -or -name .yarn-cache \ + -or -name envs \ + -or -name .venv \ + -or -name .venvs \ + -or -name venv \ + -or -name venvs \ + -or -name .git \ + -or -name .hg \ + -or -name .tox \ + -or -name __pycache__ \ + -or -name '.egg-info*' \ + -or -name '$bower_components' \ + -or -name node_modules \ + -or -name 'conftest_*.c.gcov' \ + \) -prune -or \ + -type f \( -name '*coverage*.*' \ + -or -name '*.clover' \ + -or -name '*.codecov.*' \ + -or -name '*.gcov' \ + -or -name '*.lcov' \ + -or -name '*.lst' \ + -or -name 'clover.xml' \ + -or -name 'cobertura.xml' \ + -or -name 'codecov.*' \ + -or -name 'cover.out' \ + -or -name 'coverage-final.json' \ + -or -name 'excoveralls.json' \ + -or -name 'gcov.info' \ + -or -name 'jacoco*.xml' \ + -or -name '*Jacoco*.xml' \ + -or -name 'lcov.dat' \ + -or -name 'lcov.info' \ + -or -name 'luacov.report.out' \ + -or -name 'naxsi.info' \ + -or -name 'nosetests.xml' \ + -or -name 'report.xml' \ + $include_cov \) \ + $exclude_cov \ + -not -name '*.am' \ + -not -name '*.bash' \ + -not -name '*.bat' \ + -not -name '*.bw' \ + -not -name '*.cfg' \ + -not -name '*.class' \ + -not -name '*.cmake' \ + -not -name '*.cmake' \ + -not -name '*.conf' \ + -not -name '*.coverage' \ + -not -name '*.cp' \ + -not -name '*.cpp' \ + -not -name '*.crt' \ + -not -name '*.css' \ + -not -name '*.csv' \ + -not -name '*.csv' \ + -not -name '*.data' \ + -not -name '*.db' \ + -not -name '*.dox' \ + -not -name '*.ec' \ + -not -name '*.ec' \ + -not -name '*.egg' \ + -not -name '*.el' \ + -not -name '*.env' \ + -not -name '*.erb' \ + -not -name '*.exe' \ + -not -name '*.ftl' \ + -not -name '*.gif' \ + -not -name '*.gradle' \ + -not -name '*.gz' \ + -not -name '*.h' \ + -not -name '*.html' \ + -not -name '*.in' \ + -not -name '*.jade' \ + -not -name '*.jar*' \ + -not -name '*.jpeg' \ + -not -name '*.jpg' \ + -not -name '*.js' \ + -not -name '*.less' \ + -not -name '*.log' \ + -not -name '*.m4' \ + -not -name '*.mak*' \ + -not -name '*.md' \ + -not -name '*.o' \ + -not -name '*.p12' \ + -not -name '*.pem' \ + -not -name '*.png' \ + -not -name '*.pom*' \ + -not -name '*.profdata' \ + -not -name '*.proto' \ + -not -name '*.ps1' \ + -not -name '*.pth' \ + -not -name '*.py' \ + -not -name '*.pyc' \ + -not -name '*.pyo' \ + -not -name '*.rb' \ + -not -name '*.rsp' \ + -not -name '*.rst' \ + -not -name '*.ru' \ + -not -name '*.sbt' \ + -not -name '*.scss' \ + -not -name '*.scss' \ + -not -name '*.serialized' \ + -not -name '*.sh' \ + -not -name '*.snapshot' \ + -not -name '*.sql' \ + -not -name '*.svg' \ + -not -name '*.tar.tz' \ + -not -name '*.template' \ + -not -name '*.whl' \ + -not -name '*.xcconfig' \ + -not -name '*.xcoverage.*' \ + -not -name '*/classycle/report.xml' \ + -not -name '*codecov.yml' \ + -not -name '*~' \ + -not -name '.*coveragerc' \ + -not -name '.coverage*' \ + -not -name 'coverage-summary.json' \ + -not -name 'createdFiles.lst' \ + -not -name 'fullLocaleNames.lst' \ + -not -name 'include.lst' \ + -not -name 'inputFiles.lst' \ + -not -name 'phpunit-code-coverage.xml' \ + -not -name 'phpunit-coverage.xml' \ + -not -name 'remapInstanbul.coverage*.json' \ + -not -name 'scoverage.measurements.*' \ + -not -name 'test_*_coverage.txt' \ + -not -name 'testrunner-coverage*' \ + -print 2>/dev/null" + files=$(eval "$patterns" || echo '') + +elif [ "$include_cov" != "" ]; +then + files=$(eval "find $search_in -type f \( ${include_cov:5} \)$exclude_cov 2>/dev/null" || echo '') +fi + +num_of_files=$(echo "$files" | wc -l | tr -d ' ') +if [ "$num_of_files" != '' ] && [ "$files" != '' ]; +then + say " ${e}->${x} Found $num_of_files reports" +fi + +# no files found +if [ "$files" = "" ]; +then + say "${r}-->${x} No coverage report found." + say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" + exit ${exit_with}; +fi + +if [ "$ft_network" == "1" ]; +then + say "${e}==>${x} Detecting git/mercurial file structure" + network=$(cd "$git_root" && git ls-files $git_ls_files_recurse_submodules_o 2>/dev/null || hg locate 2>/dev/null || echo "") + if [ "$network" = "" ]; + then + network=$(find "$git_root" \( \ + -name virtualenv \ + -name .virtualenv \ + -name virtualenvs \ + -name .virtualenvs \ + -name '*.png' \ + -name '*.gif' \ + -name '*.jpg' \ + -name '*.jpeg' \ + -name '*.md' \ + -name .env \ + -name .envs \ + -name env \ + -name envs \ + -name .venv \ + -name .venvs \ + -name venv \ + -name venvs \ + -name .git \ + -name .egg-info \ + -name shunit2-2.1.6 \ + -name vendor \ + -name __pycache__ \ + -name node_modules \ + -path "*/$bower_components/*" \ + -path '*/target/delombok/*' \ + -path '*/build/lib/*' \ + -path '*/js/generated/coverage/*' \ + \) -prune -or \ + -type f -print 2>/dev/null || echo '') + fi + + if [ "$prefix_o" != "" ]; + then + network=$(echo "$network" | awk "{print \"$prefix_o/\"\$0}") + fi +fi + +upload_file=$(mktemp /tmp/codecov.XXXXXX) +adjustments_file=$(mktemp /tmp/codecov.adjustments.XXXXXX) + +cleanup() { + rm -f "$upload_file" "$adjustments_file" "$upload_file.gz" +} + +trap cleanup INT ABRT TERM + +if [ "$env" != "" ]; +then + inc_env="" + say "${e}==>${x} Appending build variables" + for varname in $(echo "$env" | tr ',' ' ') + do + if [ "$varname" != "" ]; + then + say " ${g}+${x} $varname" + inc_env="${inc_env}${varname}=$(eval echo "\$${varname}") +" + fi + done + +echo "$inc_env<<<<<< ENV" >> "$upload_file" +fi + +# Append git file list +# write discovered yaml location +echo "$yaml" >> "$upload_file" +if [ "$ft_network" == "1" ]; +then + i="woff|eot|otf" # fonts + i="$i|gif|png|jpg|jpeg|psd" # images + i="$i|ptt|pptx|numbers|pages|md|txt|xlsx|docx|doc|pdf|csv" # docs + i="$i|yml|yaml|.gitignore" # supporting docs + + if [ "$ft_html" != "1" ]; + then + i="$i|html" + fi + + echo "$network" | grep -vwE "($i)$" >> "$upload_file" +fi +echo "<<<<<< network" >> "$upload_file" + +fr=0 +say "${e}==>${x} Reading reports" +while IFS='' read -r file; +do + # read the coverage file + if [ "$(echo "$file" | tr -d ' ')" != '' ]; + then + if [ -f "$file" ]; + then + report_len=$(wc -c < "$file") + if [ "$report_len" -ne 0 ]; + then + say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" + # append to to upload + _filename=$(basename "$file") + if [ "${_filename##*.}" = 'gcov' ]; + then + { + echo "# path=$(echo "$file.reduced" | sed "s|^$git_root/||")"; + # get file name + head -1 "$file"; + } >> "$upload_file" + # 1. remove source code + # 2. remove ending bracket lines + # 3. remove whitespace + # 4. remove contextual lines + # 5. remove function names + awk -F': *' '{print $1":"$2":"}' "$file" \ + | sed '\/: *} *$/d' \ + | sed 's/^ *//' \ + | sed '/^-/d' \ + | sed 's/^function.*/func/' >> "$upload_file" + else + { + echo "# path=${file//^$git_root/||}"; + cat "$file"; + } >> "$upload_file" + fi + echo "<<<<<< EOF" >> "$upload_file" + fr=1 + if [ "$clean" = "1" ]; + then + rm "$file" + fi + else + say " ${r}-${x} Skipping empty file $file" + fi + else + say " ${r}-${x} file not found at $file" + fi + fi +done <<< "$(echo -e "$files")" + +if [ "$fr" = "0" ]; +then + say "${r}-->${x} No coverage data found." + say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" + say " search for your projects language to learn how to collect reports." + exit ${exit_with}; +fi + +if [ "$ft_fix" = "1" ]; +then + say "${e}==>${x} Appending adjustments" + say " ${b}https://docs.codecov.io/docs/fixing-reports${x}" + + empty_line='^[[:space:]]*$' + # // + syntax_comment='^[[:space:]]*//.*' + # /* or */ + syntax_comment_block='^[[:space:]]*(\/\*|\*\/)[[:space:]]*$' + # { or } + syntax_bracket='^[[:space:]]*[\{\}][[:space:]]*(//.*)?$' + # [ or ] + syntax_list='^[[:space:]]*[][][[:space:]]*(//.*)?$' + # func ... { + syntax_go_func='^[[:space:]]*[func].*[\{][[:space:]]*$' + + # shellcheck disable=SC2089 + skip_dirs="-not -path '*/$bower_components/*' \ + -not -path '*/node_modules/*'" + + cut_and_join() { + awk 'BEGIN { FS=":" } + $3 ~ /\/\*/ || $3 ~ /\*\// { print $0 ; next } + $1!=key { if (key!="") print out ; key=$1 ; out=$1":"$2 ; next } + { out=out","$2 } + END { print out }' 2>/dev/null + } + + if echo "$network" | grep -m1 '.kt$' 1>/dev/null; + then + # skip brackets and comments + cd "$git_root" && \ + find . -type f \ + -name '*.kt' \ + -exec \ + grep -nIHE -e "$syntax_bracket" \ + -e "$syntax_comment_block" {} \; \ + | cut_and_join \ + >> "$adjustments_file" \ + || echo '' + + # last line in file + cd "$git_root" && \ + find . -type f \ + -name '*.kt' -exec \ + wc -l {} \; \ + | while read -r l; do echo "EOF: $l"; done \ + 2>/dev/null \ + >> "$adjustments_file" \ + || echo '' + fi + + if echo "$network" | grep -m1 '.go$' 1>/dev/null; + then + # skip empty lines, comments, and brackets + cd "$git_root" && \ + find . -type f \ + -not -path '*/vendor/*' \ + -not -path '*/caches/*' \ + -name '*.go' \ + -exec \ + grep -nIHE \ + -e "$empty_line" \ + -e "$syntax_comment" \ + -e "$syntax_comment_block" \ + -e "$syntax_bracket" \ + -e "$syntax_go_func" \ + {} \; \ + | cut_and_join \ + >> "$adjustments_file" \ + || echo '' + fi + + if echo "$network" | grep -m1 '.dart$' 1>/dev/null; + then + # skip brackets + cd "$git_root" && \ + find . -type f \ + -name '*.dart' \ + -exec \ + grep -nIHE \ + -e "$syntax_bracket" \ + {} \; \ + | cut_and_join \ + >> "$adjustments_file" \ + || echo '' + fi + + if echo "$network" | grep -m1 '.php$' 1>/dev/null; + then + # skip empty lines, comments, and brackets + cd "$git_root" && \ + find . -type f \ + -not -path "*/vendor/*" \ + -name '*.php' \ + -exec \ + grep -nIHE \ + -e "$syntax_list" \ + -e "$syntax_bracket" \ + -e '^[[:space:]]*\);[[:space:]]*(//.*)?$' \ + {} \; \ + | cut_and_join \ + >> "$adjustments_file" \ + || echo '' + fi + + if echo "$network" | grep -m1 '\(.c\.cpp\|.cxx\|.h\|.hpp\|.m\|.swift\|.vala\)$' 1>/dev/null; + then + # skip brackets + # shellcheck disable=SC2086,SC2090 + cd "$git_root" && \ + find . -type f \ + $skip_dirs \ + \( \ + -name '*.c' \ + -or -name '*.cpp' \ + -or -name '*.cxx' \ + -or -name '*.h' \ + -or -name '*.hpp' \ + -or -name '*.m' \ + -or -name '*.swift' \ + -or -name '*.vala' \ + \) -exec \ + grep -nIHE \ + -e "$empty_line" \ + -e "$syntax_bracket" \ + -e '// LCOV_EXCL' \ + {} \; \ + | cut_and_join \ + >> "$adjustments_file" \ + || echo '' + + # skip brackets + # shellcheck disable=SC2086,SC2090 + cd "$git_root" && \ + find . -type f \ + $skip_dirs \ + \( \ + -name '*.c' \ + -or -name '*.cpp' \ + -or -name '*.cxx' \ + -or -name '*.h' \ + -or -name '*.hpp' \ + -or -name '*.m' \ + -or -name '*.swift' \ + -or -name '*.vala' \ + \) -exec \ + grep -nIH '// LCOV_EXCL' \ + {} \; \ + >> "$adjustments_file" \ + || echo '' + + fi + + found=$(< "$adjustments_file" tr -d ' ') + + if [ "$found" != "" ]; + then + say " ${g}+${x} Found adjustments" + { + echo "# path=fixes"; + cat "$adjustments_file"; + echo "<<<<<< EOF"; + } >> "$upload_file" + rm -rf "$adjustments_file" + else + say " ${e}->${x} No adjustments found" + fi +fi + +if [ "$url_o" != "" ]; +then + url="$url_o" +fi + +if [ "$dump" != "0" ]; +then + # trim whitespace from query + say " ${e}->${x} Dumping upload file (no upload)" + echo "$url/upload/v4?$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ')" + cat "$upload_file" +else + if [ "$save_to" != "" ]; + then + say "${e}==>${x} Copying upload file to ${save_to}" + cp "$upload_file" "$save_to" + fi + + say "${e}==>${x} Gzipping contents" + gzip -nf9 "$upload_file" + say " $(du -h "$upload_file.gz")" + + query=$(echo "${query}" | tr -d ' ') + say "${e}==>${x} Uploading reports" + say " ${e}url:${x} $url" + say " ${e}query:${x} $query" + + # Full query without token (to display on terminal output) + queryNoToken=$(echo "package=$package-$VERSION&token=secret&$query" | tr -d ' ') + # now add token to query + query=$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ') + + if [ "$ft_s3" = "1" ]; + then + say "${e}->${x} Pinging Codecov" + say "$url/upload/v4?$queryNoToken" + # shellcheck disable=SC2086,2090 + res=$(curl $curl_s -X POST $cacert \ + --retry 5 --retry-delay 2 --connect-timeout 2 \ + -H 'X-Reduced-Redundancy: false' \ + -H 'X-Content-Type: application/x-gzip' \ + -H 'Content-Length: 0' \ + --write-out "\n%{response_code}\n" \ + $curlargs \ + "$url/upload/v4?$query" || true) + # a good reply is "https://codecov.io" + "\n" + "https://storage.googleapis.com/codecov/..." + s3target=$(echo "$res" | sed -n 2p) + status=$(tail -n1 <<< "$res") + + if [ "$status" = "200" ] && [ "$s3target" != "" ]; + then + say "${e}->${x} Uploading to" + say "${s3target}" + + # shellcheck disable=SC2086 + s3=$(curl -fiX PUT \ + --data-binary @"$upload_file.gz" \ + -H 'Content-Type: application/x-gzip' \ + -H 'Content-Encoding: gzip' \ + $curlawsargs \ + "$s3target" || true) + + if [ "$s3" != "" ]; + then + say " ${g}->${x} View reports at ${b}$(echo "$res" | sed -n 1p)${x}" + exit 0 + else + say " ${r}X>${x} Failed to upload" + fi + elif [ "$status" = "400" ]; + then + # 400 Error + say "${r}${res}${x}" + exit ${exit_with} + else + say "${r}${res}${x}" + fi + fi + + say "${e}==>${x} Uploading to Codecov" + + # shellcheck disable=SC2086,2090 + res=$(curl -X POST $cacert \ + --data-binary @"$upload_file.gz" \ + --retry 5 --retry-delay 2 --connect-timeout 2 \ + -H 'Content-Type: text/plain' \ + -H 'Content-Encoding: gzip' \ + -H 'X-Content-Encoding: gzip' \ + -H 'Accept: text/plain' \ + $curlargs \ + "$url/upload/v2?$query&attempt=$i" || echo 'HTTP 500') + # HTTP 200 + # http://.... + status=$(echo "$res" | head -1 | cut -d' ' -f2) + if [ "$status" = "" ] || [ "$status" = "200" ]; + then + say " View reports at ${b}$(echo "$res" | head -2 | tail -1)${x}" + exit 0 + else + say " ${g}${res}${x}" + exit ${exit_with} + fi + + say " ${r}X> Failed to upload coverage reports${x}" +fi + +exit ${exit_with} diff --git a/src/index.test.ts b/src/index.test.ts index d89aae349..7fe6b809d 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,8 +1,16 @@ import { buildExec } from "./index"; test('no arguments', () => { - let { execArgs, filepath, fail_ci } = buildExec(); - expect(execArgs).toEqual([]); + let { execArgs, options, filepath, fail_ci } = buildExec(); + expect(execArgs).toEqual([ + "codecov.sh", + "-n", + "", + "-F", + "", + "-Q", + "github-action" + ]); expect(filepath).toEqual('codecov.sh'); expect(fail_ci).toBeFalsy(); }); From 7a024964de7a4039096870adfe91627d62e426b5 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:02:41 -0500 Subject: [PATCH 08/23] Update test files --- .github/workflows/main.yml | 13 ++++++------- {src => demo}/calculator/calculator.test.ts | 0 {src => demo}/calculator/calculator.ts | 0 package.json | 5 +++-- src/index/index.test.ts | 11 ----------- src/index/index.ts | 21 --------------------- 6 files changed, 9 insertions(+), 41 deletions(-) rename {src => demo}/calculator/calculator.test.ts (100%) rename {src => demo}/calculator/calculator.ts (100%) delete mode 100644 src/index/index.test.ts delete mode 100644 src/index/index.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3fa50d2d..c22b31eee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,18 +10,17 @@ jobs: run: npm install - name: Run tests and collect coverage run: yarn run test-all - - name: Upload coverage to Codecov + - name: Upload coverage to Codecov (demo) uses: ./ with: - files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json + files: ./coverage/calculator/coverage-final.json,./coverage/coverage/coverage-final.json file: ./coverage/coverage-final.json - flags: unittest + flags: demo name: codecov-1 - - name: Upload coverage to Codecov (verbose) + - name: Upload coverage to Codecov (script) uses: ./ with: - files: ./coverage/calculator/coverage-final.json,./coverage/index/coverage-final.json - file: ./coverage/coverage-final.json - flags: unittest + files: ./coverage/script/coverage-final.json + flags: script name: codecov-1 verbose: true diff --git a/src/calculator/calculator.test.ts b/demo/calculator/calculator.test.ts similarity index 100% rename from src/calculator/calculator.test.ts rename to demo/calculator/calculator.test.ts diff --git a/src/calculator/calculator.ts b/demo/calculator/calculator.ts similarity index 100% rename from src/calculator/calculator.ts rename to demo/calculator/calculator.ts diff --git a/package.json b/package.json index e81355799..dfd10778e 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "main": "index.js", "scripts": { "test": "jest --coverage", - "test-calculator": "jest --testPathPattern=src/calculator/ --coverage --coverageDirectory=coverage/calculator", - "test-index": "jest --testPathPattern=src/index --coverage --coverageDirectory=coverage/index", + "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", + "test-coverage": "jest --testPathPattern=demo/coverage --coverage --coverageDirectory=coverage/coverage", + "test-script": "jest --testPathPattern=src --coverage --coverageDirectory=coverage/script", "test-all": "yarn run test && yarn run test-calculator && yarn run test-index && eslint", "build": "ncc build src/index.ts" }, diff --git a/src/index/index.test.ts b/src/index/index.test.ts deleted file mode 100644 index 24196db36..000000000 --- a/src/index/index.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import Index from "./index"; - -test('test uncovered if', () => { - const indexObj = new Index(); - expect(indexObj.uncovered_if()).toEqual(false); -}); - -test('fully covered', () => { - const indexObj = new Index(); - expect(indexObj.fully_covered()).toEqual(true); -}); diff --git a/src/index/index.ts b/src/index/index.ts deleted file mode 100644 index 24e5c24b2..000000000 --- a/src/index/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default class Index { - - //This function is tested and part of it is uncovered - uncovered_if = (a = true) => { - if (a == true) { - return false - } else { - return true - } - } - - //This function will be fully covered - fully_covered = () => { - return true - } - - //This function will not be tested by unit tests - uncovered = () => { - return true - } -} From 2e67f32735c173b458bd47faafb81a78e9a0a594 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:06:16 -0500 Subject: [PATCH 09/23] a name --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dfd10778e..ce7cdc497 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", "test-coverage": "jest --testPathPattern=demo/coverage --coverage --coverageDirectory=coverage/coverage", "test-script": "jest --testPathPattern=src --coverage --coverageDirectory=coverage/script", - "test-all": "yarn run test && yarn run test-calculator && yarn run test-index && eslint", + "test-all": "yarn run test-script && yarn run test-calculator && yarn run test-coverage && eslint", "build": "ncc build src/index.ts" }, "repository": { From a0e7a095bd58dc2a5fff7ea24a476a4690e3e18a Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:16:30 -0500 Subject: [PATCH 10/23] Edit package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ce7cdc497..3f1c090e4 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "test": "jest --coverage", "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", - "test-coverage": "jest --testPathPattern=demo/coverage --coverage --coverageDirectory=coverage/coverage", - "test-script": "jest --testPathPattern=src --coverage --coverageDirectory=coverage/script", + "test-coverage": "jest --testPathPattern=demo/coverage/ --coverage --coverageDirectory=coverage/coverage", + "test-script": "jest --testPathPattern=src/ --coverage --coverageDirectory=coverage/script", "test-all": "yarn run test-script && yarn run test-calculator && yarn run test-coverage && eslint", "build": "ncc build src/index.ts" }, From 25cb7e3abf4cdeb183d87c115b7fff7b1b6f1367 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:19:58 -0500 Subject: [PATCH 11/23] coverage-test --- .github/workflows/main.yml | 2 +- demo/coverage-test/coverage.test.ts | 11 +++++++++++ demo/coverage-test/coverage.ts | 21 +++++++++++++++++++++ package.json | 2 +- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 demo/coverage-test/coverage.test.ts create mode 100644 demo/coverage-test/coverage.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c22b31eee..84d4795a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: - name: Upload coverage to Codecov (demo) uses: ./ with: - files: ./coverage/calculator/coverage-final.json,./coverage/coverage/coverage-final.json + files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json file: ./coverage/coverage-final.json flags: demo name: codecov-1 diff --git a/demo/coverage-test/coverage.test.ts b/demo/coverage-test/coverage.test.ts new file mode 100644 index 000000000..9851ebdba --- /dev/null +++ b/demo/coverage-test/coverage.test.ts @@ -0,0 +1,11 @@ +import Coverage from "./coverage"; + +test('test uncovered if', () => { + const coverageObj = new Coverage(); + expect(coverageObj.uncovered_if()).toEqual(false); +}); + +test('fully covered', () => { + const coverageObj = new Coverage(); + expect(coverageObj.fully_covered()).toEqual(true); +}); diff --git a/demo/coverage-test/coverage.ts b/demo/coverage-test/coverage.ts new file mode 100644 index 000000000..f6d7bb704 --- /dev/null +++ b/demo/coverage-test/coverage.ts @@ -0,0 +1,21 @@ +export default class Coverage { + + //This function is tested and part of it is uncovered + uncovered_if = (a = true) => { + if (a == true) { + return false + } else { + return true + } + } + + //This function will be fully covered + fully_covered = () => { + return true + } + + //This function will not be tested by unit tests + uncovered = () => { + return true + } +} diff --git a/package.json b/package.json index 3f1c090e4..db6f247e5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "jest --coverage", "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", - "test-coverage": "jest --testPathPattern=demo/coverage/ --coverage --coverageDirectory=coverage/coverage", + "test-coverage": "jest --testPathPattern=demo/coverage-test/ --coverage --coverageDirectory=coverage/coverage-test", "test-script": "jest --testPathPattern=src/ --coverage --coverageDirectory=coverage/script", "test-all": "yarn run test-script && yarn run test-calculator && yarn run test-coverage && eslint", "build": "ncc build src/index.ts" From 0ad87e58506538af26dfba7fe725de14bc2a5025 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:22:49 -0500 Subject: [PATCH 12/23] Remove codecov.sh --- codecov.sh | 1820 ---------------------------------------------------- 1 file changed, 1820 deletions(-) delete mode 100644 codecov.sh diff --git a/codecov.sh b/codecov.sh deleted file mode 100644 index f5cef847d..000000000 --- a/codecov.sh +++ /dev/null @@ -1,1820 +0,0 @@ -#!/usr/bin/env bash - -# Apache License Version 2.0, January 2004 -# https://github.com/codecov/codecov-bash/blob/master/LICENSE - -set -e +o pipefail - -VERSION="20201231-23d4836" - -codecov_flags=( ) -url="https://codecov.io" -env="$CODECOV_ENV" -service="" -token="" -search_in="" -# shellcheck disable=SC2153 -flags="$CODECOV_FLAGS" -exit_with=0 -curlargs="" -curlawsargs="" -dump="0" -clean="0" -curl_s="-s" -name="$CODECOV_NAME" -include_cov="" -exclude_cov="" -ddp="$HOME/Library/Developer/Xcode/DerivedData" -xp="" -files="" -save_to="" -cacert="$CODECOV_CA_BUNDLE" -gcov_ignore="-not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**'" -gcov_include="" - -ft_gcov="1" -ft_coveragepy="1" -ft_fix="1" -ft_search="1" -ft_s3="1" -ft_network="1" -ft_xcodellvm="1" -ft_xcodeplist="0" -ft_gcovout="1" -ft_html="0" - -_git_root=$(git rev-parse --show-toplevel 2>/dev/null || hg root 2>/dev/null || echo "$PWD") -git_root="$_git_root" -remote_addr="" -if [ "$git_root" = "$PWD" ]; -then - git_root="." -fi - -url_o="" -pr_o="" -build_o="" -commit_o="" -search_in_o="" -tag_o="" -branch_o="" -slug_o="" -prefix_o="" -git_ls_files_recurse_submodules_o="" -package="bash" - -commit="$VCS_COMMIT_ID" -branch="$VCS_BRANCH_NAME" -pr="$VCS_PULL_REQUEST" -slug="$VCS_SLUG" -tag="$VCS_TAG" -build_url="$CI_BUILD_URL" -build="$CI_BUILD_ID" -job="$CI_JOB_ID" - -beta_xcode_partials="" - -proj_root="$git_root" -gcov_exe="gcov" -gcov_arg="" - -b="\033[0;36m" -g="\033[0;32m" -r="\033[0;31m" -e="\033[0;90m" -y="\033[0;33m" -x="\033[0m" - -show_help() { -cat << EOF - - Codecov Bash $VERSION - - Global report uploading tool for Codecov - Documentation at https://docs.codecov.io/docs - Contribute at https://github.com/codecov/codecov-bash - - - -h Display this help and exit - -f FILE Target file(s) to upload - - -f "path/to/file" only upload this file - skips searching unless provided patterns below - - -f '!*.bar' ignore all files at pattern *.bar - -f '*.foo' include all files at pattern *.foo - Must use single quotes. - This is non-exclusive, use -s "*.foo" to match specific paths. - - -s DIR Directory to search for coverage reports. - Already searches project root and artifact folders. - -t TOKEN Set the private repository token - (option) set environment variable CODECOV_TOKEN=:uuid - - -t @/path/to/token_file - -t uuid - - -n NAME Custom defined name of the upload. Visible in Codecov UI - - -e ENV Specify environment variables to be included with this build - Also accepting environment variables: CODECOV_ENV=VAR,VAR2 - - -e VAR,VAR2 - - -X feature Toggle functionalities - - -X gcov Disable gcov - -X coveragepy Disable python coverage - -X fix Disable report fixing - -X search Disable searching for reports - -X xcode Disable xcode processing - -X network Disable uploading the file network - -X gcovout Disable gcov output - -X html Enable coverage for HTML files - -X recursesubs Enable recurse submodules in git projects when searching for source files - - -N 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. - - -R root dir Used when not in git/hg project to identify project root directory - -F flag Flag the upload to group coverage metrics - - -F unittests This upload is only unittests - -F integration This upload is only integration tests - -F ui,chrome This upload is Chrome - UI tests - - -c Move discovered coverage reports to the trash - -Z Exit with 1 if not successful. Default will Exit with 0 - - -- xcode -- - -D Custom Derived Data Path for Coverage.profdata and gcov processing - Default '~/Library/Developer/Xcode/DerivedData' - -J 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" - - -- gcov -- - -g GLOB Paths to ignore during gcov gathering - -G GLOB Paths to include during gcov gathering - -p dir Project root directory - Also used when preparing gcov - -k prefix Prefix filepaths to help resolve path fixing: https://github.com/codecov/support/issues/472 - -x gcovexe gcov executable to run. Defaults to 'gcov' - -a gcovargs extra arguments to pass to gcov - - -- Override CI Environment Variables -- - These variables are automatically detected by popular CI providers - - -B branch Specify the branch name - -C sha Specify the commit sha - -P pr Specify the pull request number - -b build Specify the build number - -T tag Specify the git tag - - -- Enterprise -- - -u URL Set the target url for Enterprise customers - Not required when retrieving the bash uploader from your CCE - (option) Set environment variable CODECOV_URL=https://my-hosted-codecov.com - -r SLUG owner/repo slug used instead of the private repo token in Enterprise - (option) set environment variable CODECOV_SLUG=:owner/:repo - (option) set in your codecov.yml "codecov.slug" - -S PATH File path to your cacert.pem file used to verify ssl with Codecov Enterprise (optional) - (option) Set environment variable: CODECOV_CA_BUNDLE="/path/to/ca.pem" - -U curlargs Extra curl arguments to communicate with Codecov. e.g., -U "--proxy http://http-proxy" - -A curlargs Extra curl arguments to communicate with AWS. - - -- Debugging -- - -d Don't upload, but dump upload file to stdout - -q PATH Write upload file to path - -K Remove color from the output - -v Verbose mode - -EOF -} - - -say() { - echo -e "$1" -} - - -urlencode() { - echo "$1" | curl -Gso /dev/null -w "%{url_effective}" --data-urlencode @- "" | cut -c 3- | sed -e 's/%0A//' -} - - -swiftcov() { - _dir=$(dirname "$1" | sed 's/\(Build\).*/\1/g') - for _type in app framework xctest - do - find "$_dir" -name "*.$_type" | while read -r f - do - _proj=${f##*/} - _proj=${_proj%."$_type"} - if [ "$2" = "" ] || [ "$(echo "$_proj" | grep -i "$2")" != "" ]; - then - say " $g+$x Building reports for $_proj $_type" - dest=$([ -f "$f/$_proj" ] && echo "$f/$_proj" || echo "$f/Contents/MacOS/$_proj") - # shellcheck disable=SC2001 - _proj_name=$(echo "$_proj" | sed -e 's/[[:space:]]//g') - # shellcheck disable=SC2086 - xcrun llvm-cov show $beta_xcode_partials -instr-profile "$1" "$dest" > "$_proj_name.$_type.coverage.txt" \ - || say " ${r}x>${x} llvm-cov failed to produce results for $dest" - fi - done - done -} - - -# Credits to: https://gist.github.com/pkuczynski/8665367 -parse_yaml() { - local prefix=$2 - local s='[[:space:]]*' w='[a-zA-Z0-9_]*' - local fs - fs=$(echo @|tr @ '\034') - sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \ - -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" | - awk -F"$fs" '{ - indent = length($1)/2; - vname[indent] = $2; - for (i in vname) {if (i > indent) {delete vname[i]}} - if (length($3) > 0) { - vn=""; if (indent > 0) {vn=(vn)(vname[0])("_")} - printf("%s%s%s=\"%s\"\n", "'"$prefix"'",vn, $2, $3); - } - }' -} - - -if [ $# != 0 ]; -then - while getopts "a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:ZN:-" o - do - codecov_flags+=( "$o" ) - case "$o" in - "-") - echo -e "${r}Long options are not supported${x}" - exit 2 - ;; - "?") - ;; - "N") - parent=$OPTARG - ;; - "a") - gcov_arg=$OPTARG - ;; - "A") - curlawsargs="$OPTARG" - ;; - "b") - build_o="$OPTARG" - ;; - "B") - branch_o="$OPTARG" - ;; - "c") - clean="1" - ;; - "C") - commit_o="$OPTARG" - ;; - "d") - dump="1" - ;; - "D") - ddp="$OPTARG" - ;; - "e") - env="$env,$OPTARG" - ;; - "f") - if [ "${OPTARG::1}" = "!" ]; - then - exclude_cov="$exclude_cov -not -path '${OPTARG:1}'" - - elif [[ "$OPTARG" = *"*"* ]]; - then - include_cov="$include_cov -or -name '$OPTARG'" - - else - ft_search=0 - if [ "$files" = "" ]; - then - files="$OPTARG" - else - files="$files -$OPTARG" - fi - fi - ;; - "F") - if [ "$flags" = "" ]; - then - flags="$OPTARG" - else - flags="$flags,$OPTARG" - fi - ;; - "g") - gcov_ignore="$gcov_ignore -not -path '$OPTARG'" - ;; - "G") - gcov_include="$gcov_include -path '$OPTARG'" - ;; - "h") - show_help - exit 0; - ;; - "J") - ft_xcodellvm="1" - ft_xcodeplist="0" - if [ "$xp" = "" ]; - then - xp="$OPTARG" - else - xp="$xp\|$OPTARG" - fi - ;; - "k") - prefix_o=$(echo "$OPTARG" | sed -e 's:^/*::' -e 's:/*$::') - ;; - "K") - b="" - g="" - r="" - e="" - x="" - ;; - "n") - name="$OPTARG" - ;; - "p") - proj_root="$OPTARG" - ;; - "P") - pr_o="$OPTARG" - ;; - "Q") - # this is only meant for Codecov packages to overwrite - package="$OPTARG" - ;; - "q") - save_to="$OPTARG" - ;; - "r") - slug_o="$OPTARG" - ;; - "R") - git_root="$OPTARG" - ;; - "s") - if [ "$search_in_o" = "" ]; - then - search_in_o="$OPTARG" - else - search_in_o="$search_in_o $OPTARG" - fi - ;; - "S") - # shellcheck disable=SC2089 - cacert="--cacert \"$OPTARG\"" - ;; - "t") - if [ "${OPTARG::1}" = "@" ]; - then - token=$(< "${OPTARG:1}" tr -d ' \n') - else - token="$OPTARG" - fi - ;; - "T") - tag_o="$OPTARG" - ;; - "u") - url_o=$(echo "$OPTARG" | sed -e 's/\/$//') - ;; - "U") - curlargs="$OPTARG" - ;; - "v") - set -x - curl_s="" - ;; - "x") - gcov_exe=$OPTARG - ;; - "X") - if [ "$OPTARG" = "gcov" ]; - then - ft_gcov="0" - elif [ "$OPTARG" = "coveragepy" ] || [ "$OPTARG" = "py" ]; - then - ft_coveragepy="0" - elif [ "$OPTARG" = "gcovout" ]; - then - ft_gcovout="0" - elif [ "$OPTARG" = "xcodellvm" ]; - then - ft_xcodellvm="1" - ft_xcodeplist="0" - elif [ "$OPTARG" = "fix" ] || [ "$OPTARG" = "fixes" ]; - then - ft_fix="0" - elif [ "$OPTARG" = "xcode" ]; - then - ft_xcodellvm="0" - ft_xcodeplist="0" - elif [ "$OPTARG" = "search" ]; - then - ft_search="0" - elif [ "$OPTARG" = "xcodepartials" ]; - then - beta_xcode_partials="-use-color" - elif [ "$OPTARG" = "network" ]; - then - ft_network="0" - elif [ "$OPTARG" = "s3" ]; - then - ft_s3="0" - elif [ "$OPTARG" = "html" ]; - then - ft_html="1" - elif [ "$OPTARG" = "recursesubs" ]; - then - git_ls_files_recurse_submodules_o="--recurse-submodules" - fi - ;; - "Z") - exit_with=1 - ;; - *) - echo -e "${r}Unexpected flag not supported${x}" - ;; - esac - done -fi - -say " - _____ _ - / ____| | | -| | ___ __| | ___ ___ _____ __ -| | / _ \\ / _\` |/ _ \\/ __/ _ \\ \\ / / -| |___| (_) | (_| | __/ (_| (_) \\ V / - \\_____\\___/ \\__,_|\\___|\\___\\___/ \\_/ - Bash-$VERSION - -" - -# check for installed tools -# git/hg -if [ -x "$(command -v git)" ]; -then - say "$b==>$x $(git --version) found" -else - say "$y==>$x git not installed, testing for mercurial" - if [ -x "$(command -v hg)" ]; - then - say "$b==>$x $(hg --version) found" - else - say "$r==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences" - fi -fi -# curl -if [ -x "$(command -v curl)" ]; -then - say "$b==>$x $(curl --version)" -else - say "$r==>$x curl not installed. Exiting." - exit ${exit_with}; -fi - -search_in="$proj_root" - -#shellcheck disable=SC2154 -if [ "$JENKINS_URL" != "" ]; -then - say "$e==>$x Jenkins CI detected." - # https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project - # https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin#GitHubpullrequestbuilderplugin-EnvironmentVariables - service="jenkins" - - # shellcheck disable=SC2154 - if [ "$ghprbSourceBranch" != "" ]; - then - branch="$ghprbSourceBranch" - elif [ "$GIT_BRANCH" != "" ]; - then - branch="$GIT_BRANCH" - elif [ "$BRANCH_NAME" != "" ]; - then - branch="$BRANCH_NAME" - fi - - # shellcheck disable=SC2154 - if [ "$ghprbActualCommit" != "" ]; - then - commit="$ghprbActualCommit" - elif [ "$GIT_COMMIT" != "" ]; - then - commit="$GIT_COMMIT" - fi - - # shellcheck disable=SC2154 - if [ "$ghprbPullId" != "" ]; - then - pr="$ghprbPullId" - elif [ "$CHANGE_ID" != "" ]; - then - pr="$CHANGE_ID" - fi - - build="$BUILD_NUMBER" - # shellcheck disable=SC2153 - build_url=$(urlencode "$BUILD_URL") - -elif [ "$CI" = "true" ] && [ "$TRAVIS" = "true" ] && [ "$SHIPPABLE" != "true" ]; -then - say "$e==>$x Travis CI detected." - # https://docs.travis-ci.com/user/environment-variables/ - service="travis" - commit="${TRAVIS_PULL_REQUEST_SHA:-$TRAVIS_COMMIT}" - build="$TRAVIS_JOB_NUMBER" - pr="$TRAVIS_PULL_REQUEST" - job="$TRAVIS_JOB_ID" - slug="$TRAVIS_REPO_SLUG" - env="$env,TRAVIS_OS_NAME" - tag="$TRAVIS_TAG" - if [ "$TRAVIS_BRANCH" != "$TRAVIS_TAG" ]; - then - branch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" - fi - - language=$(compgen -A variable | grep "^TRAVIS_.*_VERSION$" | head -1) - if [ "$language" != "" ]; - then - env="$env,${!language}" - fi - -elif [ "$CODEBUILD_CI" = "true" ]; -then - say "$e==>$x AWS Codebuild detected." - # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html - service="codebuild" - commit="$CODEBUILD_RESOLVED_SOURCE_VERSION" - build="$CODEBUILD_BUILD_ID" - branch="$(echo "$CODEBUILD_WEBHOOK_HEAD_REF" | sed 's/^refs\/heads\///')" - if [ "${CODEBUILD_SOURCE_VERSION/pr}" = "$CODEBUILD_SOURCE_VERSION" ] ; then - pr="false" - else - pr="$(echo "$CODEBUILD_SOURCE_VERSION" | sed 's/^pr\///')" - fi - job="$CODEBUILD_BUILD_ID" - slug="$(echo "$CODEBUILD_SOURCE_REPO_URL" | sed 's/^.*:\/\/[^\/]*\///' | sed 's/\.git$//')" - -elif [ "$CI" = "true" ] && [ "$CI_NAME" = "codeship" ]; -then - say "$e==>$x Codeship CI detected." - # https://www.codeship.io/documentation/continuous-integration/set-environment-variables/ - service="codeship" - branch="$CI_BRANCH" - build="$CI_BUILD_NUMBER" - build_url=$(urlencode "$CI_BUILD_URL") - commit="$CI_COMMIT_ID" - -elif [ -n "$CF_BUILD_URL" ] && [ -n "$CF_BUILD_ID" ]; -then - say "$e==>$x Codefresh CI detected." - # https://docs.codefresh.io/v1.0/docs/variables - service="codefresh" - branch="$CF_BRANCH" - build="$CF_BUILD_ID" - build_url=$(urlencode "$CF_BUILD_URL") - commit="$CF_REVISION" - -elif [ "$TEAMCITY_VERSION" != "" ]; -then - say "$e==>$x TeamCity CI detected." - # https://confluence.jetbrains.com/display/TCD8/Predefined+Build+Parameters - # https://confluence.jetbrains.com/plugins/servlet/mobile#content/view/74847298 - if [ "$TEAMCITY_BUILD_BRANCH" = '' ]; - then - echo " Teamcity does not automatically make build parameters available as environment variables." - echo " Add the following environment parameters to the build configuration" - echo " env.TEAMCITY_BUILD_BRANCH = %teamcity.build.branch%" - echo " env.TEAMCITY_BUILD_ID = %teamcity.build.id%" - echo " env.TEAMCITY_BUILD_URL = %teamcity.serverUrl%/viewLog.html?buildId=%teamcity.build.id%" - echo " env.TEAMCITY_BUILD_COMMIT = %system.build.vcs.number%" - echo " env.TEAMCITY_BUILD_REPOSITORY = %vcsroot..url%" - fi - service="teamcity" - branch="$TEAMCITY_BUILD_BRANCH" - build="$TEAMCITY_BUILD_ID" - build_url=$(urlencode "$TEAMCITY_BUILD_URL") - if [ "$TEAMCITY_BUILD_COMMIT" != "" ]; - then - commit="$TEAMCITY_BUILD_COMMIT" - else - commit="$BUILD_VCS_NUMBER" - fi - remote_addr="$TEAMCITY_BUILD_REPOSITORY" - -elif [ "$CI" = "true" ] && [ "$CIRCLECI" = "true" ]; -then - say "$e==>$x Circle CI detected." - # https://circleci.com/docs/environment-variables - service="circleci" - branch="$CIRCLE_BRANCH" - build="$CIRCLE_BUILD_NUM" - job="$CIRCLE_NODE_INDEX" - if [ "$CIRCLE_PROJECT_REPONAME" != "" ]; - then - slug="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" - else - # git@github.com:owner/repo.git - slug="${CIRCLE_REPOSITORY_URL##*:}" - # owner/repo.git - slug="${slug%%.git}" - fi - pr="${CIRCLE_PULL_REQUEST##*/}" - commit="$CIRCLE_SHA1" - search_in="$search_in $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS" - -elif [ "$BUDDYBUILD_BRANCH" != "" ]; -then - say "$e==>$x buddybuild detected" - # http://docs.buddybuild.com/v6/docs/custom-prebuild-and-postbuild-steps - service="buddybuild" - branch="$BUDDYBUILD_BRANCH" - build="$BUDDYBUILD_BUILD_NUMBER" - build_url="https://dashboard.buddybuild.com/public/apps/$BUDDYBUILD_APP_ID/build/$BUDDYBUILD_BUILD_ID" - # BUDDYBUILD_TRIGGERED_BY - if [ "$ddp" = "$HOME/Library/Developer/Xcode/DerivedData" ]; - then - ddp="/private/tmp/sandbox/${BUDDYBUILD_APP_ID}/bbtest" - fi - -elif [ "${bamboo_planRepository_revision}" != "" ]; -then - say "$e==>$x Bamboo detected" - # https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html#Bamboovariables-Build-specificvariables - service="bamboo" - commit="${bamboo_planRepository_revision}" - # shellcheck disable=SC2154 - branch="${bamboo_planRepository_branch}" - # shellcheck disable=SC2154 - build="${bamboo_buildNumber}" - # shellcheck disable=SC2154 - build_url="${bamboo_buildResultsUrl}" - # shellcheck disable=SC2154 - remote_addr="${bamboo_planRepository_repositoryUrl}" - -elif [ "$CI" = "true" ] && [ "$BITRISE_IO" = "true" ]; -then - # http://devcenter.bitrise.io/faq/available-environment-variables/ - say "$e==>$x Bitrise CI detected." - service="bitrise" - branch="$BITRISE_GIT_BRANCH" - build="$BITRISE_BUILD_NUMBER" - build_url=$(urlencode "$BITRISE_BUILD_URL") - pr="$BITRISE_PULL_REQUEST" - if [ "$GIT_CLONE_COMMIT_HASH" != "" ]; - then - commit="$GIT_CLONE_COMMIT_HASH" - fi - -elif [ "$CI" = "true" ] && [ "$SEMAPHORE" = "true" ]; -then - say "$e==>$x Semaphore CI detected." -# https://docs.semaphoreci.com/ci-cd-environment/environment-variables/#semaphore-related - service="semaphore" - branch="$SEMAPHORE_GIT_BRANCH" - build="$SEMAPHORE_WORKFLOW_NUMBER" - job="$SEMAPHORE_JOB_ID" - pr="$PULL_REQUEST_NUMBER" - slug="$SEMAPHORE_REPO_SLUG" - commit="$REVISION" - env="$env,SEMAPHORE_TRIGGER_SOURCE" - -elif [ "$CI" = "true" ] && [ "$BUILDKITE" = "true" ]; -then - say "$e==>$x Buildkite CI detected." - # https://buildkite.com/docs/guides/environment-variables - service="buildkite" - branch="$BUILDKITE_BRANCH" - build="$BUILDKITE_BUILD_NUMBER" - job="$BUILDKITE_JOB_ID" - build_url=$(urlencode "$BUILDKITE_BUILD_URL") - slug="$BUILDKITE_PROJECT_SLUG" - commit="$BUILDKITE_COMMIT" - if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]]; then - pr="$BUILDKITE_PULL_REQUEST" - fi - tag="$BUILDKITE_TAG" - -elif [ "$CI" = "drone" ] || [ "$DRONE" = "true" ]; -then - say "$e==>$x Drone CI detected." - # http://docs.drone.io/env.html - # drone commits are not full shas - service="drone.io" - branch="$DRONE_BRANCH" - build="$DRONE_BUILD_NUMBER" - build_url=$(urlencode "${DRONE_BUILD_LINK}") - pr="$DRONE_PULL_REQUEST" - job="$DRONE_JOB_NUMBER" - tag="$DRONE_TAG" - -elif [ "$CI" = "true" ] && [ "$HEROKU_TEST_RUN_BRANCH" != "" ]; -then - say "$e==>$x Heroku CI detected." - # https://devcenter.heroku.com/articles/heroku-ci#environment-variables - service="heroku" - branch="$HEROKU_TEST_RUN_BRANCH" - build="$HEROKU_TEST_RUN_ID" - commit="$HEROKU_TEST_RUN_COMMIT_VERSION" - -elif [[ "$CI" = "true" || "$CI" = "True" ]] && [[ "$APPVEYOR" = "true" || "$APPVEYOR" = "True" ]]; -then - say "$e==>$x Appveyor CI detected." - # http://www.appveyor.com/docs/environment-variables - service="appveyor" - branch="$APPVEYOR_REPO_BRANCH" - build=$(urlencode "$APPVEYOR_JOB_ID") - pr="$APPVEYOR_PULL_REQUEST_NUMBER" - job="$APPVEYOR_ACCOUNT_NAME%2F$APPVEYOR_PROJECT_SLUG%2F$APPVEYOR_BUILD_VERSION" - slug="$APPVEYOR_REPO_NAME" - commit="$APPVEYOR_REPO_COMMIT" - build_url=$(urlencode "${APPVEYOR_URL}/project/${APPVEYOR_REPO_NAME}/builds/$APPVEYOR_BUILD_ID/job/${APPVEYOR_JOB_ID}") - -elif [ "$CI" = "true" ] && [ "$WERCKER_GIT_BRANCH" != "" ]; -then - say "$e==>$x Wercker CI detected." - # http://devcenter.wercker.com/articles/steps/variables.html - service="wercker" - branch="$WERCKER_GIT_BRANCH" - build="$WERCKER_MAIN_PIPELINE_STARTED" - slug="$WERCKER_GIT_OWNER/$WERCKER_GIT_REPOSITORY" - commit="$WERCKER_GIT_COMMIT" - -elif [ "$CI" = "true" ] && [ "$MAGNUM" = "true" ]; -then - say "$e==>$x Magnum CI detected." - # https://magnum-ci.com/docs/environment - service="magnum" - branch="$CI_BRANCH" - build="$CI_BUILD_NUMBER" - commit="$CI_COMMIT" - -elif [ "$SHIPPABLE" = "true" ]; -then - say "$e==>$x Shippable CI detected." - # http://docs.shippable.com/ci_configure/ - service="shippable" - # shellcheck disable=SC2153 - branch=$([ "$HEAD_BRANCH" != "" ] && echo "$HEAD_BRANCH" || echo "$BRANCH") - build="$BUILD_NUMBER" - build_url=$(urlencode "$BUILD_URL") - pr="$PULL_REQUEST" - slug="$REPO_FULL_NAME" - # shellcheck disable=SC2153 - commit="$COMMIT" - -elif [ "$TDDIUM" = "true" ]; -then - say "Solano CI detected." - # http://docs.solanolabs.com/Setup/tddium-set-environment-variables/ - service="solano" - commit="$TDDIUM_CURRENT_COMMIT" - branch="$TDDIUM_CURRENT_BRANCH" - build="$TDDIUM_TID" - pr="$TDDIUM_PR_ID" - -elif [ "$GREENHOUSE" = "true" ]; -then - say "$e==>$x Greenhouse CI detected." - # http://docs.greenhouseci.com/docs/environment-variables-files - service="greenhouse" - branch="$GREENHOUSE_BRANCH" - build="$GREENHOUSE_BUILD_NUMBER" - build_url=$(urlencode "$GREENHOUSE_BUILD_URL") - pr="$GREENHOUSE_PULL_REQUEST" - commit="$GREENHOUSE_COMMIT" - search_in="$search_in $GREENHOUSE_EXPORT_DIR" - -elif [ "$GITLAB_CI" != "" ]; -then - say "$e==>$x GitLab CI detected." - # http://doc.gitlab.com/ce/ci/variables/README.html - service="gitlab" - branch="${CI_BUILD_REF_NAME:-$CI_COMMIT_REF_NAME}" - build="${CI_BUILD_ID:-$CI_JOB_ID}" - remote_addr="${CI_BUILD_REPO:-$CI_REPOSITORY_URL}" - commit="${CI_BUILD_REF:-$CI_COMMIT_SHA}" - slug="${CI_PROJECT_PATH}" - -elif [ "$GITHUB_ACTIONS" != "" ]; -then - say "$e==>$x GitHub Actions detected." - - # https://github.com/features/actions - service="github-actions" - - # https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables - branch="${GITHUB_REF#refs/heads/}" - if [ "$GITHUB_HEAD_REF" != "" ]; - then - # PR refs are in the format: refs/pull/7/merge - pr="${GITHUB_REF#refs/pull/}" - pr="${pr%/merge}" - branch="${GITHUB_HEAD_REF}" - fi - commit="${GITHUB_SHA}" - slug="${GITHUB_REPOSITORY}" - build="${GITHUB_RUN_ID}" - build_url=$(urlencode "http://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}") - job="${GITHUB_WORKFLOW}" - - # actions/checkout runs in detached HEAD - mc= - if [ -n "$pr" ] && [ "$pr" != false ]; - then - mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") - - if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; - then - mc=$(echo "$mc" | cut -d' ' -f2) - say " Fixing merge commit SHA $commit -> $mc" - commit=$mc - elif [[ "$mc" = "" ]]; - then - say "$r-> Issue detecting commit SHA. Please run actions/checkout with fetch-depth > 1 or set to 0$x" - fi - fi - -elif [ "$SYSTEM_TEAMFOUNDATIONSERVERURI" != "" ]; -then - say "$e==>$x Azure Pipelines detected." - # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=vsts - # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&viewFallbackFrom=vsts&tabs=yaml - service="azure_pipelines" - commit="$BUILD_SOURCEVERSION" - build="$BUILD_BUILDNUMBER" - if [ -z "$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" ]; - then - pr="$SYSTEM_PULLREQUEST_PULLREQUESTID" - else - pr="$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" - fi - project="${SYSTEM_TEAMPROJECT}" - server_uri="${SYSTEM_TEAMFOUNDATIONSERVERURI}" - job="${BUILD_BUILDID}" - branch="${BUILD_SOURCEBRANCH#"refs/heads/"}" - build_url=$(urlencode "${SYSTEM_TEAMFOUNDATIONSERVERURI}${SYSTEM_TEAMPROJECT}/_build/results?buildId=${BUILD_BUILDID}") - - # azure/pipelines runs in detached HEAD - mc= - if [ -n "$pr" ] && [ "$pr" != false ]; - then - mc=$(git show --no-patch --format="%P" 2>/dev/null || echo "") - - if [[ "$mc" =~ ^[a-z0-9]{40}[[:space:]][a-z0-9]{40}$ ]]; - then - mc=$(echo "$mc" | cut -d' ' -f2) - say " Fixing merge commit SHA $commit -> $mc" - commit=$mc - fi - fi - -elif [ "$CI" = "true" ] && [ "$BITBUCKET_BUILD_NUMBER" != "" ]; -then - say "$e==>$x Bitbucket detected." - # https://confluence.atlassian.com/bitbucket/variables-in-pipelines-794502608.html - service="bitbucket" - branch="$BITBUCKET_BRANCH" - build="$BITBUCKET_BUILD_NUMBER" - slug="$BITBUCKET_REPO_OWNER/$BITBUCKET_REPO_SLUG" - job="$BITBUCKET_BUILD_NUMBER" - pr="$BITBUCKET_PR_ID" - commit="$BITBUCKET_COMMIT" - # See https://jira.atlassian.com/browse/BCLOUD-19393 - if [ "${#commit}" = 12 ]; - then - commit=$(git rev-parse "$BITBUCKET_COMMIT") - fi - -elif [ "$CI" = "true" ] && [ "$BUDDY" = "true" ]; -then - say "$e==>$x Buddy CI detected." - # https://buddy.works/docs/pipelines/environment-variables - service="buddy" - branch="$BUDDY_EXECUTION_BRANCH" - build="$BUDDY_EXECUTION_ID" - build_url=$(urlencode "$BUDDY_EXECUTION_URL") - commit="$BUDDY_EXECUTION_REVISION" - pr="$BUDDY_EXECUTION_PULL_REQUEST_NO" - tag="$BUDDY_EXECUTION_TAG" - slug="$BUDDY_REPO_SLUG" - -elif [ "$CIRRUS_CI" != "" ]; -then - say "$e==>$x Cirrus CI detected." - # https://cirrus-ci.org/guide/writing-tasks/#environment-variables - service="cirrus-ci" - slug="$CIRRUS_REPO_FULL_NAME" - branch="$CIRRUS_BRANCH" - pr="$CIRRUS_PR" - commit="$CIRRUS_CHANGE_IN_REPO" - build="$CIRRUS_TASK_ID" - job="$CIRRUS_TASK_NAME" - -elif [ "$DOCKER_REPO" != "" ]; -then - say "$e==>$x Docker detected." - # https://docs.docker.com/docker-cloud/builds/advanced/ - service="docker" - branch="$SOURCE_BRANCH" - commit="$SOURCE_COMMIT" - slug="$DOCKER_REPO" - tag="$CACHE_TAG" - env="$env,IMAGE_NAME" - -else - say "${r}x>${x} No CI provider detected." - say " Testing inside Docker? ${b}http://docs.codecov.io/docs/testing-with-docker${x}" - say " Testing with Tox? ${b}https://docs.codecov.io/docs/python#section-testing-with-tox${x}" - -fi - -say " ${e}project root:${x} $git_root" - -# find branch, commit, repo from git command -if [ "$GIT_BRANCH" != "" ]; -then - branch="$GIT_BRANCH" - -elif [ "$branch" = "" ]; -then - branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || hg branch 2>/dev/null || echo "") - if [ "$branch" = "HEAD" ]; - then - branch="" - fi -fi - -if [ "$commit_o" = "" ]; -then - if [ "$GIT_COMMIT" != "" ]; - then - commit="$GIT_COMMIT" - elif [ "$commit" = "" ]; - then - commit=$(git log -1 --format="%H" 2>/dev/null || hg id -i --debug 2>/dev/null | tr -d '+' || echo "") - fi -else - commit="$commit_o" -fi - -if [ "$CODECOV_TOKEN" != "" ] && [ "$token" = "" ]; -then - say "${e}-->${x} token set from env" - token="$CODECOV_TOKEN" -fi - -if [ "$CODECOV_URL" != "" ] && [ "$url_o" = "" ]; -then - say "${e}-->${x} url set from env" - url_o=$(echo "$CODECOV_URL" | sed -e 's/\/$//') -fi - -if [ "$CODECOV_SLUG" != "" ]; -then - say "${e}-->${x} slug set from env" - slug_o="$CODECOV_SLUG" - -elif [ "$slug" = "" ]; -then - if [ "$remote_addr" = "" ]; - then - remote_addr=$(git config --get remote.origin.url || hg paths default || echo '') - fi - if [ "$remote_addr" != "" ]; - then - if echo "$remote_addr" | grep -q "//"; then - # https - slug=$(echo "$remote_addr" | cut -d / -f 4,5 | sed -e 's/\.git$//') - else - # ssh - slug=$(echo "$remote_addr" | cut -d : -f 2 | sed -e 's/\.git$//') - fi - fi - if [ "$slug" = "/" ]; - then - slug="" - fi -fi - -yaml=$(cd "$git_root" && \ - git ls-files "*codecov.yml" "*codecov.yaml" 2>/dev/null \ - || hg locate "*codecov.yml" "*codecov.yaml" 2>/dev/null \ - || cd "$proj_root" && find . -maxdepth 1 -type f -name '*codecov.y*ml' 2>/dev/null \ - || echo '') -yaml=$(echo "$yaml" | head -1) - -if [ "$yaml" != "" ]; -then - say " ${e}Yaml found at:${x} $yaml" - if [[ "$yaml" != /* ]]; then - # relative path for yaml file given, assume relative to the repo root - yaml="$git_root/$yaml" - fi - config=$(parse_yaml "$yaml" || echo '') - - # TODO validate the yaml here - - if [ "$(echo "$config" | grep 'codecov_token="')" != "" ] && [ "$token" = "" ]; - then - say "${e}-->${x} token set from yaml" - token="$(echo "$config" | grep 'codecov_token="' | sed -e 's/codecov_token="//' | sed -e 's/"\.*//')" - fi - - if [ "$(echo "$config" | grep 'codecov_url="')" != "" ] && [ "$url_o" = "" ]; - then - say "${e}-->${x} url set from yaml" - url_o="$(echo "$config" | grep 'codecov_url="' | sed -e 's/codecov_url="//' | sed -e 's/"\.*//')" - fi - - if [ "$(echo "$config" | grep 'codecov_slug="')" != "" ] && [ "$slug_o" = "" ]; - then - say "${e}-->${x} slug set from yaml" - slug_o="$(echo "$config" | grep 'codecov_slug="' | sed -e 's/codecov_slug="//' | sed -e 's/"\.*//')" - fi -else - say " ${g}Yaml not found, that's ok! Learn more at${x} ${b}http://docs.codecov.io/docs/codecov-yaml${x}" -fi - -if [ "$branch_o" != "" ]; -then - branch=$(urlencode "$branch_o") -else - branch=$(urlencode "$branch") -fi - -if [ "$slug_o" = "" ]; -then - urlencoded_slug=$(urlencode "$slug") -else - urlencoded_slug=$(urlencode "$slug_o") -fi - -query="branch=$branch\ - &commit=$commit\ - &build=$([ "$build_o" = "" ] && echo "$build" || echo "$build_o")\ - &build_url=$build_url\ - &name=$(urlencode "$name")\ - &tag=$([ "$tag_o" = "" ] && echo "$tag" || echo "$tag_o")\ - &slug=$urlencoded_slug\ - &service=$service\ - &flags=$flags\ - &pr=$([ "$pr_o" = "" ] && echo "${pr##\#}" || echo "${pr_o##\#}")\ - &job=$job\ - &cmd_args=$(IFS=,; echo "${codecov_flags[*]}")" - -if [ -n "$project" ] && [ -n "$server_uri" ]; -then - query=$(echo "$query&project=$project&server_uri=$server_uri" | tr -d ' ') -fi - -if [ "$parent" != "" ]; -then - query=$(echo "parent=$parent&$query" | tr -d ' ') -fi - -if [ "$ft_search" = "1" ]; -then - # detect bower comoponents location - bower_components="bower_components" - bower_rc=$(cd "$git_root" && cat .bowerrc 2>/dev/null || echo "") - if [ "$bower_rc" != "" ]; - then - bower_components=$(echo "$bower_rc" | tr -d '\n' | grep '"directory"' | cut -d'"' -f4 | sed -e 's/\/$//') - if [ "$bower_components" = "" ]; - then - bower_components="bower_components" - fi - fi - - # Swift Coverage - if [ "$ft_xcodellvm" = "1" ] && [ -d "$ddp" ]; - then - say "${e}==>${x} Processing Xcode reports via llvm-cov" - say " DerivedData folder: $ddp" - profdata_files=$(find "$ddp" -name '*.profdata' 2>/dev/null || echo '') - if [ "$profdata_files" != "" ]; - then - # xcode via profdata - if [ "$xp" = "" ]; - then - # xp=$(xcodebuild -showBuildSettings 2>/dev/null | grep -i "^\s*PRODUCT_NAME" | sed -e 's/.*= \(.*\)/\1/') - # say " ${e}->${x} Speed up Xcode processing by adding ${e}-J '$xp'${x}" - say " ${g}hint${x} Speed up Swift processing by using use ${g}-J 'AppName'${x} (regexp accepted)" - say " ${g}hint${x} This will remove Pods/ from your report. Also ${b}https://docs.codecov.io/docs/ignoring-paths${x}" - fi - while read -r profdata; - do - if [ "$profdata" != "" ]; - then - swiftcov "$profdata" "$xp" - fi - done <<< "$profdata_files" - else - say " ${e}->${x} No Swift coverage found" - fi - - # Obj-C Gcov Coverage - if [ "$ft_gcov" = "1" ]; - then - say " ${e}->${x} Running $gcov_exe for Obj-C" - if [ "$ft_gcovout" = "0" ]; - then - # suppress gcov output - bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" >/dev/null 2>&1 || true - else - bash -c "find $ddp -type f -name '*.gcda' $gcov_include $gcov_ignore -exec $gcov_exe -p $gcov_arg {} +" || true - fi - fi - fi - - if [ "$ft_xcodeplist" = "1" ] && [ -d "$ddp" ]; - then - say "${e}==>${x} Processing Xcode plists" - plists_files=$(find "$ddp" -name '*.xccoverage' 2>/dev/null || echo '') - if [ "$plists_files" != "" ]; - then - while read -r plist; - do - if [ "$plist" != "" ]; - then - say " ${g}Found${x} plist file at $plist" - plutil -convert xml1 -o "$(basename "$plist").plist" -- "$plist" - fi - done <<< "$plists_files" - fi - fi - - # Gcov Coverage - if [ "$ft_gcov" = "1" ]; - then - say "${e}==>${x} Running $gcov_exe in $proj_root ${e}(disable via -X gcov)${x}" - if [ "$ft_gcovout" = "0" ]; - then - # suppress gcov output - bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" >/dev/null 2>&1 || true - else - bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -exec $gcov_exe -pb $gcov_arg {} +" || true - fi - else - say "${e}==>${x} gcov disabled" - fi - - # Python Coverage - if [ "$ft_coveragepy" = "1" ]; - then - if [ ! -f coverage.xml ]; - then - if command -v coverage >/dev/null 2>&1; - then - say "${e}==>${x} Python coveragepy exists ${e}disable via -X coveragepy${x}" - - dotcoverage=$(find "$git_root" -name '.coverage' -or -name '.coverage.*' | head -1 || echo '') - if [ "$dotcoverage" != "" ]; - then - cd "$(dirname "$dotcoverage")" - if [ ! -f .coverage ]; - then - say " ${e}->${x} Running coverage combine" - coverage combine -a - fi - say " ${e}->${x} Running coverage xml" - if [ "$(coverage xml -i)" != "No data to report." ]; - then - files="$files -$PWD/coverage.xml" - else - say " ${r}No data to report.${x}" - fi - cd "$proj_root" - else - say " ${r}No .coverage file found.${x}" - fi - else - say "${e}==>${x} Python coveragepy not found" - fi - fi - else - say "${e}==>${x} Python coveragepy disabled" - fi - - if [ "$search_in_o" != "" ]; - then - # location override - search_in="$search_in_o" - fi - - say "$e==>$x Searching for coverage reports in:" - for _path in $search_in - do - say " ${g}+${x} $_path" - done - - patterns="find $search_in \( \ - -name vendor \ - -or -name htmlcov \ - -or -name virtualenv \ - -or -name js/generated/coverage \ - -or -name .virtualenv \ - -or -name virtualenvs \ - -or -name .virtualenvs \ - -or -name .env \ - -or -name .envs \ - -or -name env \ - -or -name .yarn-cache \ - -or -name envs \ - -or -name .venv \ - -or -name .venvs \ - -or -name venv \ - -or -name venvs \ - -or -name .git \ - -or -name .hg \ - -or -name .tox \ - -or -name __pycache__ \ - -or -name '.egg-info*' \ - -or -name '$bower_components' \ - -or -name node_modules \ - -or -name 'conftest_*.c.gcov' \ - \) -prune -or \ - -type f \( -name '*coverage*.*' \ - -or -name '*.clover' \ - -or -name '*.codecov.*' \ - -or -name '*.gcov' \ - -or -name '*.lcov' \ - -or -name '*.lst' \ - -or -name 'clover.xml' \ - -or -name 'cobertura.xml' \ - -or -name 'codecov.*' \ - -or -name 'cover.out' \ - -or -name 'coverage-final.json' \ - -or -name 'excoveralls.json' \ - -or -name 'gcov.info' \ - -or -name 'jacoco*.xml' \ - -or -name '*Jacoco*.xml' \ - -or -name 'lcov.dat' \ - -or -name 'lcov.info' \ - -or -name 'luacov.report.out' \ - -or -name 'naxsi.info' \ - -or -name 'nosetests.xml' \ - -or -name 'report.xml' \ - $include_cov \) \ - $exclude_cov \ - -not -name '*.am' \ - -not -name '*.bash' \ - -not -name '*.bat' \ - -not -name '*.bw' \ - -not -name '*.cfg' \ - -not -name '*.class' \ - -not -name '*.cmake' \ - -not -name '*.cmake' \ - -not -name '*.conf' \ - -not -name '*.coverage' \ - -not -name '*.cp' \ - -not -name '*.cpp' \ - -not -name '*.crt' \ - -not -name '*.css' \ - -not -name '*.csv' \ - -not -name '*.csv' \ - -not -name '*.data' \ - -not -name '*.db' \ - -not -name '*.dox' \ - -not -name '*.ec' \ - -not -name '*.ec' \ - -not -name '*.egg' \ - -not -name '*.el' \ - -not -name '*.env' \ - -not -name '*.erb' \ - -not -name '*.exe' \ - -not -name '*.ftl' \ - -not -name '*.gif' \ - -not -name '*.gradle' \ - -not -name '*.gz' \ - -not -name '*.h' \ - -not -name '*.html' \ - -not -name '*.in' \ - -not -name '*.jade' \ - -not -name '*.jar*' \ - -not -name '*.jpeg' \ - -not -name '*.jpg' \ - -not -name '*.js' \ - -not -name '*.less' \ - -not -name '*.log' \ - -not -name '*.m4' \ - -not -name '*.mak*' \ - -not -name '*.md' \ - -not -name '*.o' \ - -not -name '*.p12' \ - -not -name '*.pem' \ - -not -name '*.png' \ - -not -name '*.pom*' \ - -not -name '*.profdata' \ - -not -name '*.proto' \ - -not -name '*.ps1' \ - -not -name '*.pth' \ - -not -name '*.py' \ - -not -name '*.pyc' \ - -not -name '*.pyo' \ - -not -name '*.rb' \ - -not -name '*.rsp' \ - -not -name '*.rst' \ - -not -name '*.ru' \ - -not -name '*.sbt' \ - -not -name '*.scss' \ - -not -name '*.scss' \ - -not -name '*.serialized' \ - -not -name '*.sh' \ - -not -name '*.snapshot' \ - -not -name '*.sql' \ - -not -name '*.svg' \ - -not -name '*.tar.tz' \ - -not -name '*.template' \ - -not -name '*.whl' \ - -not -name '*.xcconfig' \ - -not -name '*.xcoverage.*' \ - -not -name '*/classycle/report.xml' \ - -not -name '*codecov.yml' \ - -not -name '*~' \ - -not -name '.*coveragerc' \ - -not -name '.coverage*' \ - -not -name 'coverage-summary.json' \ - -not -name 'createdFiles.lst' \ - -not -name 'fullLocaleNames.lst' \ - -not -name 'include.lst' \ - -not -name 'inputFiles.lst' \ - -not -name 'phpunit-code-coverage.xml' \ - -not -name 'phpunit-coverage.xml' \ - -not -name 'remapInstanbul.coverage*.json' \ - -not -name 'scoverage.measurements.*' \ - -not -name 'test_*_coverage.txt' \ - -not -name 'testrunner-coverage*' \ - -print 2>/dev/null" - files=$(eval "$patterns" || echo '') - -elif [ "$include_cov" != "" ]; -then - files=$(eval "find $search_in -type f \( ${include_cov:5} \)$exclude_cov 2>/dev/null" || echo '') -fi - -num_of_files=$(echo "$files" | wc -l | tr -d ' ') -if [ "$num_of_files" != '' ] && [ "$files" != '' ]; -then - say " ${e}->${x} Found $num_of_files reports" -fi - -# no files found -if [ "$files" = "" ]; -then - say "${r}-->${x} No coverage report found." - say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" - exit ${exit_with}; -fi - -if [ "$ft_network" == "1" ]; -then - say "${e}==>${x} Detecting git/mercurial file structure" - network=$(cd "$git_root" && git ls-files $git_ls_files_recurse_submodules_o 2>/dev/null || hg locate 2>/dev/null || echo "") - if [ "$network" = "" ]; - then - network=$(find "$git_root" \( \ - -name virtualenv \ - -name .virtualenv \ - -name virtualenvs \ - -name .virtualenvs \ - -name '*.png' \ - -name '*.gif' \ - -name '*.jpg' \ - -name '*.jpeg' \ - -name '*.md' \ - -name .env \ - -name .envs \ - -name env \ - -name envs \ - -name .venv \ - -name .venvs \ - -name venv \ - -name venvs \ - -name .git \ - -name .egg-info \ - -name shunit2-2.1.6 \ - -name vendor \ - -name __pycache__ \ - -name node_modules \ - -path "*/$bower_components/*" \ - -path '*/target/delombok/*' \ - -path '*/build/lib/*' \ - -path '*/js/generated/coverage/*' \ - \) -prune -or \ - -type f -print 2>/dev/null || echo '') - fi - - if [ "$prefix_o" != "" ]; - then - network=$(echo "$network" | awk "{print \"$prefix_o/\"\$0}") - fi -fi - -upload_file=$(mktemp /tmp/codecov.XXXXXX) -adjustments_file=$(mktemp /tmp/codecov.adjustments.XXXXXX) - -cleanup() { - rm -f "$upload_file" "$adjustments_file" "$upload_file.gz" -} - -trap cleanup INT ABRT TERM - -if [ "$env" != "" ]; -then - inc_env="" - say "${e}==>${x} Appending build variables" - for varname in $(echo "$env" | tr ',' ' ') - do - if [ "$varname" != "" ]; - then - say " ${g}+${x} $varname" - inc_env="${inc_env}${varname}=$(eval echo "\$${varname}") -" - fi - done - -echo "$inc_env<<<<<< ENV" >> "$upload_file" -fi - -# Append git file list -# write discovered yaml location -echo "$yaml" >> "$upload_file" -if [ "$ft_network" == "1" ]; -then - i="woff|eot|otf" # fonts - i="$i|gif|png|jpg|jpeg|psd" # images - i="$i|ptt|pptx|numbers|pages|md|txt|xlsx|docx|doc|pdf|csv" # docs - i="$i|yml|yaml|.gitignore" # supporting docs - - if [ "$ft_html" != "1" ]; - then - i="$i|html" - fi - - echo "$network" | grep -vwE "($i)$" >> "$upload_file" -fi -echo "<<<<<< network" >> "$upload_file" - -fr=0 -say "${e}==>${x} Reading reports" -while IFS='' read -r file; -do - # read the coverage file - if [ "$(echo "$file" | tr -d ' ')" != '' ]; - then - if [ -f "$file" ]; - then - report_len=$(wc -c < "$file") - if [ "$report_len" -ne 0 ]; - then - say " ${g}+${x} $file ${e}bytes=$(echo "$report_len" | tr -d ' ')${x}" - # append to to upload - _filename=$(basename "$file") - if [ "${_filename##*.}" = 'gcov' ]; - then - { - echo "# path=$(echo "$file.reduced" | sed "s|^$git_root/||")"; - # get file name - head -1 "$file"; - } >> "$upload_file" - # 1. remove source code - # 2. remove ending bracket lines - # 3. remove whitespace - # 4. remove contextual lines - # 5. remove function names - awk -F': *' '{print $1":"$2":"}' "$file" \ - | sed '\/: *} *$/d' \ - | sed 's/^ *//' \ - | sed '/^-/d' \ - | sed 's/^function.*/func/' >> "$upload_file" - else - { - echo "# path=${file//^$git_root/||}"; - cat "$file"; - } >> "$upload_file" - fi - echo "<<<<<< EOF" >> "$upload_file" - fr=1 - if [ "$clean" = "1" ]; - then - rm "$file" - fi - else - say " ${r}-${x} Skipping empty file $file" - fi - else - say " ${r}-${x} file not found at $file" - fi - fi -done <<< "$(echo -e "$files")" - -if [ "$fr" = "0" ]; -then - say "${r}-->${x} No coverage data found." - say " Please visit ${b}http://docs.codecov.io/docs/supported-languages${x}" - say " search for your projects language to learn how to collect reports." - exit ${exit_with}; -fi - -if [ "$ft_fix" = "1" ]; -then - say "${e}==>${x} Appending adjustments" - say " ${b}https://docs.codecov.io/docs/fixing-reports${x}" - - empty_line='^[[:space:]]*$' - # // - syntax_comment='^[[:space:]]*//.*' - # /* or */ - syntax_comment_block='^[[:space:]]*(\/\*|\*\/)[[:space:]]*$' - # { or } - syntax_bracket='^[[:space:]]*[\{\}][[:space:]]*(//.*)?$' - # [ or ] - syntax_list='^[[:space:]]*[][][[:space:]]*(//.*)?$' - # func ... { - syntax_go_func='^[[:space:]]*[func].*[\{][[:space:]]*$' - - # shellcheck disable=SC2089 - skip_dirs="-not -path '*/$bower_components/*' \ - -not -path '*/node_modules/*'" - - cut_and_join() { - awk 'BEGIN { FS=":" } - $3 ~ /\/\*/ || $3 ~ /\*\// { print $0 ; next } - $1!=key { if (key!="") print out ; key=$1 ; out=$1":"$2 ; next } - { out=out","$2 } - END { print out }' 2>/dev/null - } - - if echo "$network" | grep -m1 '.kt$' 1>/dev/null; - then - # skip brackets and comments - cd "$git_root" && \ - find . -type f \ - -name '*.kt' \ - -exec \ - grep -nIHE -e "$syntax_bracket" \ - -e "$syntax_comment_block" {} \; \ - | cut_and_join \ - >> "$adjustments_file" \ - || echo '' - - # last line in file - cd "$git_root" && \ - find . -type f \ - -name '*.kt' -exec \ - wc -l {} \; \ - | while read -r l; do echo "EOF: $l"; done \ - 2>/dev/null \ - >> "$adjustments_file" \ - || echo '' - fi - - if echo "$network" | grep -m1 '.go$' 1>/dev/null; - then - # skip empty lines, comments, and brackets - cd "$git_root" && \ - find . -type f \ - -not -path '*/vendor/*' \ - -not -path '*/caches/*' \ - -name '*.go' \ - -exec \ - grep -nIHE \ - -e "$empty_line" \ - -e "$syntax_comment" \ - -e "$syntax_comment_block" \ - -e "$syntax_bracket" \ - -e "$syntax_go_func" \ - {} \; \ - | cut_and_join \ - >> "$adjustments_file" \ - || echo '' - fi - - if echo "$network" | grep -m1 '.dart$' 1>/dev/null; - then - # skip brackets - cd "$git_root" && \ - find . -type f \ - -name '*.dart' \ - -exec \ - grep -nIHE \ - -e "$syntax_bracket" \ - {} \; \ - | cut_and_join \ - >> "$adjustments_file" \ - || echo '' - fi - - if echo "$network" | grep -m1 '.php$' 1>/dev/null; - then - # skip empty lines, comments, and brackets - cd "$git_root" && \ - find . -type f \ - -not -path "*/vendor/*" \ - -name '*.php' \ - -exec \ - grep -nIHE \ - -e "$syntax_list" \ - -e "$syntax_bracket" \ - -e '^[[:space:]]*\);[[:space:]]*(//.*)?$' \ - {} \; \ - | cut_and_join \ - >> "$adjustments_file" \ - || echo '' - fi - - if echo "$network" | grep -m1 '\(.c\.cpp\|.cxx\|.h\|.hpp\|.m\|.swift\|.vala\)$' 1>/dev/null; - then - # skip brackets - # shellcheck disable=SC2086,SC2090 - cd "$git_root" && \ - find . -type f \ - $skip_dirs \ - \( \ - -name '*.c' \ - -or -name '*.cpp' \ - -or -name '*.cxx' \ - -or -name '*.h' \ - -or -name '*.hpp' \ - -or -name '*.m' \ - -or -name '*.swift' \ - -or -name '*.vala' \ - \) -exec \ - grep -nIHE \ - -e "$empty_line" \ - -e "$syntax_bracket" \ - -e '// LCOV_EXCL' \ - {} \; \ - | cut_and_join \ - >> "$adjustments_file" \ - || echo '' - - # skip brackets - # shellcheck disable=SC2086,SC2090 - cd "$git_root" && \ - find . -type f \ - $skip_dirs \ - \( \ - -name '*.c' \ - -or -name '*.cpp' \ - -or -name '*.cxx' \ - -or -name '*.h' \ - -or -name '*.hpp' \ - -or -name '*.m' \ - -or -name '*.swift' \ - -or -name '*.vala' \ - \) -exec \ - grep -nIH '// LCOV_EXCL' \ - {} \; \ - >> "$adjustments_file" \ - || echo '' - - fi - - found=$(< "$adjustments_file" tr -d ' ') - - if [ "$found" != "" ]; - then - say " ${g}+${x} Found adjustments" - { - echo "# path=fixes"; - cat "$adjustments_file"; - echo "<<<<<< EOF"; - } >> "$upload_file" - rm -rf "$adjustments_file" - else - say " ${e}->${x} No adjustments found" - fi -fi - -if [ "$url_o" != "" ]; -then - url="$url_o" -fi - -if [ "$dump" != "0" ]; -then - # trim whitespace from query - say " ${e}->${x} Dumping upload file (no upload)" - echo "$url/upload/v4?$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ')" - cat "$upload_file" -else - if [ "$save_to" != "" ]; - then - say "${e}==>${x} Copying upload file to ${save_to}" - cp "$upload_file" "$save_to" - fi - - say "${e}==>${x} Gzipping contents" - gzip -nf9 "$upload_file" - say " $(du -h "$upload_file.gz")" - - query=$(echo "${query}" | tr -d ' ') - say "${e}==>${x} Uploading reports" - say " ${e}url:${x} $url" - say " ${e}query:${x} $query" - - # Full query without token (to display on terminal output) - queryNoToken=$(echo "package=$package-$VERSION&token=secret&$query" | tr -d ' ') - # now add token to query - query=$(echo "package=$package-$VERSION&token=$token&$query" | tr -d ' ') - - if [ "$ft_s3" = "1" ]; - then - say "${e}->${x} Pinging Codecov" - say "$url/upload/v4?$queryNoToken" - # shellcheck disable=SC2086,2090 - res=$(curl $curl_s -X POST $cacert \ - --retry 5 --retry-delay 2 --connect-timeout 2 \ - -H 'X-Reduced-Redundancy: false' \ - -H 'X-Content-Type: application/x-gzip' \ - -H 'Content-Length: 0' \ - --write-out "\n%{response_code}\n" \ - $curlargs \ - "$url/upload/v4?$query" || true) - # a good reply is "https://codecov.io" + "\n" + "https://storage.googleapis.com/codecov/..." - s3target=$(echo "$res" | sed -n 2p) - status=$(tail -n1 <<< "$res") - - if [ "$status" = "200" ] && [ "$s3target" != "" ]; - then - say "${e}->${x} Uploading to" - say "${s3target}" - - # shellcheck disable=SC2086 - s3=$(curl -fiX PUT \ - --data-binary @"$upload_file.gz" \ - -H 'Content-Type: application/x-gzip' \ - -H 'Content-Encoding: gzip' \ - $curlawsargs \ - "$s3target" || true) - - if [ "$s3" != "" ]; - then - say " ${g}->${x} View reports at ${b}$(echo "$res" | sed -n 1p)${x}" - exit 0 - else - say " ${r}X>${x} Failed to upload" - fi - elif [ "$status" = "400" ]; - then - # 400 Error - say "${r}${res}${x}" - exit ${exit_with} - else - say "${r}${res}${x}" - fi - fi - - say "${e}==>${x} Uploading to Codecov" - - # shellcheck disable=SC2086,2090 - res=$(curl -X POST $cacert \ - --data-binary @"$upload_file.gz" \ - --retry 5 --retry-delay 2 --connect-timeout 2 \ - -H 'Content-Type: text/plain' \ - -H 'Content-Encoding: gzip' \ - -H 'X-Content-Encoding: gzip' \ - -H 'Accept: text/plain' \ - $curlargs \ - "$url/upload/v2?$query&attempt=$i" || echo 'HTTP 500') - # HTTP 200 - # http://.... - status=$(echo "$res" | head -1 | cut -d' ' -f2) - if [ "$status" = "" ] || [ "$status" = "200" ]; - then - say " View reports at ${b}$(echo "$res" | head -2 | tail -1)${x}" - exit 0 - else - say " ${g}${res}${x}" - exit ${exit_with} - fi - - say " ${r}X> Failed to upload coverage reports${x}" -fi - -exit ${exit_with} From 27a4acecbb258756730a48288334942b4d5a6b9b Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:30:42 -0500 Subject: [PATCH 13/23] Split out buildExec --- dist/index.js | 311 ++++++++++++----------- src/{index.test.ts => buildExec.test.ts} | 2 +- src/buildExec.ts | 103 ++++++++ src/index.ts | 102 +------- 4 files changed, 265 insertions(+), 253 deletions(-) rename src/{index.test.ts => buildExec.test.ts} (88%) create mode 100644 src/buildExec.ts diff --git a/dist/index.js b/dist/index.js index 4d8d936fd..7a64c971a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12298,159 +12298,11 @@ module.exports = {"$id":"log.json#","$schema":"http://json-schema.org/draft-06/s "use strict"; exports.__esModule = true; -exports.buildExec = void 0; var core = __webpack_require__(470); var exec = __webpack_require__(986); var fs = __webpack_require__(747); var request = __webpack_require__(335); -var isTrue = function (variable) { - var lowercase = variable.toLowerCase(); - return (lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes"); -}; -var buildExec = function () { - var clean = core.getInput("move_coverage_to_trash"); - var commit_parent = core.getInput("commit_parent"); - var curl_aws_args = core.getInput("aws_curl_args"); - var curl_codecov_args = core.getInput("codecov_curl_args"); - var env_vars = core.getInput("env_vars"); - var fail_ci = isTrue(core.getInput("fail_ci_if_error")); - var file = core.getInput("file"); - var files = core.getInput("files"); - var flags = core.getInput("flags"); - var functionalities = core.getInput("functionalities"); - var gcov_args = core.getInput("gcov_args"); - var gcov_dir = core.getInput("gcov_root_dir"); - var gcov_exclude = core.getInput("gcov_path_exclude"); - var gcov_exec = core.getInput("gcov_executable"); - var gcov_include = core.getInput("gcov_path_include"); - var gcov_prefix = core.getInput("gcov_prefix"); - var name = core.getInput("name"); - var override_branch = core.getInput("override_branch"); - var override_build = core.getInput("override_build"); - var override_commit = core.getInput("override_commit"); - var override_pr = core.getInput("override_pr"); - var override_tag = core.getInput("override_tag"); - var root_dir = core.getInput("root_dir"); - var search_dir = core.getInput("directory"); - var token = core.getInput("token"); - var verbose = isTrue(core.getInput("verbose")); - var working_dir = core.getInput("working_directory"); - var write_path = core.getInput("path_to_write_report"); - var xcode_derived_data = core.getInput("xcode_derived_data"); - var xcode_package = core.getInput("xcode_package"); - var filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh"; - var execArgs = [filepath]; - execArgs.push("-n", "" + name, "-F", "" + flags, "-Q", "github-action"); - var options = {}; - options.env = Object.assign(process.env, { - GITHUB_ACTION: process.env.GITHUB_ACTION, - GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, - GITHUB_REF: process.env.GITHUB_REF, - GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, - GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' - }); - var env_vars_arg = []; - for (var _i = 0, _a = env_vars.split(","); _i < _a.length; _i++) { - var env_var = _a[_i]; - var env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean); - } - } - if (token) { - options.env.CODECOV_TOKEN = token; - } - 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 (file) { - execArgs.push("-f", "" + file); - } - if (files) { - files.split(',').forEach(function (f) { execArgs.push("-f", "" + f); }); - } - if (functionalities) { - functionalities.split(',').forEach(function (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); - } - return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; -}; -exports.buildExec = buildExec; +var buildExec_1 = __webpack_require__(983); var fail_ci; try { request({ @@ -12459,7 +12311,7 @@ try { timeout: 3000, url: "https://codecov.io/bash" }, function (error, response, body) { - var _a = buildExec(), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; + var _a = buildExec_1["default"](), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; try { if (error && fail_ci) { throw error; @@ -54242,7 +54094,164 @@ function write(key, options) { /***/ }), -/* 983 */, +/* 983 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +exports.__esModule = true; +var core = __webpack_require__(470); +var isTrue = function (variable) { + var lowercase = variable.toLowerCase(); + return (lowercase === "1" || + lowercase === "t" || + lowercase === "true" || + lowercase === "y" || + lowercase === "yes"); +}; +var buildExec = function () { + var clean = core.getInput("move_coverage_to_trash"); + var commit_parent = core.getInput("commit_parent"); + var curl_aws_args = core.getInput("aws_curl_args"); + var curl_codecov_args = core.getInput("codecov_curl_args"); + var env_vars = core.getInput("env_vars"); + var fail_ci = isTrue(core.getInput("fail_ci_if_error")); + var file = core.getInput("file"); + var files = core.getInput("files"); + var flags = core.getInput("flags"); + var functionalities = core.getInput("functionalities"); + var gcov_args = core.getInput("gcov_args"); + var gcov_dir = core.getInput("gcov_root_dir"); + var gcov_exclude = core.getInput("gcov_path_exclude"); + var gcov_exec = core.getInput("gcov_executable"); + var gcov_include = core.getInput("gcov_path_include"); + var gcov_prefix = core.getInput("gcov_prefix"); + var name = core.getInput("name"); + var override_branch = core.getInput("override_branch"); + var override_build = core.getInput("override_build"); + var override_commit = core.getInput("override_commit"); + var override_pr = core.getInput("override_pr"); + var override_tag = core.getInput("override_tag"); + var root_dir = core.getInput("root_dir"); + var search_dir = core.getInput("directory"); + var token = core.getInput("token"); + var verbose = isTrue(core.getInput("verbose")); + var working_dir = core.getInput("working_directory"); + var write_path = core.getInput("path_to_write_report"); + var xcode_derived_data = core.getInput("xcode_derived_data"); + var xcode_package = core.getInput("xcode_package"); + var filepath = working_dir ? + working_dir + "/codecov.sh" : "codecov.sh"; + var execArgs = [filepath]; + execArgs.push("-n", "" + name, "-F", "" + flags, "-Q", "github-action"); + var options = {}; + options.env = Object.assign(process.env, { + GITHUB_ACTION: process.env.GITHUB_ACTION, + GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, + GITHUB_REF: process.env.GITHUB_REF, + GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, + GITHUB_SHA: process.env.GITHUB_SHA, + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + }); + var env_vars_arg = []; + for (var _i = 0, _a = env_vars.split(","); _i < _a.length; _i++) { + var env_var = _a[_i]; + var env_var_clean = env_var.trim(); + if (env_var_clean) { + options.env[env_var_clean] = process.env[env_var_clean]; + env_vars_arg.push(env_var_clean); + } + } + if (token) { + options.env.CODECOV_TOKEN = token; + } + 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 (file) { + execArgs.push("-f", "" + file); + } + if (files) { + files.split(',').forEach(function (f) { execArgs.push("-f", "" + f); }); + } + if (functionalities) { + functionalities.split(',').forEach(function (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); + } + return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; +}; +exports["default"] = buildExec; + + +/***/ }), /* 984 */, /* 985 */ /***/ (function(module) { diff --git a/src/index.test.ts b/src/buildExec.test.ts similarity index 88% rename from src/index.test.ts rename to src/buildExec.test.ts index 7fe6b809d..6412b6b57 100644 --- a/src/index.test.ts +++ b/src/buildExec.test.ts @@ -1,4 +1,4 @@ -import { buildExec } from "./index"; +import buildExec from "./buildExec"; test('no arguments', () => { let { execArgs, options, filepath, fail_ci } = buildExec(); diff --git a/src/buildExec.ts b/src/buildExec.ts new file mode 100644 index 000000000..537f2a600 --- /dev/null +++ b/src/buildExec.ts @@ -0,0 +1,103 @@ +const core = require("@actions/core"); + +let isTrue = (variable) => { + const lowercase = variable.toLowerCase(); + return ( + lowercase === "1" || + lowercase === "t" || + lowercase === "true" || + lowercase === "y" || + lowercase === "yes" + ); +} + +let buildExec = () => { + const clean = core.getInput("move_coverage_to_trash"); + const commit_parent = core.getInput("commit_parent"); + const curl_aws_args = core.getInput("aws_curl_args"); + const curl_codecov_args = core.getInput("codecov_curl_args"); + const env_vars = core.getInput("env_vars"); + const fail_ci = isTrue(core.getInput("fail_ci_if_error")); + const file = core.getInput("file"); + const files = core.getInput("files"); + const flags = core.getInput("flags"); + const functionalities = core.getInput("functionalities"); + const gcov_args = core.getInput("gcov_args"); + const gcov_dir = core.getInput("gcov_root_dir"); + const gcov_exclude = core.getInput("gcov_path_exclude"); + const gcov_exec = core.getInput("gcov_executable"); + const gcov_include = core.getInput("gcov_path_include"); + const gcov_prefix = core.getInput("gcov_prefix"); + const name = core.getInput("name"); + const override_branch = core.getInput("override_branch"); + const override_build = core.getInput("override_build"); + const override_commit = core.getInput("override_commit"); + const override_pr = core.getInput("override_pr"); + const override_tag = core.getInput("override_tag"); + const root_dir = core.getInput("root_dir"); + const search_dir = core.getInput("directory"); + const token = core.getInput("token"); + const verbose = isTrue(core.getInput("verbose")); + const working_dir = core.getInput("working_directory"); + const write_path = core.getInput("path_to_write_report"); + const xcode_derived_data = core.getInput("xcode_derived_data"); + const xcode_package = core.getInput("xcode_package"); + + const filepath = working_dir ? + working_dir + "/codecov.sh" : "codecov.sh" + + const execArgs = [filepath]; + execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); + + const options:any = {}; + options.env = Object.assign(process.env, { + GITHUB_ACTION: process.env.GITHUB_ACTION, + GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, + GITHUB_REF: process.env.GITHUB_REF, + GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, + GITHUB_SHA: process.env.GITHUB_SHA, + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + }); + + const env_vars_arg = [] + for (let env_var of env_vars.split(",")) { + let env_var_clean = env_var.trim(); + if (env_var_clean) { + options.env[env_var_clean] = process.env[env_var_clean]; + env_vars_arg.push(env_var_clean) + } + } + + if (token) { options.env.CODECOV_TOKEN = token } + 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 (file) { execArgs.push("-f", `${file}`); } + 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}`); } + + return { execArgs, options, filepath, fail_ci }; +} + +export default buildExec; diff --git a/src/index.ts b/src/index.ts index ebfb97597..5162fa70f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,105 +3,7 @@ const exec = require("@actions/exec"); const fs = require("fs"); const request = require('requestretry'); -let isTrue = (variable) => { - const lowercase = variable.toLowerCase(); - return ( - lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes" - ); -} - -let buildExec = () => { - const clean = core.getInput("move_coverage_to_trash"); - const commit_parent = core.getInput("commit_parent"); - const curl_aws_args = core.getInput("aws_curl_args"); - const curl_codecov_args = core.getInput("codecov_curl_args"); - const env_vars = core.getInput("env_vars"); - const fail_ci = isTrue(core.getInput("fail_ci_if_error")); - const file = core.getInput("file"); - const files = core.getInput("files"); - const flags = core.getInput("flags"); - const functionalities = core.getInput("functionalities"); - const gcov_args = core.getInput("gcov_args"); - const gcov_dir = core.getInput("gcov_root_dir"); - const gcov_exclude = core.getInput("gcov_path_exclude"); - const gcov_exec = core.getInput("gcov_executable"); - const gcov_include = core.getInput("gcov_path_include"); - const gcov_prefix = core.getInput("gcov_prefix"); - const name = core.getInput("name"); - const override_branch = core.getInput("override_branch"); - const override_build = core.getInput("override_build"); - const override_commit = core.getInput("override_commit"); - const override_pr = core.getInput("override_pr"); - const override_tag = core.getInput("override_tag"); - const root_dir = core.getInput("root_dir"); - const search_dir = core.getInput("directory"); - const token = core.getInput("token"); - const verbose = isTrue(core.getInput("verbose")); - const working_dir = core.getInput("working_directory"); - const write_path = core.getInput("path_to_write_report"); - const xcode_derived_data = core.getInput("xcode_derived_data"); - const xcode_package = core.getInput("xcode_package"); - - const filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh" - - const execArgs = [filepath]; - execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); - - const options:any = {}; - options.env = Object.assign(process.env, { - GITHUB_ACTION: process.env.GITHUB_ACTION, - GITHUB_RUN_ID: process.env.GITHUB_RUN_ID, - GITHUB_REF: process.env.GITHUB_REF, - GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, - GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' - }); - - const env_vars_arg = [] - for (let env_var of env_vars.split(",")) { - let env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean) - } - } - - if (token) { options.env.CODECOV_TOKEN = token } - 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 (file) { execArgs.push("-f", `${file}`); } - 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}`); } - - return { execArgs, options, filepath, fail_ci }; -} +import buildExec from "./buildExec"; let fail_ci; try { @@ -175,5 +77,3 @@ try { core.warning(`Codecov warning: ${error.message}`); } } - -export { buildExec }; From 1794277aa55d4577e781afe76d4dc476ba794a52 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:44:08 -0500 Subject: [PATCH 14/23] Add test --- src/buildExec.test.ts | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index 6412b6b57..64f991595 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -14,3 +14,59 @@ test('no arguments', () => { expect(filepath).toEqual('codecov.sh'); expect(fail_ci).toBeFalsy(); }); + +test('all arguments', () => { + const envs = { + "move_coverage_to_trash": "true", + "commit_parent": "83231650328f11695dfb754ca0f540516f188d27", + "aws_curl_args": "--timeout 1", + "codecov_curl_args": "--timeout 2", + "env_vars": "OS,PYTHON", + "fail_ci_if_error": "true", + "file": "coverage.xml", + "files": "dir1/coverage.xml,dir2/coverage.xml", + "flags": "test", + "functionalities" : "gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs", + "gcov_args": "--timeout 3", + "gcov_root_dr": "gcov_dir/", + "gcov_path_exclude": "**/exclude-dir/*.*", + "gcov_executable": "gcov", + "gcov_path_include": "**/include-dir/*.*", + "gcov_prefix": "demo", + "name": "codecov", + "override_branch": "thomasrockhu/test", + "override_build": "1", + "override_commit": "9caabca5474b49de74ef5667deabaf74cdacc244", + "override_pr": "2", + "override_tag": "v1.2", + "root_dir": "root/", + "directory": "coverage/", + "token": "d3859757-ab80-4664-924d-aef22fa7557b", + "verbose": "t", + "working-directory": "src/", + "path_to_write_report": "codecov/", + "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", + "xcode_package": "MyApp" + } + + for (let env of Object.keys(envs)) { + process.env[env] = envs[env]; + } + + let { execArgs, options, filepath, fail_ci } = buildExec(); + expect(execArgs).toEqual([ + "codecov.sh", + "-n", + "", + "-F", + "", + "-Q", + "github-action" + ]); + expect(filepath).toEqual('codecov.sh'); + expect(fail_ci).toBeFalsy(); + + for (let env of Object.keys(envs)) { + delete process.env[env]; + } +}); From 853e99ac9de08061d8a21daa312fc4b3847d7a3b Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:47:08 -0500 Subject: [PATCH 15/23] Update test --- src/buildExec.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index 64f991595..0e51500b8 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -43,14 +43,14 @@ test('all arguments', () => { "directory": "coverage/", "token": "d3859757-ab80-4664-924d-aef22fa7557b", "verbose": "t", - "working-directory": "src/", + "working_directory": "src/", "path_to_write_report": "codecov/", "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", "xcode_package": "MyApp" } for (let env of Object.keys(envs)) { - process.env[env] = envs[env]; + process.env["INPUT_" + env.toUpperCase()] = envs[env]; } let { execArgs, options, filepath, fail_ci } = buildExec(); @@ -67,6 +67,6 @@ test('all arguments', () => { expect(fail_ci).toBeFalsy(); for (let env of Object.keys(envs)) { - delete process.env[env]; + delete process.env["INPUT_" + env.toUpperCase()]; } }); From 40b489d7978ad3f7cd8349df29981f82963bb69a Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:51:07 -0500 Subject: [PATCH 16/23] Fix test --- src/buildExec.test.ts | 79 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index 0e51500b8..eff7b176e 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -43,7 +43,7 @@ test('all arguments', () => { "directory": "coverage/", "token": "d3859757-ab80-4664-924d-aef22fa7557b", "verbose": "t", - "working_directory": "src/", + "working_directory": "src", "path_to_write_report": "codecov/", "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", "xcode_package": "MyApp" @@ -55,16 +55,81 @@ test('all arguments', () => { let { execArgs, options, filepath, fail_ci } = buildExec(); expect(execArgs).toEqual([ - "codecov.sh", + "src/codecov.sh", "-n", - "", + "codecov", "-F", - "", + "test", "-Q", - "github-action" + "github-action", + "-c", + "-N", + "83231650328f11695dfb754ca0f540516f188d27", + "-A", + "--timeout 1", + "-U", + "--timeout 2", + "-e", + "OS,PYTHON", + "-Z", + "-f", + "coverage.xml", + "-f", + "dir1/coverage.xml", + "-f", + "dir2/coverage.xml", + "-X", + "gcov", + "-X", + "coveragepy", + "-X", + "fix", + "-X", + "search", + "-X", + "code", + "-X", + "network", + "-X", + "gcovout", + "-X", + "html", + "-X", + "recursesubs", + "-a", + "--timeout 3", + "-g", + "**/exclude-dir/*.*", + "-x", + "gcov", + "-G", + "**/include-dir/*.*", + "-k", + "demo", + "-B", + "thomasrockhu/test", + "-b", + "1", + "-C", + "9caabca5474b49de74ef5667deabaf74cdacc244", + "-P", + "2", + "-T", + "v1.2", + "-N", + "root/", + "-s", + "coverage/", + "-v", + "-q", + "codecov/", + "-D", + "~/Library/Developer/Xcode/DerivedData", + "-J", + "MyApp", ]); - expect(filepath).toEqual('codecov.sh'); - expect(fail_ci).toBeFalsy(); + expect(filepath).toEqual('src/codecov.sh'); + expect(fail_ci).toBeTruthy(); for (let env of Object.keys(envs)) { delete process.env["INPUT_" + env.toUpperCase()]; From be4e2a5e02c7ae31368a8d2cb5664feb42e0e15b Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 18:53:08 -0500 Subject: [PATCH 17/23] Update changelog --- CHANGELOG.md | 4 ++-- README.md | 2 +- dist/index.js | 2 +- src/buildExec.test.ts | 2 +- src/buildExec.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb0da808..45fac3847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ ### 1.2.0 #### Features -- #185 [Placeholder] +- #193 Add all the bash params #### Fixes -- #185 [Placeholder] +- #193 Fixes issue with working-directory ### 1.1.1 diff --git a/README.md b/README.md index c523faaff..94b726f66 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Codecov's Action currently supports five inputs from the user: `token`, `file`, | `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 diff --git a/dist/index.js b/dist/index.js index 7a64c971a..a158a78be 100644 --- a/dist/index.js +++ b/dist/index.js @@ -54136,7 +54136,7 @@ var buildExec = function () { var search_dir = core.getInput("directory"); var token = core.getInput("token"); var verbose = isTrue(core.getInput("verbose")); - var working_dir = core.getInput("working_directory"); + var working_dir = core.getInput("working-directory"); var write_path = core.getInput("path_to_write_report"); var xcode_derived_data = core.getInput("xcode_derived_data"); var xcode_package = core.getInput("xcode_package"); diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index eff7b176e..2c584b5e5 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -43,7 +43,7 @@ test('all arguments', () => { "directory": "coverage/", "token": "d3859757-ab80-4664-924d-aef22fa7557b", "verbose": "t", - "working_directory": "src", + "working-directory": "src", "path_to_write_report": "codecov/", "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", "xcode_package": "MyApp" diff --git a/src/buildExec.ts b/src/buildExec.ts index 537f2a600..d4d2e2434 100644 --- a/src/buildExec.ts +++ b/src/buildExec.ts @@ -38,7 +38,7 @@ let buildExec = () => { const search_dir = core.getInput("directory"); const token = core.getInput("token"); const verbose = isTrue(core.getInput("verbose")); - const working_dir = core.getInput("working_directory"); + const working_dir = core.getInput("working-directory"); const write_path = core.getInput("path_to_write_report"); const xcode_derived_data = core.getInput("xcode_derived_data"); const xcode_package = core.getInput("xcode_package"); From 4dcb7122e5b9310d72bf576c12a2a329e9e1ae65 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:01:39 -0500 Subject: [PATCH 18/23] lint --- .eslintrc.json | 19 +++ .github/workflows/main.yml | 12 +- package-lock.json | 252 ++++++++++++++++++++++++++++++++++++- package.json | 9 +- 4 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..a31470ac6 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,19 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es2021": true + }, + "extends": [ + "google" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 12 + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + } +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84d4795a2..9c1c137b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,11 +5,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 + with: + fetch-depth: 2 - name: Install dependencies - run: npm install + run: | + npm install + npm i -g eslint + - name: Lint + run: npm run lint - name: Run tests and collect coverage - run: yarn run test-all + run: yarn run test - name: Upload coverage to Codecov (demo) uses: ./ with: diff --git a/package-lock.json b/package-lock.json index 38e10a9b0..3be381490 100644 --- a/package-lock.json +++ b/package-lock.json @@ -433,6 +433,12 @@ "requires": { "type-fest": "^0.8.1" } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true } } }, @@ -947,6 +953,32 @@ "chalk": "^4.0.0" } }, + "@nodelib/fs.scandir": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", + "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.4", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", + "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", + "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.4", + "fastq": "^1.6.0" + } + }, "@sinonjs/commons": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.1.tgz", @@ -1043,6 +1075,12 @@ "pretty-format": "^26.0.0" } }, + "@types/json-schema": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz", + "integrity": "sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==", + "dev": true + }, "@types/node": { "version": "14.6.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz", @@ -1076,6 +1114,111 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-15.0.0.tgz", "integrity": "sha512-FA/BWv8t8ZWJ+gEOnLLd8ygxH/2UFbAvgEonyfN6yWGLKc7zVjbpl2Y4CTjid9h2RfgPP6SEt6uHwEOply00yw==" }, + "@typescript-eslint/eslint-plugin": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.11.1.tgz", + "integrity": "sha512-fABclAX2QIEDmTMk6Yd7Muv1CzFLwWM4505nETzRHpP3br6jfahD9UUJkhnJ/g2m7lwfz8IlswcwGGPGiq9exw==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "4.11.1", + "@typescript-eslint/scope-manager": "4.11.1", + "debug": "^4.1.1", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + }, + "dependencies": { + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/experimental-utils": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.11.1.tgz", + "integrity": "sha512-mAlWowT4A6h0TC9F+J5pdbEhjNiEMO+kqPKQ4sc3fVieKL71dEqfkKgtcFVSX3cjSBwYwhImaQ/mXQF0oaI38g==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.11.1.tgz", + "integrity": "sha512-BJ3jwPQu1jeynJ5BrjLuGfK/UJu6uwHxJ/di7sanqmUmxzmyIcd3vz58PMR7wpi8k3iWq2Q11KMYgZbUpRoIPw==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "4.11.1", + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/typescript-estree": "4.11.1", + "debug": "^4.1.1" + } + }, + "@typescript-eslint/scope-manager": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.11.1.tgz", + "integrity": "sha512-Al2P394dx+kXCl61fhrrZ1FTI7qsRDIUiVSuN6rTwss6lUn8uVO2+nnF4AvO0ug8vMsy3ShkbxLu/uWZdTtJMQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1" + } + }, + "@typescript-eslint/types": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.11.1.tgz", + "integrity": "sha512-5kvd38wZpqGY4yP/6W3qhYX6Hz0NwUbijVsX2rxczpY6OXaMxh0+5E5uLJKVFwaBM7PJe1wnMym85NfKYIh6CA==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.11.1.tgz", + "integrity": "sha512-tC7MKZIMRTYxQhrVAFoJq/DlRwv1bnqA4/S2r3+HuHibqvbrPcyf858lNzU7bFmy4mLeIHFYr34ar/1KumwyRw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "@typescript-eslint/visitor-keys": "4.11.1", + "debug": "^4.1.1", + "globby": "^11.0.1", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + }, + "dependencies": { + "semver": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", + "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@typescript-eslint/visitor-keys": { + "version": "4.11.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.11.1.tgz", + "integrity": "sha512-IrlBhD9bm4bdYcS8xpWarazkKXlE7iYb1HzRuyBP114mIaj5DJPo11Us1HgH60dTt41TCZXMaTCAW+OILIYPOg==", + "dev": true, + "requires": { + "@typescript-eslint/types": "4.11.1", + "eslint-visitor-keys": "^2.0.0" + } + }, "@zeit/ncc": { "version": "0.22.3", "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz", @@ -1189,6 +1332,12 @@ "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=" }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1745,6 +1894,15 @@ "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-26.6.2.tgz", "integrity": "sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==" }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -1895,6 +2053,12 @@ "type-fest": "^0.8.1" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -1975,6 +2139,12 @@ } } }, + "eslint-config-google": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/eslint-config-google/-/eslint-config-google-0.14.0.tgz", + "integrity": "sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==", + "dev": true + }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -2287,6 +2457,20 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=" }, + "fast-glob": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz", + "integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.0", + "merge2": "^1.3.0", + "micromatch": "^4.0.2", + "picomatch": "^2.2.1" + } + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -2297,6 +2481,15 @@ "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" }, + "fastq": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.10.0.tgz", + "integrity": "sha512-NL2Qc5L3iQEsyYzweq7qfgy5OtXCmGzGvhElGEd/SoFWEMOEczNh5s5ocaF01HDetxz+p8ecjNPA6cZxxIHmzA==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "fb-watchman": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.1.tgz", @@ -2465,6 +2658,20 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, + "globby": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz", + "integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", + "slash": "^3.0.0" + } + }, "graceful-fs": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", @@ -2592,9 +2799,9 @@ } }, "ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "import-fresh": { @@ -4513,6 +4720,12 @@ "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, "micromatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", @@ -4848,6 +5061,12 @@ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -5122,6 +5341,12 @@ "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -5135,6 +5360,12 @@ "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==" }, + "run-parallel": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", + "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", + "dev": true + }, "safe-buffer": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", @@ -5848,6 +6079,21 @@ } } }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tsutils": { + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/package.json b/package.json index db6f247e5..e2bd31278 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,11 @@ "description": "Upload coverage reports to Codecov from GitHub Actions", "main": "index.js", "scripts": { - "test": "jest --coverage", + "lint": "eslint", + "test": "yarn run test-script && yarn run test-calculator && yarn run test-coverage", "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", "test-coverage": "jest --testPathPattern=demo/coverage-test/ --coverage --coverageDirectory=coverage/coverage-test", "test-script": "jest --testPathPattern=src/ --coverage --coverageDirectory=coverage/script", - "test-all": "yarn run test-script && yarn run test-calculator && yarn run test-coverage && eslint", "build": "ncc build src/index.ts" }, "repository": { @@ -37,6 +37,9 @@ "yarn": "^1.22.10" }, "devDependencies": { - "eslint": "^7.17.0" + "@typescript-eslint/eslint-plugin": "^4.11.1", + "@typescript-eslint/parser": "^4.11.1", + "eslint": "^7.17.0", + "eslint-config-google": "^0.14.0" } } From 5dca80cf76e7d5dea3eaca50720b406fcb85c6ac Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:02:52 -0500 Subject: [PATCH 19/23] lint --- dist/index.js | 144 +++++++++++++------------- src/buildExec.test.ts | 234 +++++++++++++++++++++--------------------- src/buildExec.ts | 212 ++++++++++++++++++++++++-------------- src/index.ts | 54 +++++----- 4 files changed, 354 insertions(+), 290 deletions(-) diff --git a/dist/index.js b/dist/index.js index a158a78be..dad764c70 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12309,7 +12309,7 @@ try { json: false, maxAttempts: 10, timeout: 3000, - url: "https://codecov.io/bash" + url: 'https://codecov.io/bash', }, function (error, response, body) { var _a = buildExec_1["default"](), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; try { @@ -12326,17 +12326,17 @@ try { else if (err) { core.warning("Codecov warning: " + err.message); } - var output = ""; - var execError = ""; + var output = ''; + var execError = ''; options.listeners = { stdout: function (data) { output += data.toString(); }, stderr: function (data) { execError += data.toString(); - } + }, }; - exec.exec("bash", execArgs, options)["catch"](function (err) { + exec.exec('bash', execArgs, options)["catch"](function (err) { if (fail_ci) { core.setFailed("Codecov failed with the following error: " + err.message); } @@ -54103,47 +54103,47 @@ exports.__esModule = true; var core = __webpack_require__(470); var isTrue = function (variable) { var lowercase = variable.toLowerCase(); - return (lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes"); + return (lowercase === '1' || + lowercase === 't' || + lowercase === 'true' || + lowercase === 'y' || + lowercase === 'yes'); }; var buildExec = function () { - var clean = core.getInput("move_coverage_to_trash"); - var commit_parent = core.getInput("commit_parent"); - var curl_aws_args = core.getInput("aws_curl_args"); - var curl_codecov_args = core.getInput("codecov_curl_args"); - var env_vars = core.getInput("env_vars"); - var fail_ci = isTrue(core.getInput("fail_ci_if_error")); - var file = core.getInput("file"); - var files = core.getInput("files"); - var flags = core.getInput("flags"); - var functionalities = core.getInput("functionalities"); - var gcov_args = core.getInput("gcov_args"); - var gcov_dir = core.getInput("gcov_root_dir"); - var gcov_exclude = core.getInput("gcov_path_exclude"); - var gcov_exec = core.getInput("gcov_executable"); - var gcov_include = core.getInput("gcov_path_include"); - var gcov_prefix = core.getInput("gcov_prefix"); - var name = core.getInput("name"); - var override_branch = core.getInput("override_branch"); - var override_build = core.getInput("override_build"); - var override_commit = core.getInput("override_commit"); - var override_pr = core.getInput("override_pr"); - var override_tag = core.getInput("override_tag"); - var root_dir = core.getInput("root_dir"); - var search_dir = core.getInput("directory"); - var token = core.getInput("token"); - var verbose = isTrue(core.getInput("verbose")); - var working_dir = core.getInput("working-directory"); - var write_path = core.getInput("path_to_write_report"); - var xcode_derived_data = core.getInput("xcode_derived_data"); - var xcode_package = core.getInput("xcode_package"); + var clean = core.getInput('move_coverage_to_trash'); + var commit_parent = core.getInput('commit_parent'); + var curl_aws_args = core.getInput('aws_curl_args'); + var curl_codecov_args = core.getInput('codecov_curl_args'); + var env_vars = core.getInput('env_vars'); + var fail_ci = isTrue(core.getInput('fail_ci_if_error')); + var file = core.getInput('file'); + var files = core.getInput('files'); + var flags = core.getInput('flags'); + var functionalities = core.getInput('functionalities'); + var gcov_args = core.getInput('gcov_args'); + var gcov_dir = core.getInput('gcov_root_dir'); + var gcov_exclude = core.getInput('gcov_path_exclude'); + var gcov_exec = core.getInput('gcov_executable'); + var gcov_include = core.getInput('gcov_path_include'); + var gcov_prefix = core.getInput('gcov_prefix'); + var name = core.getInput('name'); + var override_branch = core.getInput('override_branch'); + var override_build = core.getInput('override_build'); + var override_commit = core.getInput('override_commit'); + var override_pr = core.getInput('override_pr'); + var override_tag = core.getInput('override_tag'); + var root_dir = core.getInput('root_dir'); + var search_dir = core.getInput('directory'); + var token = core.getInput('token'); + var verbose = isTrue(core.getInput('verbose')); + var working_dir = core.getInput('working-directory'); + var write_path = core.getInput('path_to_write_report'); + var xcode_derived_data = core.getInput('xcode_derived_data'); + var xcode_package = core.getInput('xcode_package'); var filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh"; + working_dir + '/codecov.sh' : 'codecov.sh'; var execArgs = [filepath]; - execArgs.push("-n", "" + name, "-F", "" + flags, "-Q", "github-action"); + execArgs.push('-n', "" + name, '-F', "" + flags, '-Q', 'github-action'); var options = {}; options.env = Object.assign(process.env, { GITHUB_ACTION: process.env.GITHUB_ACTION, @@ -54151,10 +54151,10 @@ var buildExec = function () { GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); var env_vars_arg = []; - for (var _i = 0, _a = env_vars.split(","); _i < _a.length; _i++) { + for (var _i = 0, _a = env_vars.split(','); _i < _a.length; _i++) { var env_var = _a[_i]; var env_var_clean = env_var.trim(); if (env_var_clean) { @@ -54166,85 +54166,89 @@ var buildExec = function () { options.env.CODECOV_TOKEN = token; } if (clean) { - execArgs.push("-c"); + execArgs.push('-c'); } if (commit_parent) { - execArgs.push("-N", "" + commit_parent); + execArgs.push('-N', "" + commit_parent); } if (curl_aws_args) { - execArgs.push("-A", "" + curl_aws_args); + execArgs.push('-A', "" + curl_aws_args); } if (curl_codecov_args) { - execArgs.push("-U", "" + curl_codecov_args); + execArgs.push('-U', "" + curl_codecov_args); } if (env_vars_arg.length) { - execArgs.push("-e", env_vars_arg.join(",")); + execArgs.push('-e', env_vars_arg.join(',')); } if (fail_ci) { - execArgs.push("-Z"); + execArgs.push('-Z'); } if (file) { - execArgs.push("-f", "" + file); + execArgs.push('-f', "" + file); } if (files) { - files.split(',').forEach(function (f) { execArgs.push("-f", "" + f); }); + files.split(',').forEach(function (f) { + execArgs.push('-f', "" + f); + }); } if (functionalities) { - functionalities.split(',').forEach(function (f) { execArgs.push("-X", "" + f); }); + functionalities.split(',').forEach(function (f) { + execArgs.push('-X', "" + f); + }); } if (gcov_args) { - execArgs.push("-a", "" + gcov_args); + execArgs.push('-a', "" + gcov_args); } if (gcov_dir) { - execArgs.push("-p", "" + gcov_dir); + execArgs.push('-p', "" + gcov_dir); } if (gcov_exclude) { - execArgs.push("-g", "" + gcov_exclude); + execArgs.push('-g', "" + gcov_exclude); } if (gcov_exec) { - execArgs.push("-x", "" + gcov_exec); + execArgs.push('-x', "" + gcov_exec); } if (gcov_include) { - execArgs.push("-G", "" + gcov_include); + execArgs.push('-G', "" + gcov_include); } if (gcov_prefix) { - execArgs.push("-k", "" + gcov_prefix); + execArgs.push('-k', "" + gcov_prefix); } if (override_branch) { - execArgs.push("-B", "" + override_branch); + execArgs.push('-B', "" + override_branch); } if (override_build) { - execArgs.push("-b", "" + override_build); + execArgs.push('-b', "" + override_build); } if (override_commit) { - execArgs.push("-C", "" + override_commit); + execArgs.push('-C', "" + override_commit); } if (override_pr) { - execArgs.push("-P", "" + override_pr); + execArgs.push('-P', "" + override_pr); } if (override_tag) { - execArgs.push("-T", "" + override_tag); + execArgs.push('-T', "" + override_tag); } if (root_dir) { - execArgs.push("-N", "" + root_dir); + execArgs.push('-N', "" + root_dir); } if (search_dir) { - execArgs.push("-s", "" + search_dir); + execArgs.push('-s', "" + search_dir); } if (verbose) { - execArgs.push("-v"); + execArgs.push('-v'); } if (working_dir) { options.cwd = working_dir; } if (write_path) { - execArgs.push("-q", "" + write_path); + execArgs.push('-q', "" + write_path); } if (xcode_derived_data) { - execArgs.push("-D", "" + xcode_derived_data); + execArgs.push('-D', "" + xcode_derived_data); } if (xcode_package) { - execArgs.push("-J", "" + xcode_package); + execArgs.push('-J', "" + xcode_package); } return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; }; diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index 2c584b5e5..c4eceef8b 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -1,15 +1,15 @@ -import buildExec from "./buildExec"; +import buildExec from './buildExec'; test('no arguments', () => { - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); expect(execArgs).toEqual([ - "codecov.sh", - "-n", - "", - "-F", - "", - "-Q", - "github-action" + 'codecov.sh', + '-n', + '', + '-F', + '', + '-Q', + 'github-action', ]); expect(filepath).toEqual('codecov.sh'); expect(fail_ci).toBeFalsy(); @@ -17,121 +17,121 @@ test('no arguments', () => { test('all arguments', () => { const envs = { - "move_coverage_to_trash": "true", - "commit_parent": "83231650328f11695dfb754ca0f540516f188d27", - "aws_curl_args": "--timeout 1", - "codecov_curl_args": "--timeout 2", - "env_vars": "OS,PYTHON", - "fail_ci_if_error": "true", - "file": "coverage.xml", - "files": "dir1/coverage.xml,dir2/coverage.xml", - "flags": "test", - "functionalities" : "gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs", - "gcov_args": "--timeout 3", - "gcov_root_dr": "gcov_dir/", - "gcov_path_exclude": "**/exclude-dir/*.*", - "gcov_executable": "gcov", - "gcov_path_include": "**/include-dir/*.*", - "gcov_prefix": "demo", - "name": "codecov", - "override_branch": "thomasrockhu/test", - "override_build": "1", - "override_commit": "9caabca5474b49de74ef5667deabaf74cdacc244", - "override_pr": "2", - "override_tag": "v1.2", - "root_dir": "root/", - "directory": "coverage/", - "token": "d3859757-ab80-4664-924d-aef22fa7557b", - "verbose": "t", - "working-directory": "src", - "path_to_write_report": "codecov/", - "xcode_derived_data": "~/Library/Developer/Xcode/DerivedData", - "xcode_package": "MyApp" - } + 'move_coverage_to_trash': 'true', + 'commit_parent': '83231650328f11695dfb754ca0f540516f188d27', + 'aws_curl_args': '--timeout 1', + 'codecov_curl_args': '--timeout 2', + 'env_vars': 'OS,PYTHON', + 'fail_ci_if_error': 'true', + 'file': 'coverage.xml', + 'files': 'dir1/coverage.xml,dir2/coverage.xml', + 'flags': 'test', + 'functionalities': 'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs', + 'gcov_args': '--timeout 3', + 'gcov_root_dr': 'gcov_dir/', + 'gcov_path_exclude': '**/exclude-dir/*.*', + 'gcov_executable': 'gcov', + 'gcov_path_include': '**/include-dir/*.*', + 'gcov_prefix': 'demo', + 'name': 'codecov', + 'override_branch': 'thomasrockhu/test', + 'override_build': '1', + 'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244', + 'override_pr': '2', + 'override_tag': 'v1.2', + 'root_dir': 'root/', + 'directory': 'coverage/', + 'token': 'd3859757-ab80-4664-924d-aef22fa7557b', + 'verbose': 't', + 'working-directory': 'src', + 'path_to_write_report': 'codecov/', + 'xcode_derived_data': '~/Library/Developer/Xcode/DerivedData', + 'xcode_package': 'MyApp', + }; - for (let env of Object.keys(envs)) { - process.env["INPUT_" + env.toUpperCase()] = envs[env]; + for (const env of Object.keys(envs)) { + process.env['INPUT_' + env.toUpperCase()] = envs[env]; } - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); expect(execArgs).toEqual([ - "src/codecov.sh", - "-n", - "codecov", - "-F", - "test", - "-Q", - "github-action", - "-c", - "-N", - "83231650328f11695dfb754ca0f540516f188d27", - "-A", - "--timeout 1", - "-U", - "--timeout 2", - "-e", - "OS,PYTHON", - "-Z", - "-f", - "coverage.xml", - "-f", - "dir1/coverage.xml", - "-f", - "dir2/coverage.xml", - "-X", - "gcov", - "-X", - "coveragepy", - "-X", - "fix", - "-X", - "search", - "-X", - "code", - "-X", - "network", - "-X", - "gcovout", - "-X", - "html", - "-X", - "recursesubs", - "-a", - "--timeout 3", - "-g", - "**/exclude-dir/*.*", - "-x", - "gcov", - "-G", - "**/include-dir/*.*", - "-k", - "demo", - "-B", - "thomasrockhu/test", - "-b", - "1", - "-C", - "9caabca5474b49de74ef5667deabaf74cdacc244", - "-P", - "2", - "-T", - "v1.2", - "-N", - "root/", - "-s", - "coverage/", - "-v", - "-q", - "codecov/", - "-D", - "~/Library/Developer/Xcode/DerivedData", - "-J", - "MyApp", + 'src/codecov.sh', + '-n', + 'codecov', + '-F', + 'test', + '-Q', + 'github-action', + '-c', + '-N', + '83231650328f11695dfb754ca0f540516f188d27', + '-A', + '--timeout 1', + '-U', + '--timeout 2', + '-e', + 'OS,PYTHON', + '-Z', + '-f', + 'coverage.xml', + '-f', + 'dir1/coverage.xml', + '-f', + 'dir2/coverage.xml', + '-X', + 'gcov', + '-X', + 'coveragepy', + '-X', + 'fix', + '-X', + 'search', + '-X', + 'code', + '-X', + 'network', + '-X', + 'gcovout', + '-X', + 'html', + '-X', + 'recursesubs', + '-a', + '--timeout 3', + '-g', + '**/exclude-dir/*.*', + '-x', + 'gcov', + '-G', + '**/include-dir/*.*', + '-k', + 'demo', + '-B', + 'thomasrockhu/test', + '-b', + '1', + '-C', + '9caabca5474b49de74ef5667deabaf74cdacc244', + '-P', + '2', + '-T', + 'v1.2', + '-N', + 'root/', + '-s', + 'coverage/', + '-v', + '-q', + 'codecov/', + '-D', + '~/Library/Developer/Xcode/DerivedData', + '-J', + 'MyApp', ]); expect(filepath).toEqual('src/codecov.sh'); expect(fail_ci).toBeTruthy(); - for (let env of Object.keys(envs)) { - delete process.env["INPUT_" + env.toUpperCase()]; + for (const env of Object.keys(envs)) { + delete process.env['INPUT_' + env.toUpperCase()]; } }); diff --git a/src/buildExec.ts b/src/buildExec.ts index d4d2e2434..5b4d8569c 100644 --- a/src/buildExec.ts +++ b/src/buildExec.ts @@ -1,53 +1,53 @@ -const core = require("@actions/core"); +const core = require('@actions/core'); -let isTrue = (variable) => { +const isTrue = (variable) => { const lowercase = variable.toLowerCase(); return ( - lowercase === "1" || - lowercase === "t" || - lowercase === "true" || - lowercase === "y" || - lowercase === "yes" + lowercase === '1' || + lowercase === 't' || + lowercase === 'true' || + lowercase === 'y' || + lowercase === 'yes' ); -} +}; -let buildExec = () => { - const clean = core.getInput("move_coverage_to_trash"); - const commit_parent = core.getInput("commit_parent"); - const curl_aws_args = core.getInput("aws_curl_args"); - const curl_codecov_args = core.getInput("codecov_curl_args"); - const env_vars = core.getInput("env_vars"); - const fail_ci = isTrue(core.getInput("fail_ci_if_error")); - const file = core.getInput("file"); - const files = core.getInput("files"); - const flags = core.getInput("flags"); - const functionalities = core.getInput("functionalities"); - const gcov_args = core.getInput("gcov_args"); - const gcov_dir = core.getInput("gcov_root_dir"); - const gcov_exclude = core.getInput("gcov_path_exclude"); - const gcov_exec = core.getInput("gcov_executable"); - const gcov_include = core.getInput("gcov_path_include"); - const gcov_prefix = core.getInput("gcov_prefix"); - const name = core.getInput("name"); - const override_branch = core.getInput("override_branch"); - const override_build = core.getInput("override_build"); - const override_commit = core.getInput("override_commit"); - const override_pr = core.getInput("override_pr"); - const override_tag = core.getInput("override_tag"); - const root_dir = core.getInput("root_dir"); - const search_dir = core.getInput("directory"); - const token = core.getInput("token"); - const verbose = isTrue(core.getInput("verbose")); - const working_dir = core.getInput("working-directory"); - const write_path = core.getInput("path_to_write_report"); - const xcode_derived_data = core.getInput("xcode_derived_data"); - const xcode_package = core.getInput("xcode_package"); +const buildExec = () => { + const clean = core.getInput('move_coverage_to_trash'); + const commit_parent = core.getInput('commit_parent'); + const curl_aws_args = core.getInput('aws_curl_args'); + const curl_codecov_args = core.getInput('codecov_curl_args'); + const env_vars = core.getInput('env_vars'); + const fail_ci = isTrue(core.getInput('fail_ci_if_error')); + const file = core.getInput('file'); + const files = core.getInput('files'); + const flags = core.getInput('flags'); + const functionalities = core.getInput('functionalities'); + const gcov_args = core.getInput('gcov_args'); + const gcov_dir = core.getInput('gcov_root_dir'); + const gcov_exclude = core.getInput('gcov_path_exclude'); + const gcov_exec = core.getInput('gcov_executable'); + const gcov_include = core.getInput('gcov_path_include'); + const gcov_prefix = core.getInput('gcov_prefix'); + const name = core.getInput('name'); + const override_branch = core.getInput('override_branch'); + const override_build = core.getInput('override_build'); + const override_commit = core.getInput('override_commit'); + const override_pr = core.getInput('override_pr'); + const override_tag = core.getInput('override_tag'); + const root_dir = core.getInput('root_dir'); + const search_dir = core.getInput('directory'); + const token = core.getInput('token'); + const verbose = isTrue(core.getInput('verbose')); + const working_dir = core.getInput('working-directory'); + const write_path = core.getInput('path_to_write_report'); + const xcode_derived_data = core.getInput('xcode_derived_data'); + const xcode_package = core.getInput('xcode_package'); const filepath = working_dir ? - working_dir + "/codecov.sh" : "codecov.sh" + working_dir + '/codecov.sh' : 'codecov.sh'; const execArgs = [filepath]; - execArgs.push( "-n", `${name}`, "-F", `${flags}`, "-Q", "github-action" ); + execArgs.push( '-n', `${name}`, '-F', `${flags}`, '-Q', 'github-action' ); const options:any = {}; options.env = Object.assign(process.env, { @@ -56,48 +56,108 @@ let buildExec = () => { GITHUB_REF: process.env.GITHUB_REF, GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY, GITHUB_SHA: process.env.GITHUB_SHA, - GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '' + GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); - const env_vars_arg = [] - for (let env_var of env_vars.split(",")) { - let env_var_clean = env_var.trim(); + const env_vars_arg = []; + for (const env_var of env_vars.split(',')) { + const env_var_clean = env_var.trim(); if (env_var_clean) { options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean) + env_vars_arg.push(env_var_clean); } } - if (token) { options.env.CODECOV_TOKEN = token } - 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 (file) { execArgs.push("-f", `${file}`); } - 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}`); } + if (token) { + options.env.CODECOV_TOKEN = token; + } + 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 (file) { + execArgs.push('-f', `${file}`); + } + 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}`); + } - return { execArgs, options, filepath, fail_ci }; -} + return {execArgs, options, filepath, fail_ci}; +}; export default buildExec; diff --git a/src/index.ts b/src/index.ts index 5162fa70f..4c9abf489 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -const core = require("@actions/core"); -const exec = require("@actions/exec"); -const fs = require("fs"); +const core = require('@actions/core'); +const exec = require('@actions/exec'); +const fs = require('fs'); const request = require('requestretry'); -import buildExec from "./buildExec"; +import buildExec from './buildExec'; let fail_ci; try { @@ -11,9 +11,9 @@ try { json: false, maxAttempts: 10, timeout: 3000, - url: "https://codecov.io/bash" + url: 'https://codecov.io/bash', }, (error, response, body) => { - let { execArgs, options, filepath, fail_ci } = buildExec(); + const {execArgs, options, filepath, fail_ci} = buildExec(); try { if (error && fail_ci) { @@ -22,40 +22,40 @@ try { core.warning(`Codecov warning: ${error.message}`); } - fs.writeFile(filepath, body, err => { + fs.writeFile(filepath, body, (err) => { if (err && fail_ci) { throw err; } else if (err) { core.warning(`Codecov warning: ${err.message}`); } - let output = ""; - let execError = ""; + let output = ''; + let execError = ''; options.listeners = { - stdout: data => { + stdout: (data) => { output += data.toString(); }, - stderr: data => { + stderr: (data) => { execError += data.toString(); - } + }, }; - exec.exec("bash", execArgs, options) - .catch(err => { - if (fail_ci) { - core.setFailed( - `Codecov failed with the following error: ${err.message}` - ); - } else { - core.warning(`Codecov warning: ${err.message}`); - } - }) - .then(() => { - unlinkFile(); - }); + exec.exec('bash', execArgs, options) + .catch((err) => { + if (fail_ci) { + core.setFailed( + `Codecov failed with the following error: ${err.message}`, + ); + } else { + core.warning(`Codecov warning: ${err.message}`); + } + }) + .then(() => { + unlinkFile(); + }); const unlinkFile = () => { - fs.unlink(filepath, err => { + fs.unlink(filepath, (err) => { if (err && fail_ci) { throw err; } else if (err) { @@ -66,7 +66,7 @@ try { }); } catch (error) { core.setFailed( - `Codecov failed with the following error: ${error.message}` + `Codecov failed with the following error: ${error.message}`, ); } }); From 431265badfa053a8ddf425dfa1dcd1a8bda4aa63 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:03:40 -0500 Subject: [PATCH 20/23] Update linter --- hooks/pre-commit | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 034f5ff65..fc777952d 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,6 +1,8 @@ #!/usr/bin/env bash npm i --package-lock-only +npm run lint --fix npm run build +git add src/ git add dist/index.js git add package-lock.json diff --git a/package.json b/package.json index e2bd31278..bce455d70 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Upload coverage reports to Codecov from GitHub Actions", "main": "index.js", "scripts": { - "lint": "eslint", + "lint": "eslint src/*.*", "test": "yarn run test-script && yarn run test-calculator && yarn run test-coverage", "test-calculator": "jest --testPathPattern=demo/calculator/ --coverage --coverageDirectory=coverage/calculator", "test-coverage": "jest --testPathPattern=demo/coverage-test/ --coverage --coverageDirectory=coverage/coverage-test", From 6961e2c69851ecbe7d60bc2164215a429a5f9af3 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:11:49 -0500 Subject: [PATCH 21/23] lint --- dist/index.js | 174 ++++++++++++++++++++---------------------- src/buildExec.test.ts | 11 +-- src/buildExec.ts | 148 +++++++++++++++++------------------ src/index.ts | 25 ++---- 4 files changed, 169 insertions(+), 189 deletions(-) diff --git a/dist/index.js b/dist/index.js index dad764c70..453b59634 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12303,7 +12303,7 @@ var exec = __webpack_require__(986); var fs = __webpack_require__(747); var request = __webpack_require__(335); var buildExec_1 = __webpack_require__(983); -var fail_ci; +var failCi; try { request({ json: false, @@ -12311,33 +12311,23 @@ try { timeout: 3000, url: 'https://codecov.io/bash', }, function (error, response, body) { - var _a = buildExec_1["default"](), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, fail_ci = _a.fail_ci; + var _a = buildExec_1["default"](), execArgs = _a.execArgs, options = _a.options, filepath = _a.filepath, failCi = _a.failCi; try { - if (error && fail_ci) { + if (error && failCi) { throw error; } else if (error) { core.warning("Codecov warning: " + error.message); } fs.writeFile(filepath, body, function (err) { - if (err && fail_ci) { + if (err && failCi) { throw err; } else if (err) { core.warning("Codecov warning: " + err.message); } - var output = ''; - var execError = ''; - options.listeners = { - stdout: function (data) { - output += data.toString(); - }, - stderr: function (data) { - execError += data.toString(); - }, - }; exec.exec('bash', execArgs, options)["catch"](function (err) { - if (fail_ci) { + if (failCi) { core.setFailed("Codecov failed with the following error: " + err.message); } else { @@ -12349,7 +12339,7 @@ try { }); var unlinkFile = function () { fs.unlink(filepath, function (err) { - if (err && fail_ci) { + if (err && failCi) { throw err; } else if (err) { @@ -12365,7 +12355,7 @@ try { }); } catch (error) { - if (fail_ci) { + if (failCi) { core.setFailed("Codecov failed with the following error: " + error.message); } else { @@ -54111,37 +54101,37 @@ var isTrue = function (variable) { }; var buildExec = function () { var clean = core.getInput('move_coverage_to_trash'); - var commit_parent = core.getInput('commit_parent'); - var curl_aws_args = core.getInput('aws_curl_args'); - var curl_codecov_args = core.getInput('codecov_curl_args'); - var env_vars = core.getInput('env_vars'); - var fail_ci = isTrue(core.getInput('fail_ci_if_error')); + var commitParent = core.getInput('commit_parent'); + var curlAwsArgs = core.getInput('aws_curl_args'); + var curlCodecovArgs = core.getInput('codecov_curl_args'); + var envVars = core.getInput('env_vars'); + var failCi = isTrue(core.getInput('fail_ci_if_error')); var file = core.getInput('file'); var files = core.getInput('files'); var flags = core.getInput('flags'); var functionalities = core.getInput('functionalities'); - var gcov_args = core.getInput('gcov_args'); - var gcov_dir = core.getInput('gcov_root_dir'); - var gcov_exclude = core.getInput('gcov_path_exclude'); - var gcov_exec = core.getInput('gcov_executable'); - var gcov_include = core.getInput('gcov_path_include'); - var gcov_prefix = core.getInput('gcov_prefix'); + var gcovArgs = core.getInput('gcov_args'); + var gcovDir = core.getInput('gcov_root_dir'); + var gcovExclude = core.getInput('gcov_path_exclude'); + var gcovExec = core.getInput('gcov_executable'); + var gcovInclude = core.getInput('gcov_path_include'); + var gcovPrefix = core.getInput('gcov_prefix'); var name = core.getInput('name'); - var override_branch = core.getInput('override_branch'); - var override_build = core.getInput('override_build'); - var override_commit = core.getInput('override_commit'); - var override_pr = core.getInput('override_pr'); - var override_tag = core.getInput('override_tag'); - var root_dir = core.getInput('root_dir'); - var search_dir = core.getInput('directory'); + var overrideBranch = core.getInput('override_branch'); + var overrideBuild = core.getInput('override_build'); + var overrideCommit = core.getInput('override_commit'); + var overridePr = core.getInput('override_pr'); + var overrideTag = core.getInput('override_tag'); + var rootDir = core.getInput('root_dir'); + var searchDir = core.getInput('directory'); var token = core.getInput('token'); var verbose = isTrue(core.getInput('verbose')); - var working_dir = core.getInput('working-directory'); - var write_path = core.getInput('path_to_write_report'); - var xcode_derived_data = core.getInput('xcode_derived_data'); - var xcode_package = core.getInput('xcode_package'); - var filepath = working_dir ? - working_dir + '/codecov.sh' : 'codecov.sh'; + var workingDir = core.getInput('working-directory'); + var writePath = core.getInput('path_to_write_report'); + var xcodeDerivedData = core.getInput('xcode_derived_data'); + var xcodePackage = core.getInput('xcode_package'); + var filepath = workingDir ? + workingDir + '/codecov.sh' : 'codecov.sh'; var execArgs = [filepath]; execArgs.push('-n', "" + name, '-F', "" + flags, '-Q', 'github-action'); var options = {}; @@ -54153,13 +54143,13 @@ var buildExec = function () { GITHUB_SHA: process.env.GITHUB_SHA, GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); - var env_vars_arg = []; - for (var _i = 0, _a = env_vars.split(','); _i < _a.length; _i++) { - var env_var = _a[_i]; - var env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean); + var envVarsArg = []; + for (var _i = 0, _a = envVars.split(','); _i < _a.length; _i++) { + var envVar = _a[_i]; + var envVarClean = envVar.trim(); + if (envVarClean) { + options.env[envVarClean] = process.env[envVarClean]; + envVarsArg.push(envVarClean); } } if (token) { @@ -54168,19 +54158,19 @@ var buildExec = function () { if (clean) { execArgs.push('-c'); } - if (commit_parent) { - execArgs.push('-N', "" + commit_parent); + if (commitParent) { + execArgs.push('-N', "" + commitParent); } - if (curl_aws_args) { - execArgs.push('-A', "" + curl_aws_args); + if (curlAwsArgs) { + execArgs.push('-A', "" + curlAwsArgs); } - if (curl_codecov_args) { - execArgs.push('-U', "" + curl_codecov_args); + if (curlCodecovArgs) { + execArgs.push('-U', "" + curlCodecovArgs); } - if (env_vars_arg.length) { - execArgs.push('-e', env_vars_arg.join(',')); + if (envVarsArg.length) { + execArgs.push('-e', envVarsArg.join(',')); } - if (fail_ci) { + if (failCi) { execArgs.push('-Z'); } if (file) { @@ -54196,61 +54186,61 @@ var buildExec = function () { execArgs.push('-X', "" + f); }); } - if (gcov_args) { - execArgs.push('-a', "" + gcov_args); + if (gcovArgs) { + execArgs.push('-a', "" + gcovArgs); } - if (gcov_dir) { - execArgs.push('-p', "" + gcov_dir); + if (gcovDir) { + execArgs.push('-p', "" + gcovDir); } - if (gcov_exclude) { - execArgs.push('-g', "" + gcov_exclude); + if (gcovExclude) { + execArgs.push('-g', "" + gcovExclude); } - if (gcov_exec) { - execArgs.push('-x', "" + gcov_exec); + if (gcovExec) { + execArgs.push('-x', "" + gcovExec); } - if (gcov_include) { - execArgs.push('-G', "" + gcov_include); + if (gcovInclude) { + execArgs.push('-G', "" + gcovInclude); } - if (gcov_prefix) { - execArgs.push('-k', "" + gcov_prefix); + if (gcovPrefix) { + execArgs.push('-k', "" + gcovPrefix); } - if (override_branch) { - execArgs.push('-B', "" + override_branch); + if (overrideBranch) { + execArgs.push('-B', "" + overrideBranch); } - if (override_build) { - execArgs.push('-b', "" + override_build); + if (overrideBuild) { + execArgs.push('-b', "" + overrideBuild); } - if (override_commit) { - execArgs.push('-C', "" + override_commit); + if (overrideCommit) { + execArgs.push('-C', "" + overrideCommit); } - if (override_pr) { - execArgs.push('-P', "" + override_pr); + if (overridePr) { + execArgs.push('-P', "" + overridePr); } - if (override_tag) { - execArgs.push('-T', "" + override_tag); + if (overrideTag) { + execArgs.push('-T', "" + overrideTag); } - if (root_dir) { - execArgs.push('-N', "" + root_dir); + if (rootDir) { + execArgs.push('-N', "" + rootDir); } - if (search_dir) { - execArgs.push('-s', "" + search_dir); + if (searchDir) { + execArgs.push('-s', "" + searchDir); } if (verbose) { execArgs.push('-v'); } - if (working_dir) { - options.cwd = working_dir; + if (workingDir) { + options.cwd = workingDir; } - if (write_path) { - execArgs.push('-q', "" + write_path); + if (writePath) { + execArgs.push('-q', "" + writePath); } - if (xcode_derived_data) { - execArgs.push('-D', "" + xcode_derived_data); + if (xcodeDerivedData) { + execArgs.push('-D', "" + xcodeDerivedData); } - if (xcode_package) { - execArgs.push('-J', "" + xcode_package); + if (xcodePackage) { + execArgs.push('-J', "" + xcodePackage); } - return { execArgs: execArgs, options: options, filepath: filepath, fail_ci: fail_ci }; + return { execArgs: execArgs, options: options, filepath: filepath, failCi: failCi }; }; exports["default"] = buildExec; diff --git a/src/buildExec.test.ts b/src/buildExec.test.ts index c4eceef8b..83d819b17 100644 --- a/src/buildExec.test.ts +++ b/src/buildExec.test.ts @@ -1,7 +1,7 @@ import buildExec from './buildExec'; test('no arguments', () => { - const {execArgs, options, filepath, fail_ci} = buildExec(); + const {execArgs, filepath, failCi} = buildExec(); expect(execArgs).toEqual([ 'codecov.sh', '-n', @@ -12,7 +12,7 @@ test('no arguments', () => { 'github-action', ]); expect(filepath).toEqual('codecov.sh'); - expect(fail_ci).toBeFalsy(); + expect(failCi).toBeFalsy(); }); test('all arguments', () => { @@ -26,7 +26,8 @@ test('all arguments', () => { 'file': 'coverage.xml', 'files': 'dir1/coverage.xml,dir2/coverage.xml', 'flags': 'test', - 'functionalities': 'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs', + 'functionalities': + 'gcov,coveragepy,fix,search,code,network,gcovout,html,recursesubs', 'gcov_args': '--timeout 3', 'gcov_root_dr': 'gcov_dir/', 'gcov_path_exclude': '**/exclude-dir/*.*', @@ -53,7 +54,7 @@ test('all arguments', () => { process.env['INPUT_' + env.toUpperCase()] = envs[env]; } - const {execArgs, options, filepath, fail_ci} = buildExec(); + const {execArgs, filepath, failCi} = buildExec(); expect(execArgs).toEqual([ 'src/codecov.sh', '-n', @@ -129,7 +130,7 @@ test('all arguments', () => { 'MyApp', ]); expect(filepath).toEqual('src/codecov.sh'); - expect(fail_ci).toBeTruthy(); + expect(failCi).toBeTruthy(); for (const env of Object.keys(envs)) { delete process.env['INPUT_' + env.toUpperCase()]; diff --git a/src/buildExec.ts b/src/buildExec.ts index 5b4d8569c..22dfd298e 100644 --- a/src/buildExec.ts +++ b/src/buildExec.ts @@ -13,38 +13,38 @@ const isTrue = (variable) => { const buildExec = () => { const clean = core.getInput('move_coverage_to_trash'); - const commit_parent = core.getInput('commit_parent'); - const curl_aws_args = core.getInput('aws_curl_args'); - const curl_codecov_args = core.getInput('codecov_curl_args'); - const env_vars = core.getInput('env_vars'); - const fail_ci = isTrue(core.getInput('fail_ci_if_error')); + const commitParent = core.getInput('commit_parent'); + const curlAwsArgs = core.getInput('aws_curl_args'); + const curlCodecovArgs = core.getInput('codecov_curl_args'); + const envVars = core.getInput('env_vars'); + const failCi = isTrue(core.getInput('fail_ci_if_error')); const file = core.getInput('file'); const files = core.getInput('files'); const flags = core.getInput('flags'); const functionalities = core.getInput('functionalities'); - const gcov_args = core.getInput('gcov_args'); - const gcov_dir = core.getInput('gcov_root_dir'); - const gcov_exclude = core.getInput('gcov_path_exclude'); - const gcov_exec = core.getInput('gcov_executable'); - const gcov_include = core.getInput('gcov_path_include'); - const gcov_prefix = core.getInput('gcov_prefix'); + const gcovArgs = core.getInput('gcov_args'); + const gcovDir = core.getInput('gcov_root_dir'); + const gcovExclude = core.getInput('gcov_path_exclude'); + const gcovExec = core.getInput('gcov_executable'); + const gcovInclude = core.getInput('gcov_path_include'); + const gcovPrefix = core.getInput('gcov_prefix'); const name = core.getInput('name'); - const override_branch = core.getInput('override_branch'); - const override_build = core.getInput('override_build'); - const override_commit = core.getInput('override_commit'); - const override_pr = core.getInput('override_pr'); - const override_tag = core.getInput('override_tag'); - const root_dir = core.getInput('root_dir'); - const search_dir = core.getInput('directory'); + const overrideBranch = core.getInput('override_branch'); + const overrideBuild = core.getInput('override_build'); + const overrideCommit = core.getInput('override_commit'); + const overridePr = core.getInput('override_pr'); + const overrideTag = core.getInput('override_tag'); + const rootDir = core.getInput('root_dir'); + const searchDir = core.getInput('directory'); const token = core.getInput('token'); const verbose = isTrue(core.getInput('verbose')); - const working_dir = core.getInput('working-directory'); - const write_path = core.getInput('path_to_write_report'); - const xcode_derived_data = core.getInput('xcode_derived_data'); - const xcode_package = core.getInput('xcode_package'); + const workingDir = core.getInput('working-directory'); + const writePath = core.getInput('path_to_write_report'); + const xcodeDerivedData = core.getInput('xcode_derived_data'); + const xcodePackage = core.getInput('xcode_package'); - const filepath = working_dir ? - working_dir + '/codecov.sh' : 'codecov.sh'; + const filepath = workingDir ? + workingDir + '/codecov.sh' : 'codecov.sh'; const execArgs = [filepath]; execArgs.push( '-n', `${name}`, '-F', `${flags}`, '-Q', 'github-action' ); @@ -59,12 +59,12 @@ const buildExec = () => { GITHUB_HEAD_REF: process.env.GITHUB_HEAD_REF || '', }); - const env_vars_arg = []; - for (const env_var of env_vars.split(',')) { - const env_var_clean = env_var.trim(); - if (env_var_clean) { - options.env[env_var_clean] = process.env[env_var_clean]; - env_vars_arg.push(env_var_clean); + const envVarsArg = []; + for (const envVar of envVars.split(',')) { + const envVarClean = envVar.trim(); + if (envVarClean) { + options.env[envVarClean] = process.env[envVarClean]; + envVarsArg.push(envVarClean); } } @@ -74,19 +74,19 @@ const buildExec = () => { if (clean) { execArgs.push('-c'); } - if (commit_parent) { - execArgs.push('-N', `${commit_parent}`); + if (commitParent) { + execArgs.push('-N', `${commitParent}`); } - if (curl_aws_args) { - execArgs.push('-A', `${curl_aws_args}`); + if (curlAwsArgs) { + execArgs.push('-A', `${curlAwsArgs}`); } - if (curl_codecov_args) { - execArgs.push('-U', `${curl_codecov_args}`); + if (curlCodecovArgs) { + execArgs.push('-U', `${curlCodecovArgs}`); } - if (env_vars_arg.length) { - execArgs.push('-e', env_vars_arg.join(',')); + if (envVarsArg.length) { + execArgs.push('-e', envVarsArg.join(',')); } - if (fail_ci) { + if (failCi) { execArgs.push('-Z'); } if (file) { @@ -102,62 +102,62 @@ const buildExec = () => { execArgs.push('-X', `${f}`); }); } - if (gcov_args) { - execArgs.push('-a', `${gcov_args}`); + if (gcovArgs) { + execArgs.push('-a', `${gcovArgs}`); } - if (gcov_dir) { - execArgs.push('-p', `${gcov_dir}`); + if (gcovDir) { + execArgs.push('-p', `${gcovDir}`); } - if (gcov_exclude) { - execArgs.push('-g', `${gcov_exclude}`); + if (gcovExclude) { + execArgs.push('-g', `${gcovExclude}`); } - if (gcov_exec) { - execArgs.push('-x', `${gcov_exec}`); + if (gcovExec) { + execArgs.push('-x', `${gcovExec}`); } - if (gcov_include) { - execArgs.push('-G', `${gcov_include}`); + if (gcovInclude) { + execArgs.push('-G', `${gcovInclude}`); } - if (gcov_prefix) { - execArgs.push('-k', `${gcov_prefix}`); + if (gcovPrefix) { + execArgs.push('-k', `${gcovPrefix}`); } - if (override_branch) { - execArgs.push('-B', `${override_branch}`); + if (overrideBranch) { + execArgs.push('-B', `${overrideBranch}`); } - if (override_build) { - execArgs.push('-b', `${override_build}`); + if (overrideBuild) { + execArgs.push('-b', `${overrideBuild}`); } - if (override_commit) { - execArgs.push('-C', `${override_commit}`); + if (overrideCommit) { + execArgs.push('-C', `${overrideCommit}`); } - if (override_pr) { - execArgs.push('-P', `${override_pr}`); + if (overridePr) { + execArgs.push('-P', `${overridePr}`); } - if (override_tag) { - execArgs.push('-T', `${override_tag}`); + if (overrideTag) { + execArgs.push('-T', `${overrideTag}`); } - if (root_dir) { - execArgs.push('-N', `${root_dir}`); + if (rootDir) { + execArgs.push('-N', `${rootDir}`); } - if (search_dir) { - execArgs.push('-s', `${search_dir}`); + if (searchDir) { + execArgs.push('-s', `${searchDir}`); } if (verbose) { execArgs.push('-v'); } - if (working_dir) { - options.cwd = working_dir; + if (workingDir) { + options.cwd = workingDir; } - if (write_path) { - execArgs.push('-q', `${write_path}`); + if (writePath) { + execArgs.push('-q', `${writePath}`); } - if (xcode_derived_data) { - execArgs.push('-D', `${xcode_derived_data}`); + if (xcodeDerivedData) { + execArgs.push('-D', `${xcodeDerivedData}`); } - if (xcode_package) { - execArgs.push('-J', `${xcode_package}`); + if (xcodePackage) { + execArgs.push('-J', `${xcodePackage}`); } - return {execArgs, options, filepath, fail_ci}; + return {execArgs, options, filepath, failCi}; }; export default buildExec; diff --git a/src/index.ts b/src/index.ts index 4c9abf489..cc15bdc1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ const request = require('requestretry'); import buildExec from './buildExec'; -let fail_ci; +let failCi; try { request({ json: false, @@ -13,36 +13,25 @@ try { timeout: 3000, url: 'https://codecov.io/bash', }, (error, response, body) => { - const {execArgs, options, filepath, fail_ci} = buildExec(); + const {execArgs, options, filepath, failCi} = buildExec(); try { - if (error && fail_ci) { + if (error && failCi) { throw error; } else if (error) { core.warning(`Codecov warning: ${error.message}`); } fs.writeFile(filepath, body, (err) => { - if (err && fail_ci) { + if (err && failCi) { throw err; } else if (err) { core.warning(`Codecov warning: ${err.message}`); } - let output = ''; - let execError = ''; - options.listeners = { - stdout: (data) => { - output += data.toString(); - }, - stderr: (data) => { - execError += data.toString(); - }, - }; - exec.exec('bash', execArgs, options) .catch((err) => { - if (fail_ci) { + if (failCi) { core.setFailed( `Codecov failed with the following error: ${err.message}`, ); @@ -56,7 +45,7 @@ try { const unlinkFile = () => { fs.unlink(filepath, (err) => { - if (err && fail_ci) { + if (err && failCi) { throw err; } else if (err) { core.warning(`Codecov warning: ${err.message}`); @@ -71,7 +60,7 @@ try { } }); } catch (error) { - if (fail_ci) { + if (failCi) { core.setFailed(`Codecov failed with the following error: ${error.message}`); } else { core.warning(`Codecov warning: ${error.message}`); From 1acc162055f47d817cf9c3e6ceefd642c82e70d5 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:16:25 -0500 Subject: [PATCH 22/23] permissions? --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9c1c137b6..cf64a1e0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,9 +9,7 @@ jobs: with: fetch-depth: 2 - name: Install dependencies - run: | - npm install - npm i -g eslint + run: npm install - name: Lint run: npm run lint - name: Run tests and collect coverage From 8d13d6a7ba19b9e548276d8e25d3b229f2799fa9 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Sat, 2 Jan 2021 19:18:26 -0500 Subject: [PATCH 23/23] cleanup --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf64a1e0c..c4ccb0351 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,11 +20,10 @@ jobs: files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json file: ./coverage/coverage-final.json flags: demo - name: codecov-1 + name: codecov-demo - name: Upload coverage to Codecov (script) uses: ./ with: files: ./coverage/script/coverage-final.json flags: script - name: codecov-1 - verbose: true + name: codecov-script