GAME_CI_BUILD_SUCCESS and GAME_CI_STEP_SUMMARY

pull/576/head
Toby Harris 2023-09-21 14:17:50 +01:00
parent 2190fd5667
commit 4dd5a3fb85
3 changed files with 43 additions and 15 deletions

24
dist/index.js generated vendored
View File

@ -5983,24 +5983,34 @@ exports["default"] = ValidationError;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.execWithErrorCheck = void 0;
const exec_1 = __nccwpck_require__(71514);
const core_1 = __nccwpck_require__(42186);
async function execWithErrorCheck(commandLine, arguments_, options, errorWhenMissingUnityBuildResults = true) {
const result = await (0, exec_1.getExecOutput)(commandLine, arguments_, options);
if (!errorWhenMissingUnityBuildResults) {
return result.exitCode;
}
// Check for errors in the Build Results section
const match = result.stdout.match(/^#\s*Build results\s*#(.*)^Size:/ms);
if (match) {
const buildResults = match[1];
// Check for errors in the Unity Build Results section
const unityMatch = result.stdout.match(/^#\s*Build results\s*#(.*)^Size:/ms);
if (unityMatch) {
const buildResults = unityMatch[1];
const errorMatch = buildResults.match(/^Errors:\s*(\d+)$/m);
if (errorMatch && Number.parseInt(errorMatch[1], 10) !== 0) {
throw new Error(`There was an error building the project. Please read the logs for details.`);
}
await core_1.summary.addHeading('Build Results').addQuote(unityMatch[0]).write();
return result.exitCode;
}
else {
throw new Error(`There was an error building the project. Please read the logs for details.`);
// Check for presence of game-ci message(s)
const gameciMatch = result.stdout.match(/^GAME_CI_BUILD_SUCCESS$/ms);
if (gameciMatch) {
const quote = result.stdout
.match(/^GAME_CI_STEP_SUMMARY.*$/gm)
?.map((x) => x.replace('GAME_CI_STEP_SUMMARY', ''))
.join('\n\n') ?? '<No GAME_CI_STEP_SUMMARY messages found>';
await core_1.summary.addHeading('Build Results').addQuote(quote).write();
return result.exitCode;
}
return result.exitCode;
throw new Error(`There was an error building the project. Did not find success messages in logs (either Unity's build results or GAME_CI_BUILD_SUCCESS).`);
}
exports.execWithErrorCheck = execWithErrorCheck;

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
import { getExecOutput, ExecOptions } from '@actions/exec';
import { summary } from '@actions/core';
export async function execWithErrorCheck(
commandLine: string,
@ -12,18 +13,35 @@ export async function execWithErrorCheck(
return result.exitCode;
}
// Check for errors in the Build Results section
const match = result.stdout.match(/^#\s*Build results\s*#(.*)^Size:/ms);
// Check for errors in the Unity Build Results section
const unityMatch = result.stdout.match(/^#\s*Build results\s*#(.*)^Size:/ms);
if (match) {
const buildResults = match[1];
if (unityMatch) {
const buildResults = unityMatch[1];
const errorMatch = buildResults.match(/^Errors:\s*(\d+)$/m);
if (errorMatch && Number.parseInt(errorMatch[1], 10) !== 0) {
throw new Error(`There was an error building the project. Please read the logs for details.`);
}
} else {
throw new Error(`There was an error building the project. Please read the logs for details.`);
await summary.addHeading('Build Results').addQuote(unityMatch[0]).write();
return result.exitCode;
}
return result.exitCode;
// Check for presence of game-ci message(s)
const gameciMatch = result.stdout.match(/^GAME_CI_BUILD_SUCCESS$/ms);
if (gameciMatch) {
const quote =
result.stdout
.match(/^GAME_CI_STEP_SUMMARY.*$/gm)
?.map((x) => x.replace('GAME_CI_STEP_SUMMARY', ''))
.join('\n\n') ?? '<No GAME_CI_STEP_SUMMARY messages found>';
await summary.addHeading('Build Results').addQuote(quote).write();
return result.exitCode;
}
throw new Error(
`There was an error building the project. Did not find success messages in logs (either Unity's build results or GAME_CI_BUILD_SUCCESS).`,
);
}