Don't fail build jobs if report generation fails.

Fixes #24.
This commit is contained in:
Fabio Niephaus 2022-12-01 13:36:35 +01:00
parent a20b6434b3
commit 778af55c2a
No known key found for this signature in database
GPG Key ID: F21CF5275F31DFD6
4 changed files with 39 additions and 35 deletions

36
dist/cleanup/index.js generated vendored
View File

@ -73781,7 +73781,7 @@ function saveCache() {
* @param promise the promise to ignore error from * @param promise the promise to ignore error from
* @returns Promise that will ignore error reported by the given promise * @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* () { return __awaiter(this, void 0, void 0, function* () {
/* eslint-disable github/no-then */ /* eslint-disable github/no-then */
return new Promise(resolve => { return new Promise(resolve => {
@ -73796,8 +73796,8 @@ function ignoreError(promise) {
} }
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
reports_1.generateReports(); yield ignoreErrors(reports_1.generateReports());
yield ignoreError(saveCache()); yield ignoreErrors(saveCache());
}); });
} }
exports.run = run; exports.run = run;
@ -74151,21 +74151,23 @@ function setUpNativeImageBuildReports(graalVMVersion) {
} }
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
function generateReports() { function generateReports() {
if (areJobReportsEnabled() || arePRReportsEnabled()) { return __awaiter(this, void 0, void 0, function* () {
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { if (areJobReportsEnabled() || arePRReportsEnabled()) {
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
return; 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; exports.generateReports = generateReports;
function areJobReportsEnabled() { function areJobReportsEnabled() {

30
dist/main/index.js generated vendored
View File

@ -74253,21 +74253,23 @@ function setUpNativeImageBuildReports(graalVMVersion) {
} }
exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports; exports.setUpNativeImageBuildReports = setUpNativeImageBuildReports;
function generateReports() { function generateReports() {
if (areJobReportsEnabled() || arePRReportsEnabled()) { return __awaiter(this, void 0, void 0, function* () {
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { if (areJobReportsEnabled() || arePRReportsEnabled()) {
core.warning('Unable to find build output data to create a report. Are you sure this build job has used GraalVM Native Image?'); if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
return; 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; exports.generateReports = generateReports;
function areJobReportsEnabled() { function areJobReportsEnabled() {

View File

@ -44,7 +44,7 @@ async function saveCache(): Promise<void> {
* @param promise the promise to ignore error from * @param promise the promise to ignore error from
* @returns Promise that will ignore error reported by the given promise * @returns Promise that will ignore error reported by the given promise
*/ */
async function ignoreError(promise: Promise<void>): Promise<unknown> { async function ignoreErrors(promise: Promise<void>): Promise<unknown> {
/* eslint-disable github/no-then */ /* eslint-disable github/no-then */
return new Promise(resolve => { return new Promise(resolve => {
promise promise
@ -57,8 +57,8 @@ async function ignoreError(promise: Promise<void>): Promise<unknown> {
} }
export async function run(): Promise<void> { export async function run(): Promise<void> {
generateReports() await ignoreErrors(generateReports())
await ignoreError(saveCache()) await ignoreErrors(saveCache())
} }
if (require.main === module) { if (require.main === module) {

View File

@ -101,7 +101,7 @@ export async function setUpNativeImageBuildReports(
) // Escape backslashes for Windows ) // Escape backslashes for Windows
} }
export function generateReports(): void { export async function generateReports(): Promise<void> {
if (areJobReportsEnabled() || arePRReportsEnabled()) { if (areJobReportsEnabled() || arePRReportsEnabled()) {
if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) { if (!fs.existsSync(BUILD_OUTPUT_JSON_PATH)) {
core.warning( core.warning(