From 778af55c2a4db58e95a5a51ca1ad2bd5ce32ba5a Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 1 Dec 2022 13:36:35 +0100 Subject: [PATCH] Don't fail build jobs if report generation fails. Fixes #24. --- dist/cleanup/index.js | 36 +++++++++++++++++++----------------- dist/main/index.js | 30 ++++++++++++++++-------------- src/cleanup.ts | 6 +++--- src/features/reports.ts | 2 +- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index b826875..e122576 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -73781,7 +73781,7 @@ function saveCache() { * @param promise the promise to ignore error from * @returns Promise that will ignore error reported by the given promise */ -function ignoreError(promise) { +function ignoreErrors(promise) { return __awaiter(this, void 0, void 0, function* () { /* eslint-disable github/no-then */ return new Promise(resolve => { @@ -73796,8 +73796,8 @@ function ignoreError(promise) { } function run() { return __awaiter(this, void 0, void 0, function* () { - reports_1.generateReports(); - yield ignoreError(saveCache()); + yield ignoreErrors(reports_1.generateReports()); + yield ignoreErrors(saveCache()); }); } exports.run = run; @@ -74151,21 +74151,23 @@ function setUpNativeImageBuildReports(graalVMVersion) { } exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; function generateReports() { - if (areJobReportsEnabled() || arePRReportsEnabled()) { - if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { - core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); - return; + return __awaiter(this, void 0, void 0, function* () { + if (areJobReportsEnabled() || arePRReportsEnabled()) { + if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { + core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); + return; + } + const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8')); + const report = createReport(buildOutput); + if (areJobReportsEnabled()) { + core.summary.addRaw(report); + core.summary.write(); + } + if (arePRReportsEnabled()) { + utils_1.createPRComment(report); + } } - const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8')); - const report = createReport(buildOutput); - if (areJobReportsEnabled()) { - core.summary.addRaw(report); - core.summary.write(); - } - if (arePRReportsEnabled()) { - utils_1.createPRComment(report); - } - } + }); } exports.generateReports = generateReports; function areJobReportsEnabled() { diff --git a/dist/main/index.js b/dist/main/index.js index b97dbcb..b661fa3 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -74253,21 +74253,23 @@ function setUpNativeImageBuildReports(graalVMVersion) { } exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; function generateReports() { - if (areJobReportsEnabled() || arePRReportsEnabled()) { - if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { - core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); - return; + return __awaiter(this, void 0, void 0, function* () { + if (areJobReportsEnabled() || arePRReportsEnabled()) { + if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { + core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); + return; + } + const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8')); + const report = createReport(buildOutput); + if (areJobReportsEnabled()) { + core.summary.addRaw(report); + core.summary.write(); + } + if (arePRReportsEnabled()) { + utils_1.createPRComment(report); + } } - const buildOutput = JSON.parse(fs.readFileSync(BUILD_OUTPUT_JSON_PATH, 'utf8')); - const report = createReport(buildOutput); - if (areJobReportsEnabled()) { - core.summary.addRaw(report); - core.summary.write(); - } - if (arePRReportsEnabled()) { - utils_1.createPRComment(report); - } - } + }); } exports.generateReports = generateReports; function areJobReportsEnabled() { diff --git a/src/cleanup.ts b/src/cleanup.ts index c94ba38..3ed1b0c 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -44,7 +44,7 @@ async function saveCache(): Promise { * @param promise the promise to ignore error from * @returns Promise that will ignore error reported by the given promise */ -async function ignoreError(promise: Promise): Promise { +async function ignoreErrors(promise: Promise): Promise { /* eslint-disable github/no-then */ return new Promise(resolve => { promise @@ -57,8 +57,8 @@ async function ignoreError(promise: Promise): Promise { } export async function run(): Promise { - generateReports() - await ignoreError(saveCache()) + await ignoreErrors(generateReports()) + await ignoreErrors(saveCache()) } if (require.main === module) { diff --git a/src/features/reports.ts b/src/features/reports.ts index 23731ea..3533057 100644 --- a/src/features/reports.ts +++ b/src/features/reports.ts @@ -101,7 +101,7 @@ export async function setUpNativeImageBuildReports( ) // Escape backslashes for Windows } -export function generateReports(): void { +export async function generateReports(): Promise { if (areJobReportsEnabled() || arePRReportsEnabled()) { if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { core.warning(