mirror of
https://github.com/codecov/codecov-action.git
synced 2026-04-13 01:20:06 +00:00
use CLI instead of uploader
This commit is contained in:
parent
8ccb892add
commit
0c99ab319f
8 changed files with 143 additions and 656 deletions
248
dist/index.js
vendored
248
dist/index.js
vendored
|
|
@ -22068,15 +22068,12 @@ var external_path_ = __nccwpck_require__(1017);
|
|||
// EXTERNAL MODULE: ./node_modules/@actions/exec/lib/exec.js
|
||||
var exec = __nccwpck_require__(1514);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
|
||||
var lib_core = __nccwpck_require__(2186);
|
||||
var core = __nccwpck_require__(2186);
|
||||
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
|
||||
var github = __nccwpck_require__(5438);
|
||||
;// CONCATENATED MODULE: ./package.json
|
||||
const package_namespaceObject = {"i8":"3.1.4"};
|
||||
;// CONCATENATED MODULE: ./src/buildExec.ts
|
||||
|
||||
|
||||
|
||||
const context = github.context;
|
||||
const isTrue = (variable) => {
|
||||
const lowercase = variable.toLowerCase();
|
||||
|
|
@ -22086,188 +22083,6 @@ const isTrue = (variable) => {
|
|||
lowercase === 'y' ||
|
||||
lowercase === 'yes');
|
||||
};
|
||||
const buildExec = () => {
|
||||
const clean = lib_core.getInput('move_coverage_to_trash');
|
||||
const commitParent = lib_core.getInput('commit_parent');
|
||||
const dryRun = isTrue(lib_core.getInput('dry_run'));
|
||||
const envVars = lib_core.getInput('env_vars');
|
||||
const failCi = isTrue(lib_core.getInput('fail_ci_if_error'));
|
||||
const file = lib_core.getInput('file');
|
||||
const files = lib_core.getInput('files');
|
||||
const flags = lib_core.getInput('flags');
|
||||
const fullReport = lib_core.getInput('full_report');
|
||||
const functionalities = lib_core.getInput('functionalities');
|
||||
const gcov = lib_core.getInput('gcov');
|
||||
const gcovArgs = lib_core.getInput('gcov_args');
|
||||
const gcovExecutable = lib_core.getInput('gcov_executable');
|
||||
const gcovIgnore = lib_core.getInput('gcov_ignore');
|
||||
const gcovInclude = lib_core.getInput('gcov_include');
|
||||
const name = lib_core.getInput('name');
|
||||
const networkFilter = lib_core.getInput('network_filter');
|
||||
const networkPrefix = lib_core.getInput('network_prefix');
|
||||
const os = lib_core.getInput('os');
|
||||
const overrideBranch = lib_core.getInput('override_branch');
|
||||
const overrideBuild = lib_core.getInput('override_build');
|
||||
const overrideCommit = lib_core.getInput('override_commit');
|
||||
const overridePr = lib_core.getInput('override_pr');
|
||||
const overrideTag = lib_core.getInput('override_tag');
|
||||
const rootDir = lib_core.getInput('root_dir');
|
||||
const searchDir = lib_core.getInput('directory');
|
||||
const slug = lib_core.getInput('slug');
|
||||
const swift = lib_core.getInput('swift');
|
||||
const swiftProject = lib_core.getInput('swift_project');
|
||||
const token = lib_core.getInput('token');
|
||||
const upstream = lib_core.getInput('upstream_proxy');
|
||||
const url = lib_core.getInput('url');
|
||||
const verbose = isTrue(lib_core.getInput('verbose'));
|
||||
const workingDir = lib_core.getInput('working-directory');
|
||||
const xcode = lib_core.getInput('xcode');
|
||||
const xcodeArchivePath = lib_core.getInput('xcode_archive_path');
|
||||
const xtraArgs = lib_core.getInput('xtra_args');
|
||||
let uploaderVersion = lib_core.getInput('version');
|
||||
const execArgs = [];
|
||||
execArgs.push('-n', `${name}`, '-Q', `github-action-${package_namespaceObject.i8}`);
|
||||
const 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 || '',
|
||||
});
|
||||
const envVarsArg = [];
|
||||
for (const envVar of envVars.split(',')) {
|
||||
const envVarClean = envVar.trim();
|
||||
if (envVarClean) {
|
||||
options.env[envVarClean] = process.env[envVarClean];
|
||||
envVarsArg.push(envVarClean);
|
||||
}
|
||||
}
|
||||
if (token) {
|
||||
options.env.CODECOV_TOKEN = token;
|
||||
}
|
||||
if (clean) {
|
||||
execArgs.push('-c');
|
||||
}
|
||||
if (commitParent) {
|
||||
execArgs.push('-N', `${commitParent}`);
|
||||
}
|
||||
if (dryRun) {
|
||||
execArgs.push('-d');
|
||||
}
|
||||
if (envVarsArg.length) {
|
||||
execArgs.push('-e', envVarsArg.join(','));
|
||||
}
|
||||
if (functionalities) {
|
||||
functionalities.split(',').map((f) => f.trim()).forEach((f) => {
|
||||
execArgs.push('-X', `${f}`);
|
||||
});
|
||||
}
|
||||
if (failCi) {
|
||||
execArgs.push('-Z');
|
||||
}
|
||||
if (file) {
|
||||
execArgs.push('-f', `${file}`);
|
||||
}
|
||||
if (files) {
|
||||
files.split(',').map((f) => f.trim()).forEach((f) => {
|
||||
execArgs.push('-f', `${f}`);
|
||||
});
|
||||
}
|
||||
if (fullReport) {
|
||||
execArgs.push('--full', `${fullReport}`);
|
||||
}
|
||||
if (flags) {
|
||||
flags.split(',').map((f) => f.trim()).forEach((f) => {
|
||||
execArgs.push('-F', `${f}`);
|
||||
});
|
||||
}
|
||||
if (gcov) {
|
||||
execArgs.push('-g');
|
||||
}
|
||||
if (gcovArgs) {
|
||||
execArgs.push('--ga', `${gcovArgs}`);
|
||||
}
|
||||
if (gcovIgnore) {
|
||||
execArgs.push('--gi', `${gcovIgnore}`);
|
||||
}
|
||||
if (gcovInclude) {
|
||||
execArgs.push('--gI', `${gcovInclude}`);
|
||||
}
|
||||
if (gcovExecutable) {
|
||||
execArgs.push('--gx', `${gcovExecutable}`);
|
||||
}
|
||||
if (networkFilter) {
|
||||
execArgs.push('-i', `${networkFilter}`);
|
||||
}
|
||||
if (networkPrefix) {
|
||||
execArgs.push('-k', `${networkPrefix}`);
|
||||
}
|
||||
if (overrideBranch) {
|
||||
execArgs.push('-B', `${overrideBranch}`);
|
||||
}
|
||||
if (overrideBuild) {
|
||||
execArgs.push('-b', `${overrideBuild}`);
|
||||
}
|
||||
if (overrideCommit) {
|
||||
execArgs.push('-C', `${overrideCommit}`);
|
||||
}
|
||||
else if (`${context.eventName}` == 'pull_request' ||
|
||||
`${context.eventName}` == 'pull_request_target') {
|
||||
execArgs.push('-C', `${context.payload.pull_request.head.sha}`);
|
||||
}
|
||||
if (overridePr) {
|
||||
execArgs.push('-P', `${overridePr}`);
|
||||
}
|
||||
else if (`${context.eventName}` == 'pull_request_target') {
|
||||
execArgs.push('-P', `${context.payload.number}`);
|
||||
}
|
||||
if (overrideTag) {
|
||||
execArgs.push('-T', `${overrideTag}`);
|
||||
}
|
||||
if (rootDir) {
|
||||
execArgs.push('-R', `${rootDir}`);
|
||||
}
|
||||
if (searchDir) {
|
||||
execArgs.push('-s', `${searchDir}`);
|
||||
}
|
||||
if (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) {
|
||||
execArgs.push('-u', `${url}`);
|
||||
}
|
||||
if (verbose) {
|
||||
execArgs.push('-v');
|
||||
}
|
||||
if (xcode && xcodeArchivePath) {
|
||||
execArgs.push('--xc');
|
||||
execArgs.push('--xp', `${xcodeArchivePath}`);
|
||||
}
|
||||
if (uploaderVersion == '') {
|
||||
uploaderVersion = 'latest';
|
||||
}
|
||||
if (verbose) {
|
||||
console.debug({ execArgs });
|
||||
}
|
||||
if (workingDir) {
|
||||
options.cwd = workingDir;
|
||||
}
|
||||
if (xtraArgs) {
|
||||
execArgs.push(`${xtraArgs}`);
|
||||
}
|
||||
return { execArgs, options, failCi, os, uploaderVersion, verbose };
|
||||
};
|
||||
const buildCommitExec = () => {
|
||||
const commitParent = core.getInput('commit_parent');
|
||||
const overrideBranch = core.getInput('override_branch');
|
||||
|
|
@ -22323,7 +22138,7 @@ const buildGeneralExec = () => {
|
|||
if (verbose) {
|
||||
args.push('-v');
|
||||
}
|
||||
return args;
|
||||
return { args, verbose };
|
||||
};
|
||||
const buildReportExec = () => {
|
||||
const overrideCommit = core.getInput('override_commit');
|
||||
|
|
@ -22475,14 +22290,12 @@ const buildUploadExec = () => {
|
|||
;// CONCATENATED MODULE: ./src/helpers.ts
|
||||
|
||||
const PLATFORMS = [
|
||||
'aarch64',
|
||||
'alpine',
|
||||
'linux',
|
||||
'macos',
|
||||
'windows',
|
||||
];
|
||||
const setFailure = (message, failCi) => {
|
||||
failCi ? lib_core.setFailed(message) : lib_core.warning(message);
|
||||
failCi ? core.setFailed(message) : core.warning(message);
|
||||
if (failCi) {
|
||||
process.exit();
|
||||
}
|
||||
|
|
@ -22504,19 +22317,22 @@ const isWindows = (platform) => {
|
|||
const getPlatform = (os) => {
|
||||
var _a;
|
||||
if (isValidPlatform(os)) {
|
||||
lib_core.info(`==> ${os} OS provided`);
|
||||
core.info(`==> ${os} OS provided`);
|
||||
return os;
|
||||
}
|
||||
const platform = (_a = process.env.RUNNER_OS) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
||||
if (isValidPlatform(platform)) {
|
||||
lib_core.info(`==> ${platform} OS detected`);
|
||||
core.info(`==> ${platform} OS detected`);
|
||||
return platform;
|
||||
}
|
||||
lib_core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
|
||||
core.info('==> Could not detect OS or provided OS is invalid. Defaulting to linux');
|
||||
return 'linux';
|
||||
};
|
||||
const getBaseUrl = (platform, version) => {
|
||||
return `https://uploader.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||
return `https://cli.codecov.io/${version}/${platform}/${getUploaderName(platform)}`;
|
||||
};
|
||||
const getCommand = (filename, generalArgs, command) => {
|
||||
return filename + ' ' + generalArgs.join(' ') + ' ' + command;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -24715,7 +24531,7 @@ const verify = (filename, platform, version, verbose, failCi) => __awaiter(void
|
|||
});
|
||||
const valid = yield verified.signatures[0].verified;
|
||||
if (valid) {
|
||||
lib_core.info('==> SHASUM file signed by key id ' +
|
||||
core.info('==> SHASUM file signed by key id ' +
|
||||
verified.signatures[0].keyID.toHex());
|
||||
}
|
||||
else {
|
||||
|
|
@ -24732,7 +24548,7 @@ const verify = (filename, platform, version, verbose, failCi) => __awaiter(void
|
|||
});
|
||||
const hash = yield calculateHash(filename);
|
||||
if (hash === shasum) {
|
||||
lib_core.info(`==> Uploader SHASUM verified (${hash})`);
|
||||
core.info(`==> Uploader SHASUM verified (${hash})`);
|
||||
}
|
||||
else {
|
||||
setFailure('Codecov: Uploader shasum does not match -- ' +
|
||||
|
|
@ -24759,17 +24575,17 @@ var version_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _
|
|||
|
||||
const versionInfo = (platform, version) => version_awaiter(void 0, void 0, void 0, function* () {
|
||||
if (version) {
|
||||
lib_core.info(`==> Running version ${version}`);
|
||||
core.info(`==> Running version ${version}`);
|
||||
}
|
||||
try {
|
||||
const metadataRes = yield fetch(`https://uploader.codecov.io/${platform}/latest`, {
|
||||
headers: { 'Accept': 'application/json' },
|
||||
});
|
||||
const metadata = yield metadataRes.json();
|
||||
lib_core.info(`==> Running version ${metadata['version']}`);
|
||||
core.info(`==> Running version ${metadata['version']}`);
|
||||
}
|
||||
catch (err) {
|
||||
lib_core.info(`Could not pull latest version information: ${err}`);
|
||||
core.info(`Could not pull latest version information: ${err}`);
|
||||
}
|
||||
});
|
||||
/* harmony default export */ const version = (versionInfo);
|
||||
|
|
@ -24794,7 +24610,10 @@ var src_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|||
|
||||
let failCi;
|
||||
try {
|
||||
const { execArgs, options, failCi, os, uploaderVersion, verbose } = buildExec();
|
||||
const { commitExecArgs, commitOptions, commitCommand } = buildCommitExec();
|
||||
const { reportExecArgs, reportOptions, reportCommand } = buildReportExec();
|
||||
const { uploadExecArgs, uploadOptions, failCi, os, uploaderVersion, uploadCommand, } = buildUploadExec();
|
||||
const { args, verbose } = buildGeneralExec();
|
||||
const platform = getPlatform(os);
|
||||
const filename = external_path_.join(__dirname, getUploaderName(platform));
|
||||
external_https_.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||
|
|
@ -24816,11 +24635,32 @@ try {
|
|||
}
|
||||
});
|
||||
};
|
||||
yield exec.exec(filename, execArgs, options)
|
||||
.catch((err) => {
|
||||
setFailure(`Codecov: Failed to properly upload: ${err.message}`, failCi);
|
||||
}).then(() => {
|
||||
const doUpload = () => src_awaiter(void 0, void 0, void 0, function* () {
|
||||
yield exec.exec(getCommand(filename, args, uploadCommand), uploadExecArgs, uploadOptions)
|
||||
.catch((err) => {
|
||||
setFailure(`Codecov:
|
||||
Failed to properly upload report: ${err.message}`, failCi);
|
||||
});
|
||||
});
|
||||
const createReport = () => src_awaiter(void 0, void 0, void 0, function* () {
|
||||
yield exec.exec(getCommand(filename, args, reportCommand), reportExecArgs, reportOptions)
|
||||
.then((exitCode) => src_awaiter(void 0, void 0, void 0, function* () {
|
||||
if (exitCode == 0) {
|
||||
yield doUpload();
|
||||
}
|
||||
})).catch((err) => {
|
||||
setFailure(`Codecov:
|
||||
Failed to properly create report: ${err.message}`, failCi);
|
||||
});
|
||||
});
|
||||
yield exec.exec(getCommand(filename, args, commitCommand), commitExecArgs, commitOptions)
|
||||
.then((exitCode) => src_awaiter(void 0, void 0, void 0, function* () {
|
||||
if (exitCode == 0) {
|
||||
yield createReport();
|
||||
}
|
||||
unlink();
|
||||
})).catch((err) => {
|
||||
setFailure(`Codecov: Failed to properly create commit: ${err.message}`, failCi);
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue