use cli instead of node uploader (#1068)

* use cli instead of node uploader

* changes based on review

* logging out run command
This commit is contained in:
Dana Yaish
2023-09-13 11:39:47 +03:00
committed by GitHub
parent c9e0f0b3cf
commit c9e4b73267
8 changed files with 150 additions and 656 deletions

View File

@@ -4,12 +4,18 @@ import * as path from 'path';
import * as exec from '@actions/exec';
import {buildExec} from './buildExec';
import {
buildCommitExec,
buildGeneralExec,
buildReportExec,
buildUploadExec,
} from './buildExec';
import {
getBaseUrl,
getPlatform,
getUploaderName,
setFailure,
getCommand,
} from './helpers';
import verify from './validate';
@@ -18,7 +24,18 @@ import versionInfo from './version';
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 = path.join( __dirname, getUploaderName(platform));
@@ -49,14 +66,52 @@ try {
}
});
};
await exec.exec(filename, execArgs, options)
.catch((err) => {
const doUpload = async () => {
await exec.exec(getCommand(filename, args, uploadCommand).join(' '),
uploadExecArgs,
uploadOptions)
.catch((err) => {
setFailure(
`Codecov:
Failed to properly upload report: ${err.message}`,
failCi,
);
});
};
const createReport = async () => {
await exec.exec(
getCommand(filename, args, reportCommand).join(' '),
reportExecArgs,
reportOptions)
.then(async (exitCode) => {
if (exitCode == 0) {
await doUpload();
}
}).catch((err) => {
setFailure(
`Codecov:
Failed to properly create report: ${err.message}`,
failCi,
);
});
};
await exec.exec(
getCommand(
filename,
args,
commitCommand,
).join(' '),
commitExecArgs, commitOptions)
.then(async (exitCode) => {
if (exitCode == 0) {
await createReport();
}
unlink();
}).catch((err) => {
setFailure(
`Codecov: Failed to properly upload: ${err.message}`,
`Codecov: Failed to properly create commit: ${err.message}`,
failCi,
);
}).then(() => {
unlink();
});
});
});