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
* @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() {

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

@ -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() {

View File

@ -44,7 +44,7 @@ async function saveCache(): Promise<void> {
* @param promise the promise to ignore error from
* @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 */
return new Promise(resolve => {
promise
@ -57,8 +57,8 @@ async function ignoreError(promise: Promise<void>): Promise<unknown> {
}
export async function run(): Promise<void> {
generateReports()
await ignoreError(saveCache())
await ignoreErrors(generateReports())
await ignoreErrors(saveCache())
}
if (require.main === module) {

View File

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