mirror of
https://github.com/codecov/codecov-action.git
synced 2025-12-23 20:27:02 +08:00
Add all args (#1245)
* fix: add all args from cli * chore(release): bump to 4.0.1
This commit is contained in:
35
.github/workflows/main.yml
vendored
35
.github/workflows/main.yml
vendored
@@ -1,41 +1,6 @@
|
|||||||
name: Workflow for Codecov Action
|
name: Workflow for Codecov Action
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
no-deps:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4.1.1
|
|
||||||
- name: Upload coverage to Codecov (script)
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: ./coverage/script/coverage-final.json
|
|
||||||
flags: script,${{ matrix.os }}
|
|
||||||
name: codecov-script
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
- name: Upload coverage to Codecov (demo)
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
|
||||||
file: ./coverage/coverage-final.json
|
|
||||||
flags: demo,${{ matrix.os }}
|
|
||||||
name: codecov-demo
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
- name: Upload coverage to Codecov (version)
|
|
||||||
uses: ./
|
|
||||||
with:
|
|
||||||
files: ./coverage/calculator/coverage-final.json,./coverage/coverage-test/coverage-final.json
|
|
||||||
file: ./coverage/coverage-final.json
|
|
||||||
flags: version,${{ matrix.os }}
|
|
||||||
name: codecov-version
|
|
||||||
version: v0.2.0
|
|
||||||
verbose: true
|
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
|
||||||
run:
|
run:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
34
action.yml
34
action.yml
@@ -5,11 +5,8 @@ inputs:
|
|||||||
token:
|
token:
|
||||||
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
description: 'Repository upload token - get it from codecov.io. Required only for private repositories'
|
||||||
required: false
|
required: false
|
||||||
file:
|
codecov_yml_path:
|
||||||
description: 'Path to coverage file to upload'
|
description: 'Specify the path to the Codecov YML'
|
||||||
required: false
|
|
||||||
files:
|
|
||||||
description: 'Comma-separated list of files to upload'
|
|
||||||
required: false
|
required: false
|
||||||
commit_parent:
|
commit_parent:
|
||||||
description: 'Override to specify the parent commit SHA'
|
description: 'Override to specify the parent commit SHA'
|
||||||
@@ -17,6 +14,12 @@ inputs:
|
|||||||
directory:
|
directory:
|
||||||
description: 'Directory to search for coverage reports.'
|
description: 'Directory to search for coverage reports.'
|
||||||
required: false
|
required: false
|
||||||
|
disable_search:
|
||||||
|
description: 'Disable search for coverage files. This is helpful when specifying what files you want to upload with the --file option.'
|
||||||
|
required: false
|
||||||
|
disable_file_fixes:
|
||||||
|
description: 'Disable file fixes to ignore common lines from coverage (e.g. blank lines or empty brackets)'
|
||||||
|
required: false
|
||||||
dry_run:
|
dry_run:
|
||||||
description: "Don't upload files to Codecov"
|
description: "Don't upload files to Codecov"
|
||||||
required: false
|
required: false
|
||||||
@@ -29,9 +32,21 @@ inputs:
|
|||||||
fail_ci_if_error:
|
fail_ci_if_error:
|
||||||
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
description: 'Specify whether or not CI build should fail if Codecov runs into an error during upload'
|
||||||
required: false
|
required: false
|
||||||
|
file:
|
||||||
|
description: 'Path to coverage file to upload'
|
||||||
|
required: false
|
||||||
|
files:
|
||||||
|
description: 'Comma-separated list of files to upload'
|
||||||
|
required: false
|
||||||
flags:
|
flags:
|
||||||
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
description: 'Flag upload to group coverage metrics (e.g. unittests | integration | ui,chrome)'
|
||||||
required: false
|
required: false
|
||||||
|
handle_no_reports_found:
|
||||||
|
description: 'Raise no exceptions when no coverage reports found'
|
||||||
|
required: false
|
||||||
|
job_code:
|
||||||
|
description: 'The job code'
|
||||||
|
required: false
|
||||||
name:
|
name:
|
||||||
description: 'User defined upload name. Visible in Codecov UI'
|
description: 'User defined upload name. Visible in Codecov UI'
|
||||||
required: false
|
required: false
|
||||||
@@ -44,6 +59,9 @@ inputs:
|
|||||||
override_build:
|
override_build:
|
||||||
description: 'Specify the build number'
|
description: 'Specify the build number'
|
||||||
required: false
|
required: false
|
||||||
|
override_build_url:
|
||||||
|
description: 'The URL of the build where this is running'
|
||||||
|
required: false
|
||||||
override_commit:
|
override_commit:
|
||||||
description: 'Specify the commit SHA'
|
description: 'Specify the commit SHA'
|
||||||
required: false
|
required: false
|
||||||
@@ -56,6 +74,9 @@ inputs:
|
|||||||
plugins:
|
plugins:
|
||||||
description: 'Comma-separated list of plugins for use during upload.'
|
description: 'Comma-separated list of plugins for use during upload.'
|
||||||
required: false
|
required: false
|
||||||
|
report_code:
|
||||||
|
description: 'The code of the report. If unsure, do not include'
|
||||||
|
required: false
|
||||||
root_dir:
|
root_dir:
|
||||||
description: 'Used when not in git/hg project to identify project root directory'
|
description: 'Used when not in git/hg project to identify project root directory'
|
||||||
required: false
|
required: false
|
||||||
@@ -65,6 +86,9 @@ inputs:
|
|||||||
url:
|
url:
|
||||||
description: 'Specify the base url to upload (Enterprise use)'
|
description: 'Specify the base url to upload (Enterprise use)'
|
||||||
required: false
|
required: false
|
||||||
|
use_legacy_upload_endpoint:
|
||||||
|
description: 'Use the legacy upload endpoint'
|
||||||
|
required: false
|
||||||
verbose:
|
verbose:
|
||||||
description: 'Specify whether the Codecov output should be verbose'
|
description: 'Specify whether the Codecov output should be verbose'
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
71
dist/index.js
vendored
71
dist/index.js
vendored
@@ -32266,6 +32266,7 @@ const buildCommitExec = () => {
|
|||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
const commitCommand = 'create-commit';
|
const commitCommand = 'create-commit';
|
||||||
const commitExecArgs = [];
|
const commitExecArgs = [];
|
||||||
const commitOptions = {};
|
const commitOptions = {};
|
||||||
@@ -32302,12 +32303,19 @@ const buildCommitExec = () => {
|
|||||||
if (slug) {
|
if (slug) {
|
||||||
commitExecArgs.push('--slug', `${slug}`);
|
commitExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
commitExecArgs.push('-Z');
|
||||||
|
}
|
||||||
return { commitExecArgs, commitOptions, commitCommand };
|
return { commitExecArgs, commitOptions, commitCommand };
|
||||||
};
|
};
|
||||||
const buildGeneralExec = () => {
|
const buildGeneralExec = () => {
|
||||||
|
const codecovYmlPath = core.getInput('codecov_yml_path');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const args = [];
|
const args = [];
|
||||||
|
if (codecovYmlPath) {
|
||||||
|
args.push('--codecov-yml-path', `${codecovYmlPath}`);
|
||||||
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
args.push('--enterprise-url', `${url}`);
|
args.push('--enterprise-url', `${url}`);
|
||||||
}
|
}
|
||||||
@@ -32318,8 +32326,10 @@ const buildGeneralExec = () => {
|
|||||||
};
|
};
|
||||||
const buildReportExec = () => {
|
const buildReportExec = () => {
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
const reportCommand = 'create-report';
|
const reportCommand = 'create-report';
|
||||||
const reportExecArgs = [];
|
const reportExecArgs = [];
|
||||||
const reportOptions = {};
|
const reportOptions = {};
|
||||||
@@ -32341,33 +32351,49 @@ const buildReportExec = () => {
|
|||||||
`${context.eventName}` == 'pull_request_target') {
|
`${context.eventName}` == 'pull_request_target') {
|
||||||
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
}
|
}
|
||||||
|
if (overridePr) {
|
||||||
|
reportExecArgs.push('-P', `${overridePr}`);
|
||||||
|
}
|
||||||
|
else if (`${context.eventName}` == 'pull_request_target') {
|
||||||
|
reportExecArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
reportExecArgs.push('--slug', `${slug}`);
|
reportExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
reportExecArgs.push('-Z');
|
||||||
|
}
|
||||||
return { reportExecArgs, reportOptions, reportCommand };
|
return { reportExecArgs, reportOptions, reportCommand };
|
||||||
};
|
};
|
||||||
const buildUploadExec = () => {
|
const buildUploadExec = () => {
|
||||||
const envVars = core.getInput('env_vars');
|
const disableFileFixes = isTrue(core.getInput('disable_file_fixes'));
|
||||||
|
const disableSearch = isTrue(core.getInput('disable_search'));
|
||||||
const dryRun = isTrue(core.getInput('dry_run'));
|
const dryRun = isTrue(core.getInput('dry_run'));
|
||||||
|
const envVars = core.getInput('env_vars');
|
||||||
|
const exclude = core.getInput('exclude');
|
||||||
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 handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found'));
|
||||||
|
const jobCode = core.getInput('job_code');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
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');
|
||||||
|
const overrideBuildUrl = core.getInput('override_build_url');
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
|
const plugin = core.getInput('plugin');
|
||||||
const plugins = core.getInput('plugins');
|
const plugins = core.getInput('plugins');
|
||||||
|
const reportCode = core.getInput('report_code');
|
||||||
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 token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
let uploaderVersion = core.getInput('version');
|
let uploaderVersion = core.getInput('version');
|
||||||
|
const useLegacyUploadEndpoint = isTrue(core.getInput('use_legacy_upload_endpoint'));
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
const plugin = core.getInput('plugin');
|
|
||||||
const exclude = core.getInput('exclude');
|
|
||||||
const uploadExecArgs = [];
|
const uploadExecArgs = [];
|
||||||
const uploadCommand = 'do-upload';
|
const uploadCommand = 'do-upload';
|
||||||
const uploadOptions = {};
|
const uploadOptions = {};
|
||||||
@@ -32387,18 +32413,24 @@ const buildUploadExec = () => {
|
|||||||
envVarsArg.push(envVarClean);
|
envVarsArg.push(envVarClean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name) {
|
|
||||||
uploadExecArgs.push('-n', `${name}`);
|
|
||||||
}
|
|
||||||
if (token) {
|
if (token) {
|
||||||
uploadOptions.env.CODECOV_TOKEN = token;
|
uploadOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
if (disableFileFixes) {
|
||||||
|
uploadExecArgs.push('--disable-file-fixes');
|
||||||
|
}
|
||||||
|
if (disableSearch) {
|
||||||
|
uploadExecArgs.push('--disable-search');
|
||||||
|
}
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
uploadExecArgs.push('-d');
|
uploadExecArgs.push('-d');
|
||||||
}
|
}
|
||||||
if (envVarsArg.length) {
|
if (envVarsArg.length) {
|
||||||
uploadExecArgs.push('-e', envVarsArg.join(','));
|
uploadExecArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
}
|
||||||
|
if (exclude) {
|
||||||
|
uploadExecArgs.push('--exclude', `${exclude}`);
|
||||||
|
}
|
||||||
if (failCi) {
|
if (failCi) {
|
||||||
uploadExecArgs.push('-Z');
|
uploadExecArgs.push('-Z');
|
||||||
}
|
}
|
||||||
@@ -32415,12 +32447,24 @@ const buildUploadExec = () => {
|
|||||||
uploadExecArgs.push('-F', `${f}`);
|
uploadExecArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (handleNoReportsFound) {
|
||||||
|
uploadExecArgs.push('--handle-no-reports-found');
|
||||||
|
}
|
||||||
|
if (jobCode) {
|
||||||
|
uploadExecArgs.push('--job-code', `${jobCode}`);
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
uploadExecArgs.push('-n', `${name}`);
|
||||||
|
}
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
uploadExecArgs.push('-B', `${overrideBranch}`);
|
uploadExecArgs.push('-B', `${overrideBranch}`);
|
||||||
}
|
}
|
||||||
if (overrideBuild) {
|
if (overrideBuild) {
|
||||||
uploadExecArgs.push('-b', `${overrideBuild}`);
|
uploadExecArgs.push('-b', `${overrideBuild}`);
|
||||||
}
|
}
|
||||||
|
if (overrideBuildUrl) {
|
||||||
|
uploadExecArgs.push('--build-url', `${overrideBuildUrl}`);
|
||||||
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
uploadExecArgs.push('-C', `${overrideCommit}`);
|
uploadExecArgs.push('-C', `${overrideCommit}`);
|
||||||
}
|
}
|
||||||
@@ -32434,11 +32478,17 @@ const buildUploadExec = () => {
|
|||||||
else if (`${context.eventName}` == 'pull_request_target') {
|
else if (`${context.eventName}` == 'pull_request_target') {
|
||||||
uploadExecArgs.push('-P', `${context.payload.number}`);
|
uploadExecArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
}
|
||||||
|
if (plugin) {
|
||||||
|
uploadExecArgs.push('--plugin', `${plugin}`);
|
||||||
|
}
|
||||||
if (plugins) {
|
if (plugins) {
|
||||||
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
||||||
uploadExecArgs.push('--plugin', `${p}`);
|
uploadExecArgs.push('--plugin', `${p}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (reportCode) {
|
||||||
|
uploadExecArgs.push('--report-code', `${reportCode}`);
|
||||||
|
}
|
||||||
if (rootDir) {
|
if (rootDir) {
|
||||||
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
||||||
}
|
}
|
||||||
@@ -32451,15 +32501,12 @@ const buildUploadExec = () => {
|
|||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
uploadOptions.cwd = workingDir;
|
uploadOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
if (plugin) {
|
|
||||||
uploadExecArgs.push('--plugin', `${plugin}`);
|
|
||||||
}
|
|
||||||
if (exclude) {
|
|
||||||
uploadExecArgs.push('--exclude', `${exclude}`);
|
|
||||||
}
|
|
||||||
if (uploaderVersion == '') {
|
if (uploaderVersion == '') {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
if (useLegacyUploadEndpoint) {
|
||||||
|
uploadExecArgs.push('--legacy');
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
uploadExecArgs,
|
uploadExecArgs,
|
||||||
uploadOptions,
|
uploadOptions,
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codecov-action",
|
"name": "codecov-action",
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
"description": "Upload coverage reports to Codecov from GitHub Actions",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const context = github.context;
|
|||||||
|
|
||||||
test('general args', () => {
|
test('general args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
codecov_yml_path: 'dev/codecov.yml',
|
||||||
url: 'https://codecov.enterprise.com',
|
url: 'https://codecov.enterprise.com',
|
||||||
verbose: 't',
|
verbose: 't',
|
||||||
};
|
};
|
||||||
@@ -23,6 +24,8 @@ test('general args', () => {
|
|||||||
|
|
||||||
expect(args).toEqual(
|
expect(args).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
|
'--codecov-yml-path',
|
||||||
|
'dev/codecov.yml',
|
||||||
'--enterprise-url',
|
'--enterprise-url',
|
||||||
'https://codecov.enterprise.com',
|
'https://codecov.enterprise.com',
|
||||||
'-v',
|
'-v',
|
||||||
@@ -50,25 +53,38 @@ test('upload args using context', () => {
|
|||||||
|
|
||||||
test('upload args', () => {
|
test('upload args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
'codecov_yml_path': 'dev/codecov.yml',
|
||||||
|
'commit_parent': 'fakeparentcommit',
|
||||||
'directory': 'coverage/',
|
'directory': 'coverage/',
|
||||||
|
'disable_file_fixes': 'true',
|
||||||
|
'disable_search': 'true',
|
||||||
'dry_run': 'true',
|
'dry_run': 'true',
|
||||||
'env_vars': 'OS,PYTHON',
|
'env_vars': 'OS,PYTHON',
|
||||||
|
'exclude': 'node_modules/',
|
||||||
'fail_ci_if_error': 'true',
|
'fail_ci_if_error': 'true',
|
||||||
'file': 'coverage.xml',
|
'file': 'coverage.xml',
|
||||||
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
'files': 'dir1/coverage.xml,dir2/coverage.xml',
|
||||||
'flags': 'test,test2',
|
'flags': 'test,test2',
|
||||||
|
'handle_no_reports_found': 'true',
|
||||||
|
'job_code': '32',
|
||||||
'name': 'codecov',
|
'name': 'codecov',
|
||||||
|
'os': 'macos',
|
||||||
'override_branch': 'thomasrockhu/test',
|
'override_branch': 'thomasrockhu/test',
|
||||||
'override_build': '1',
|
'override_build': '1',
|
||||||
|
'override_build_url': 'https://example.com/build/2',
|
||||||
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
'override_commit': '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'override_pr': '2',
|
'override_pr': '2',
|
||||||
|
'plugin': 'xcode',
|
||||||
'plugins': 'pycoverage,compress-pycoverage',
|
'plugins': 'pycoverage,compress-pycoverage',
|
||||||
|
'report_code': 'testCode',
|
||||||
'root_dir': 'root/',
|
'root_dir': 'root/',
|
||||||
'slug': 'fakeOwner/fakeRepo',
|
'slug': 'fakeOwner/fakeRepo',
|
||||||
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
'token': 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
'url': 'https://enterprise.example.com',
|
||||||
|
'use_legacy_upload_endpoint': 'true',
|
||||||
|
'verbose': 'true',
|
||||||
|
'version': '0.1.2',
|
||||||
'working-directory': 'src',
|
'working-directory': 'src',
|
||||||
'plugin': 'xcode',
|
|
||||||
'exclude': 'src',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
@@ -76,11 +92,13 @@ test('upload args', () => {
|
|||||||
|
|
||||||
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
const {uploadExecArgs, uploadCommand} = buildUploadExec();
|
||||||
const expectedArgs = [
|
const expectedArgs = [
|
||||||
'-n',
|
'--disable-file-fixes',
|
||||||
'codecov',
|
'--disable-search',
|
||||||
'-d',
|
'-d',
|
||||||
'-e',
|
'-e',
|
||||||
'OS,PYTHON',
|
'OS,PYTHON',
|
||||||
|
'--exclude',
|
||||||
|
'node_modules/',
|
||||||
'-Z',
|
'-Z',
|
||||||
'-f',
|
'-f',
|
||||||
'coverage.xml',
|
'coverage.xml',
|
||||||
@@ -92,28 +110,36 @@ test('upload args', () => {
|
|||||||
'test',
|
'test',
|
||||||
'-F',
|
'-F',
|
||||||
'test2',
|
'test2',
|
||||||
|
'--handle-no-reports-found',
|
||||||
|
'--job-code',
|
||||||
|
'32',
|
||||||
|
'-n',
|
||||||
|
'codecov',
|
||||||
'-B',
|
'-B',
|
||||||
'thomasrockhu/test',
|
'thomasrockhu/test',
|
||||||
'-b',
|
'-b',
|
||||||
'1',
|
'1',
|
||||||
|
'--build-url',
|
||||||
|
'https://example.com/build/2',
|
||||||
'-C',
|
'-C',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'-P',
|
'-P',
|
||||||
'2',
|
'2',
|
||||||
'--plugin',
|
'--plugin',
|
||||||
|
'xcode',
|
||||||
|
'--plugin',
|
||||||
'pycoverage',
|
'pycoverage',
|
||||||
'--plugin',
|
'--plugin',
|
||||||
'compress-pycoverage',
|
'compress-pycoverage',
|
||||||
|
'--report-code',
|
||||||
|
'testCode',
|
||||||
'--network-root-folder',
|
'--network-root-folder',
|
||||||
'root/',
|
'root/',
|
||||||
'-s',
|
'-s',
|
||||||
'coverage/',
|
'coverage/',
|
||||||
'-r',
|
'-r',
|
||||||
'fakeOwner/fakeRepo',
|
'fakeOwner/fakeRepo',
|
||||||
'--plugin',
|
'--legacy',
|
||||||
'xcode',
|
|
||||||
'--exclude',
|
|
||||||
'src',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
expect(uploadExecArgs).toEqual(expectedArgs);
|
expect(uploadExecArgs).toEqual(expectedArgs);
|
||||||
@@ -127,8 +153,10 @@ test('upload args', () => {
|
|||||||
test('report args', () => {
|
test('report args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: 'fakePR',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
|
fail_ci_if_error: 'true',
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
@@ -136,13 +164,17 @@ test('report args', () => {
|
|||||||
|
|
||||||
const {reportExecArgs, reportCommand} = buildReportExec();
|
const {reportExecArgs, reportCommand} = buildReportExec();
|
||||||
|
|
||||||
expect(reportExecArgs).toEqual(
|
const expectedArgs = [
|
||||||
expect.arrayContaining([
|
'-C',
|
||||||
'-C',
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
'-P',
|
||||||
'--slug',
|
'fakePR',
|
||||||
'fakeOwner/fakeRepo',
|
'--slug',
|
||||||
]));
|
'fakeOwner/fakeRepo',
|
||||||
|
'-Z',
|
||||||
|
];
|
||||||
|
|
||||||
|
expect(reportExecArgs).toEqual(expectedArgs);
|
||||||
expect(reportCommand).toEqual('create-report');
|
expect(reportCommand).toEqual('create-report');
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
@@ -174,32 +206,34 @@ test('report args using context', () => {
|
|||||||
|
|
||||||
test('commit args', () => {
|
test('commit args', () => {
|
||||||
const envs = {
|
const envs = {
|
||||||
|
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
||||||
|
override_branch: 'thomasrockhu/test',
|
||||||
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
override_commit: '9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
override_pr: '2',
|
||||||
slug: 'fakeOwner/fakeRepo',
|
slug: 'fakeOwner/fakeRepo',
|
||||||
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
token: 'd3859757-ab80-4664-924d-aef22fa7557b',
|
||||||
override_branch: 'thomasrockhu/test',
|
fail_ci_if_error: 'true',
|
||||||
override_pr: '2',
|
|
||||||
commit_parent: '83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
};
|
};
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
process.env['INPUT_' + env.toUpperCase()] = envs[env];
|
||||||
}
|
}
|
||||||
|
|
||||||
const {commitExecArgs, commitCommand} = buildCommitExec();
|
const {commitExecArgs, commitCommand} = buildCommitExec();
|
||||||
|
const expectedArgs = [
|
||||||
|
'--parent-sha',
|
||||||
|
'83231650328f11695dfb754ca0f540516f188d27',
|
||||||
|
'-B',
|
||||||
|
'thomasrockhu/test',
|
||||||
|
'-C',
|
||||||
|
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
||||||
|
'--pr',
|
||||||
|
'2',
|
||||||
|
'--slug',
|
||||||
|
'fakeOwner/fakeRepo',
|
||||||
|
'-Z',
|
||||||
|
];
|
||||||
|
|
||||||
expect(commitExecArgs).toEqual(
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect.arrayContaining([
|
|
||||||
'-C',
|
|
||||||
'9caabca5474b49de74ef5667deabaf74cdacc244',
|
|
||||||
'--slug',
|
|
||||||
'fakeOwner/fakeRepo',
|
|
||||||
'-B',
|
|
||||||
'thomasrockhu/test',
|
|
||||||
'--pr',
|
|
||||||
'2',
|
|
||||||
'--parent-sha',
|
|
||||||
'83231650328f11695dfb754ca0f540516f188d27',
|
|
||||||
]));
|
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
for (const env of Object.keys(envs)) {
|
for (const env of Object.keys(envs)) {
|
||||||
delete process.env['INPUT_' + env.toUpperCase()];
|
delete process.env['INPUT_' + env.toUpperCase()];
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const buildCommitExec = () => {
|
|||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
||||||
const commitCommand = 'create-commit';
|
const commitCommand = 'create-commit';
|
||||||
const commitExecArgs = [];
|
const commitExecArgs = [];
|
||||||
@@ -69,16 +69,23 @@ const buildCommitExec = () => {
|
|||||||
if (slug) {
|
if (slug) {
|
||||||
commitExecArgs.push('--slug', `${slug}`);
|
commitExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
commitExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {commitExecArgs, commitOptions, commitCommand};
|
return {commitExecArgs, commitOptions, commitCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildGeneralExec = () => {
|
const buildGeneralExec = () => {
|
||||||
|
const codecovYmlPath = core.getInput('codecov_yml_path');
|
||||||
const url = core.getInput('url');
|
const url = core.getInput('url');
|
||||||
const verbose = isTrue(core.getInput('verbose'));
|
const verbose = isTrue(core.getInput('verbose'));
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
|
if (codecovYmlPath) {
|
||||||
|
args.push('--codecov-yml-path', `${codecovYmlPath}`);
|
||||||
|
}
|
||||||
if (url) {
|
if (url) {
|
||||||
args.push('--enterprise-url', `${url}`);
|
args.push('--enterprise-url', `${url}`);
|
||||||
}
|
}
|
||||||
@@ -90,8 +97,10 @@ const buildGeneralExec = () => {
|
|||||||
|
|
||||||
const buildReportExec = () => {
|
const buildReportExec = () => {
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
|
const overridePr = core.getInput('override_pr');
|
||||||
const slug = core.getInput('slug');
|
const slug = core.getInput('slug');
|
||||||
const token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
|
const failCi = isTrue(core.getInput('fail_ci_if_error'));
|
||||||
|
|
||||||
|
|
||||||
const reportCommand = 'create-report';
|
const reportCommand = 'create-report';
|
||||||
@@ -119,35 +128,54 @@ const buildReportExec = () => {
|
|||||||
) {
|
) {
|
||||||
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
reportExecArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||||
}
|
}
|
||||||
|
if (overridePr) {
|
||||||
|
reportExecArgs.push('-P', `${overridePr}`);
|
||||||
|
} else if (
|
||||||
|
`${context.eventName}` == 'pull_request_target'
|
||||||
|
) {
|
||||||
|
reportExecArgs.push('-P', `${context.payload.number}`);
|
||||||
|
}
|
||||||
if (slug) {
|
if (slug) {
|
||||||
reportExecArgs.push('--slug', `${slug}`);
|
reportExecArgs.push('--slug', `${slug}`);
|
||||||
}
|
}
|
||||||
|
if (failCi) {
|
||||||
|
reportExecArgs.push('-Z');
|
||||||
|
}
|
||||||
|
|
||||||
return {reportExecArgs, reportOptions, reportCommand};
|
return {reportExecArgs, reportOptions, reportCommand};
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildUploadExec = () => {
|
const buildUploadExec = () => {
|
||||||
const envVars = core.getInput('env_vars');
|
const disableFileFixes = isTrue(core.getInput('disable_file_fixes'));
|
||||||
|
const disableSearch = isTrue(core.getInput('disable_search'));
|
||||||
const dryRun = isTrue(core.getInput('dry_run'));
|
const dryRun = isTrue(core.getInput('dry_run'));
|
||||||
|
const envVars = core.getInput('env_vars');
|
||||||
|
const exclude = core.getInput('exclude');
|
||||||
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 handleNoReportsFound = isTrue(core.getInput('handle_no_reports_found'));
|
||||||
|
const jobCode = core.getInput('job_code');
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
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');
|
||||||
|
const overrideBuildUrl = core.getInput('override_build_url');
|
||||||
const overrideCommit = core.getInput('override_commit');
|
const overrideCommit = core.getInput('override_commit');
|
||||||
const overridePr = core.getInput('override_pr');
|
const overridePr = core.getInput('override_pr');
|
||||||
|
const plugin = core.getInput('plugin');
|
||||||
const plugins = core.getInput('plugins');
|
const plugins = core.getInput('plugins');
|
||||||
|
const reportCode = core.getInput('report_code');
|
||||||
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 token = core.getInput('token');
|
const token = core.getInput('token');
|
||||||
let uploaderVersion = core.getInput('version');
|
let uploaderVersion = core.getInput('version');
|
||||||
|
const useLegacyUploadEndpoint = isTrue(
|
||||||
|
core.getInput('use_legacy_upload_endpoint'),
|
||||||
|
);
|
||||||
const workingDir = core.getInput('working-directory');
|
const workingDir = core.getInput('working-directory');
|
||||||
const plugin = core.getInput('plugin');
|
|
||||||
const exclude = core.getInput('exclude');
|
|
||||||
|
|
||||||
const uploadExecArgs = [];
|
const uploadExecArgs = [];
|
||||||
const uploadCommand = 'do-upload';
|
const uploadCommand = 'do-upload';
|
||||||
@@ -169,21 +197,24 @@ const buildUploadExec = () => {
|
|||||||
envVarsArg.push(envVarClean);
|
envVarsArg.push(envVarClean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name) {
|
|
||||||
uploadExecArgs.push(
|
|
||||||
'-n',
|
|
||||||
`${name}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (token) {
|
if (token) {
|
||||||
uploadOptions.env.CODECOV_TOKEN = token;
|
uploadOptions.env.CODECOV_TOKEN = token;
|
||||||
}
|
}
|
||||||
|
if (disableFileFixes) {
|
||||||
|
uploadExecArgs.push('--disable-file-fixes');
|
||||||
|
}
|
||||||
|
if (disableSearch) {
|
||||||
|
uploadExecArgs.push('--disable-search');
|
||||||
|
}
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
uploadExecArgs.push('-d');
|
uploadExecArgs.push('-d');
|
||||||
}
|
}
|
||||||
if (envVarsArg.length) {
|
if (envVarsArg.length) {
|
||||||
uploadExecArgs.push('-e', envVarsArg.join(','));
|
uploadExecArgs.push('-e', envVarsArg.join(','));
|
||||||
}
|
}
|
||||||
|
if (exclude) {
|
||||||
|
uploadExecArgs.push('--exclude', `${exclude}`);
|
||||||
|
}
|
||||||
if (failCi) {
|
if (failCi) {
|
||||||
uploadExecArgs.push('-Z');
|
uploadExecArgs.push('-Z');
|
||||||
}
|
}
|
||||||
@@ -200,12 +231,24 @@ const buildUploadExec = () => {
|
|||||||
uploadExecArgs.push('-F', `${f}`);
|
uploadExecArgs.push('-F', `${f}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (handleNoReportsFound) {
|
||||||
|
uploadExecArgs.push('--handle-no-reports-found');
|
||||||
|
}
|
||||||
|
if (jobCode) {
|
||||||
|
uploadExecArgs.push('--job-code', `${jobCode}`);
|
||||||
|
}
|
||||||
|
if (name) {
|
||||||
|
uploadExecArgs.push('-n', `${name}`);
|
||||||
|
}
|
||||||
if (overrideBranch) {
|
if (overrideBranch) {
|
||||||
uploadExecArgs.push('-B', `${overrideBranch}`);
|
uploadExecArgs.push('-B', `${overrideBranch}`);
|
||||||
}
|
}
|
||||||
if (overrideBuild) {
|
if (overrideBuild) {
|
||||||
uploadExecArgs.push('-b', `${overrideBuild}`);
|
uploadExecArgs.push('-b', `${overrideBuild}`);
|
||||||
}
|
}
|
||||||
|
if (overrideBuildUrl) {
|
||||||
|
uploadExecArgs.push('--build-url', `${overrideBuildUrl}`);
|
||||||
|
}
|
||||||
if (overrideCommit) {
|
if (overrideCommit) {
|
||||||
uploadExecArgs.push('-C', `${overrideCommit}`);
|
uploadExecArgs.push('-C', `${overrideCommit}`);
|
||||||
} else if (
|
} else if (
|
||||||
@@ -221,11 +264,17 @@ const buildUploadExec = () => {
|
|||||||
) {
|
) {
|
||||||
uploadExecArgs.push('-P', `${context.payload.number}`);
|
uploadExecArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
}
|
||||||
|
if (plugin) {
|
||||||
|
uploadExecArgs.push('--plugin', `${plugin}`);
|
||||||
|
}
|
||||||
if (plugins) {
|
if (plugins) {
|
||||||
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
plugins.split(',').map((p) => p.trim()).forEach((p) => {
|
||||||
uploadExecArgs.push('--plugin', `${p}`);
|
uploadExecArgs.push('--plugin', `${p}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (reportCode) {
|
||||||
|
uploadExecArgs.push('--report-code', `${reportCode}`);
|
||||||
|
}
|
||||||
if (rootDir) {
|
if (rootDir) {
|
||||||
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
uploadExecArgs.push('--network-root-folder', `${rootDir}`);
|
||||||
}
|
}
|
||||||
@@ -238,16 +287,12 @@ const buildUploadExec = () => {
|
|||||||
if (workingDir) {
|
if (workingDir) {
|
||||||
uploadOptions.cwd = workingDir;
|
uploadOptions.cwd = workingDir;
|
||||||
}
|
}
|
||||||
if (plugin) {
|
|
||||||
uploadExecArgs.push('--plugin', `${plugin}`);
|
|
||||||
}
|
|
||||||
if (exclude) {
|
|
||||||
uploadExecArgs.push('--exclude', `${exclude}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uploaderVersion == '') {
|
if (uploaderVersion == '') {
|
||||||
uploaderVersion = 'latest';
|
uploaderVersion = 'latest';
|
||||||
}
|
}
|
||||||
|
if (useLegacyUploadEndpoint) {
|
||||||
|
uploadExecArgs.push('--legacy');
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
uploadExecArgs,
|
uploadExecArgs,
|
||||||
|
|||||||
Reference in New Issue
Block a user