fix: add in all the extra arguments for uploader (#955)

This commit is contained in:
Tom Hu
2023-04-11 09:06:59 -07:00
committed by GitHub
parent 91e184765d
commit 030a000ec6
5 changed files with 2704 additions and 2568 deletions

View File

@@ -35,7 +35,7 @@ steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- uses: codecov/codecov-action@v3 - uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage1.xml,./coverage2.xml # optional files: ./coverage1.xml,./coverage2.xml # optional
flags: unittests # optional flags: unittests # optional
name: codecov-umbrella # optional name: codecov-umbrella # optional
@@ -50,35 +50,43 @@ Codecov's Action supports inputs from the user. These inputs, along with their d
| Input | Description | Usage | | Input | Description | Usage |
| :---: | :---: | :---: | | :---: | :---: | :---: |
| `token` | Used to authorize coverage report uploads | *Required for private repos* | | `token` | Used to authorize coverage report uploads | *Required |
| `files` | Comma-separated paths to the coverage report(s). Negated paths are supported by starting with `!` | Optional | `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional
| `directory` | Directory to search for coverage reports. | Optional
| `dry_run` | Don't upload files to Codecov | Optional
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | 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 | `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
| `dry_run` | Don't upload files to Codecov | Optional
| `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional | `env_vars` | Environment variables to tag the upload with. Multiple env variables can be separated with commas (e.g. `OS,PYTHON`) | Optional
| `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional | `fail_ci_if_error` | Specify if CI pipeline should fail when Codecov runs into errors during upload. *Defaults to **false*** | Optional
| `files` | Comma-separated paths to the coverage report(s). Negated paths are supported by starting with `!` | Optional
| `flags` | Flag the upload to group coverage metrics (unittests, uitests, etc.). Multiple flags are separated by a comma (ui,chrome) | Optional
| `full_report` | Specify the path of a full Codecov report to re-upload | Optional
| `functionalities` | Toggle functionalities | Optional | `functionalities` | Toggle functionalities | Optional
| `network` | Disable uploading the file network | Optional | -- `network` | Disable uploading the file network | Optional
| -- `fixes` | Enable file fixes to ignore common lines from coverage | Optional
| -- `search` | Disable searching for coverage files | Optional
| `gcov` | Run with gcov support | Optional | `gcov` | Run with gcov support | Optional
| `gcov_args` | Extra arguments to pass to gcov | Optional | `gcov_args` | Extra arguments to pass to gcov | Optional
| `gcov_ignore` | Paths to ignore during gcov gathering | Optional | `gcov_ignore` | Paths to ignore during gcov gathering | Optional
| `gcov_include` | Paths to include during gcov gathering | Optional | `gcov_include` | Paths to include during gcov gathering | Optional
| `move_coverage_to_trash` | Move discovered coverage reports to the trash | Optional | `gcov_executable` | gcov executable to run. Defaults to gcov. | Optional
| `name` | Custom defined name for the upload | Optional | `name` | Custom defined name for the upload | Optional
| `network_filer` | Specify a filter on the files listed in the network section of the Codecov report. Useful for upload-specific path fixing | Optional
| `network_prefix` | Specify a prefix on files listed in the network section of the Codecov report. Useful to help resolve path fixing | Optional
| `os` | Specify the OS (linux, macos, windows, alpine) | Optional
| `override_branch` | Specify the branch name | Optional | `override_branch` | Specify the branch name | Optional
| `override_build` | Specify the build number | Optional | `override_build` | Specify the build number | Optional
| `override_commit` | Specify the commit SHA | Optional | `override_commit` | Specify the commit SHA | Optional
| `override_pr` | Specify the pull request number | Optional | `override_pr` | Specify the pull request number | Optional
| `override_tag` | Specify the git tag | Optional | `override_tag` | Specify the git tag | Optional
| `root_dir` | Used when not in git/hg project to identify project root directory | Optional | `root_dir` | Used when not in git/hg project to identify project root directory | Optional
| `directory` | Directory to search for coverage reports. | Optional
| `slug` | Specify the slug manually (Enterprise use) | Optional | `slug` | Specify the slug manually (Enterprise use) | Optional
| `swift` | Run with swift coverage support | Optional
| -- `swift_project` | Specify the swift project to speed up coverage conversion | Optional
| `upstream_proxy` | The upstream http proxy server to connect through | Optional
| `url` | Change the upload host (Enterprise use) | Optional | `url` | Change the upload host (Enterprise use) | Optional
| `verbose` | Specify whether the Codecov output should be verbose | Optional | `verbose` | Specify whether the Codecov output should be verbose | Optional
| `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional | `version` | Specify which version of the Codecov Uploader should be used. Defaults to `latest` | Optional
| `working-directory` | Directory in which to execute `codecov.sh` | Optional | `xtra_args` | Add additional uploader args that may be missing in the Action | Optional
| `xcode` | Run with xcode support | Optional
| `xcode_archive_path` | Specify the xcode archive path. Likely specified as the -resultBundlePath and should end in .xcresult | Optional
### Example `workflow.yml` with Codecov Action ### Example `workflow.yml` with Codecov Action
@@ -94,13 +102,13 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
env: env:
OS: ${{ matrix.os }} OS: ${{ matrix.os }}
PYTHON: '3.7' PYTHON: '3.10'
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Setup Python - name: Setup Python
uses: actions/setup-python@master uses: actions/setup-python@master
with: with:
python-version: 3.7 python-version: 3.10
- name: Generate coverage report - name: Generate coverage report
run: | run: |
pip install pytest pip install pytest

5149
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -35,25 +35,32 @@ test('all arguments', () => {
'flags': 'test,test2', 'flags': 'test,test2',
'functionalities': 'functionalities':
'network', 'network',
'full_report': 'oldDir/oldReport.json',
'gcov': 'true', 'gcov': 'true',
'gcov_args': '-v', 'gcov_args': '-v',
'gcov_ignore': '*.fake', 'gcov_ignore': '*.fake',
'gcov_include': 'real_file', 'gcov_include': 'real_file',
'gcov_executable': 'gcov2',
'move_coverage_to_trash': 'true', 'move_coverage_to_trash': 'true',
'name': 'codecov', 'name': 'codecov',
'network_filter': 'src/',
'network_prefix': 'build/',
'override_branch': 'thomasrockhu/test', 'override_branch': 'thomasrockhu/test',
'override_build': '1', 'override_build': '1',
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244', 'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
'override_pr': '2', 'override_pr': '2',
'override_tag': 'v1.2', 'override_tag': 'v1.2',
'root_dir': 'root/', 'root_dir': 'root/',
'swift': 'true',
'swift_project': 'MyApp',
'slug': 'fakeOwner/fakeRepo', 'slug': 'fakeOwner/fakeRepo',
'token': 'd3859757-ab80-4664-924d-aef22fa7557b', 'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
'upstream_proxy': 'https://codecov.example.com',
'url': 'https://codecov.enterprise.com', 'url': 'https://codecov.enterprise.com',
'verbose': 't', 'verbose': 't',
'working-directory': 'src',
'xcode': 'true', 'xcode': 'true',
'xcode_archive_path': '/test.xcresult', 'xcode_archive_path': '/test.xcresult',
'xtra_args': '-some -other -args',
}; };
for (const env of Object.keys(envs)) { for (const env of Object.keys(envs)) {
@@ -81,17 +88,25 @@ test('all arguments', () => {
'dir1/coverage.xml', 'dir1/coverage.xml',
'-f', '-f',
'dir2/coverage.xml', 'dir2/coverage.xml',
'-full',
'oldDir/oldReport.json',
'-F', '-F',
'test', 'test',
'-F', '-F',
'test2', 'test2',
'-g', '-g',
'--gcovArgs', '-gcovArgs',
'-v', '-v',
'--gcovIgnore', '-gcovIgnore',
'*.fake', '*.fake',
'--gcovInclude', '-gcovInclude',
'real_file', 'real_file',
'-gcovExecutable',
'gcov2',
'-networkFilter',
'src/',
'-networkPrefix',
'build/',
'-B', '-B',
'thomasrockhu/test', 'thomasrockhu/test',
'-b', '-b',
@@ -108,12 +123,18 @@ test('all arguments', () => {
'coverage/', 'coverage/',
'-r', '-r',
'fakeOwner/fakeRepo', 'fakeOwner/fakeRepo',
'-xs',
'-xsp',
'MyApp',
'-U',
'https://codecov.example.com',
'-u', '-u',
'https://codecov.enterprise.com', 'https://codecov.enterprise.com',
'-v', '-v',
'--xc', '-xc',
'--xp', '-xp',
'/test.xcresult', '/test.xcresult',
'-some -other -args',
]); ]);
expect(failCi).toBeTruthy(); expect(failCi).toBeTruthy();

View File

@@ -19,18 +19,22 @@ const isTrue = (variable) => {
const buildExec = () => { const buildExec = () => {
const clean = core.getInput('move_coverage_to_trash'); const clean = core.getInput('move_coverage_to_trash');
const commitParent = core.getInput('commit_parent'); const commitParent = core.getInput('commit_parent');
const envVars = core.getInput('env_vars');
const dryRun = isTrue(core.getInput('dry_run')); const dryRun = isTrue(core.getInput('dry_run'));
const envVars = core.getInput('env_vars');
const failCi = isTrue(core.getInput('fail_ci_if_error')); const failCi = isTrue(core.getInput('fail_ci_if_error'));
const file = core.getInput('file'); const file = core.getInput('file');
const files = core.getInput('files'); const files = core.getInput('files');
const flags = core.getInput('flags'); const flags = core.getInput('flags');
const fullReport = core.getInput('full_report');
const functionalities = core.getInput('functionalities');
const gcov = core.getInput('gcov'); const gcov = core.getInput('gcov');
const gcovArgs = core.getInput('gcov_args'); const gcovArgs = core.getInput('gcov_args');
const gcovExecutable = core.getInput('gcov_executable');
const gcovIgnore = core.getInput('gcov_ignore'); const gcovIgnore = core.getInput('gcov_ignore');
const gcovInclude = core.getInput('gcov_include'); const gcovInclude = core.getInput('gcov_include');
const functionalities = core.getInput('functionalities');
const name = core.getInput('name'); const name = core.getInput('name');
const networkFilter = core.getInput('network_filter');
const networkPrefix = core.getInput('network_prefix');
const os = core.getInput('os'); const os = core.getInput('os');
const overrideBranch = core.getInput('override_branch'); const overrideBranch = core.getInput('override_branch');
const overrideBuild = core.getInput('override_build'); const overrideBuild = core.getInput('override_build');
@@ -40,13 +44,16 @@ const buildExec = () => {
const rootDir = core.getInput('root_dir'); const rootDir = core.getInput('root_dir');
const searchDir = core.getInput('directory'); const searchDir = core.getInput('directory');
const slug = core.getInput('slug'); const slug = core.getInput('slug');
const swift = core.getInput('swift');
const swiftProject = core.getInput('swift_project');
const token = core.getInput('token'); const token = core.getInput('token');
let uploaderVersion = core.getInput('version'); const upstream = core.getInput('upstream_proxy');
const url = core.getInput('url'); const url = core.getInput('url');
const verbose = isTrue(core.getInput('verbose')); const verbose = isTrue(core.getInput('verbose'));
const workingDir = core.getInput('working-directory');
const xcode = core.getInput('xcode'); const xcode = core.getInput('xcode');
const xcodeArchivePath = core.getInput('xcode_archive_path'); const xcodeArchivePath = core.getInput('xcode_archive_path');
const xtraArgs = core.getInput('xtra_args');
let uploaderVersion = core.getInput('version');
const execArgs = []; const execArgs = [];
execArgs.push( execArgs.push(
@@ -106,6 +113,9 @@ const buildExec = () => {
execArgs.push('-f', `${f}`); execArgs.push('-f', `${f}`);
}); });
} }
if (fullReport) {
execArgs.push('-full', `${fullReport}`);
}
if (flags) { if (flags) {
flags.split(',').map((f) => f.trim()).forEach((f) => { flags.split(',').map((f) => f.trim()).forEach((f) => {
execArgs.push('-F', `${f}`); execArgs.push('-F', `${f}`);
@@ -116,13 +126,23 @@ const buildExec = () => {
execArgs.push('-g'); execArgs.push('-g');
} }
if (gcovArgs) { if (gcovArgs) {
execArgs.push('--gcovArgs', `${gcovArgs}`); execArgs.push('-gcovArgs', `${gcovArgs}`);
} }
if (gcovIgnore) { if (gcovIgnore) {
execArgs.push('--gcovIgnore', `${gcovIgnore}`); execArgs.push('-gcovIgnore', `${gcovIgnore}`);
} }
if (gcovInclude) { if (gcovInclude) {
execArgs.push('--gcovInclude', `${gcovInclude}`); execArgs.push('-gcovInclude', `${gcovInclude}`);
}
if (gcovExecutable) {
execArgs.push('-gcovExecutable', `${gcovExecutable}`);
}
if (networkFilter) {
execArgs.push('-networkFilter', `${networkFilter}`);
}
if (networkPrefix) {
execArgs.push('-networkPrefix', `${networkPrefix}`);
} }
if (overrideBranch) { if (overrideBranch) {
@@ -158,18 +178,24 @@ const buildExec = () => {
if (slug) { if (slug) {
execArgs.push('-r', `${slug}`); execArgs.push('-r', `${slug}`);
} }
if (swift) {
execArgs.push('-xs');
}
if (swift && swiftProject) {
execArgs.push('-xsp', `${swiftProject}`);
}
if (upstream) {
execArgs.push('-U', `${upstream}`);
}
if (url) { if (url) {
execArgs.push('-u', `${url}`); execArgs.push('-u', `${url}`);
} }
if (verbose) { if (verbose) {
execArgs.push('-v'); execArgs.push('-v');
} }
if (workingDir) {
options.cwd = workingDir;
}
if (xcode && xcodeArchivePath) { if (xcode && xcodeArchivePath) {
execArgs.push('--xc'); execArgs.push('-xc');
execArgs.push('--xp', `${xcodeArchivePath}`); execArgs.push('-xp', `${xcodeArchivePath}`);
} }
if (uploaderVersion == '') { if (uploaderVersion == '') {
@@ -180,6 +206,10 @@ const buildExec = () => {
console.debug({execArgs}); console.debug({execArgs});
} }
if (xtraArgs) {
execArgs.push(`${xtraArgs}`);
}
return {execArgs, options, failCi, os, uploaderVersion, verbose}; return {execArgs, options, failCi, os, uploaderVersion, verbose};
}; };