mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-16 16:01:44 +00:00
Use existing uploader if present
Workaround for https://github.com/codecov/codecov-action/issues/586
This commit is contained in:
parent
260aa3b4b2
commit
3f000fc412
3 changed files with 93 additions and 50 deletions
94
dist/index.js
vendored
94
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
47
src/index.ts
47
src/index.ts
|
|
@ -17,16 +17,36 @@ import versionInfo from './version';
|
||||||
|
|
||||||
let failCi;
|
let failCi;
|
||||||
|
|
||||||
try {
|
async function main(): Promise<void> {
|
||||||
const {execArgs, options, failCi, os, uploaderVersion} = buildExec();
|
const { execArgs, options, failCi, os, uploaderVersion } = buildExec();
|
||||||
const platform = getPlatform(os);
|
const platform = getPlatform(os);
|
||||||
|
const uploaderName = getUploaderName(platform);
|
||||||
const filename = path.join( __dirname, getUploaderName(platform));
|
let foundVersion: string | undefined;
|
||||||
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
try {
|
||||||
// Image will be stored at this path
|
await exec.exec(
|
||||||
const filePath = fs.createWriteStream(filename);
|
uploaderName,
|
||||||
res.pipe(filePath);
|
['--version'],
|
||||||
filePath
|
{ listeners: { stdout: (data) => (foundVersion = data.toString().trim()) },
|
||||||
|
});
|
||||||
|
} catch (ignored) {}
|
||||||
|
if (
|
||||||
|
foundVersion &&
|
||||||
|
(uploaderVersion == 'latest' || foundVersion === uploaderVersion)
|
||||||
|
) {
|
||||||
|
// We don't need to download the uploader, we can just execute it ...
|
||||||
|
try {
|
||||||
|
await exec.exec(uploaderName, execArgs, options);
|
||||||
|
} catch (err) {
|
||||||
|
setFailure(`Codecov: Failed to properly upload: ${err.message}`, failCi);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// We need to download the uploader ...
|
||||||
|
const filename = path.join(__dirname, uploaderName);
|
||||||
|
https.get(getBaseUrl(platform, uploaderVersion), (res) => {
|
||||||
|
// Uploader will be stored at this path
|
||||||
|
const filePath = fs.createWriteStream(filename);
|
||||||
|
res.pipe(filePath);
|
||||||
|
filePath
|
||||||
.on('error', (err) => {
|
.on('error', (err) => {
|
||||||
setFailure(
|
setFailure(
|
||||||
`Codecov: Failed to write uploader binary: ${err.message}`,
|
`Codecov: Failed to write uploader binary: ${err.message}`,
|
||||||
|
|
@ -59,7 +79,10 @@ try {
|
||||||
unlink();
|
unlink();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (err) {
|
}
|
||||||
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main().catch((err) =>
|
||||||
|
setFailure(`Codecov: Encountered an unexpected error ${err.message}`, failCi)
|
||||||
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue