mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
Include log chunk when task runner sees log update, clarify if we can pull logs from same line or next line
This commit is contained in:
parent
f563b8c810
commit
534c94e159
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
@ -43,13 +43,13 @@ class KubernetesTaskRunner {
|
||||
CloudRunnerLogger.log(`Log Start found in logs`);
|
||||
}
|
||||
if (chunk.includes(`LOGHASH:`)) {
|
||||
RemoteClientLogger.HandleLogChunkLine(chunk);
|
||||
RemoteClientLogger.HandleLogHash(chunk);
|
||||
CloudRunnerLogger.log(`Loghash found`);
|
||||
}
|
||||
if (chunk.includes(`LOGS:`)) {
|
||||
// remove "LOGS: " and decode base64 remaining
|
||||
const unpacked = Buffer.from(chunk.split(`LOGS: `)[1], 'base64').toString('ascii');
|
||||
const result = RemoteClientLogger.HandleLogChunkLine(unpacked);
|
||||
const result = RemoteClientLogger.HandleLogFull(unpacked);
|
||||
CloudRunnerLogger.log(`Logs found HandleLogChunkLineResult:${result}`);
|
||||
}
|
||||
}
|
||||
@ -73,13 +73,19 @@ class KubernetesTaskRunner {
|
||||
const splitLogs = logs.split(`\n`);
|
||||
for (const chunk of splitLogs) {
|
||||
const message = CloudRunner.buildParameters.cloudRunnerDebug ? chunk : chunk.split(`Z `)[1];
|
||||
|
||||
// if line contains "LOGS: " then stop
|
||||
if (message.includes(`LOGS:`)) {
|
||||
CloudRunnerLogger.log(`LOGS: found`);
|
||||
break;
|
||||
}
|
||||
({ shouldReadLogs, shouldCleanup, output } = FollowLogStreamService.handleIteration(
|
||||
message,
|
||||
shouldReadLogs,
|
||||
shouldCleanup,
|
||||
output,
|
||||
));
|
||||
const result = RemoteClientLogger.HandleLogChunkLine(message);
|
||||
const result = RemoteClientLogger.HandleLog(message);
|
||||
if (result) {
|
||||
FollowLogStreamService.DidReceiveEndOfTransmission = true;
|
||||
}
|
||||
|
@ -68,10 +68,9 @@ export class RemoteClientLogger {
|
||||
await new Promise((resolve) => setTimeout(resolve, 15000));
|
||||
}
|
||||
}
|
||||
public static HandleLogChunkLine(message: string): boolean {
|
||||
public static HandleLog(message: string): boolean {
|
||||
if (message.includes('LOGHASH: ')) {
|
||||
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
||||
CloudRunnerLogger.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
||||
RemoteClientLogger.HandleLogHash(message);
|
||||
} else {
|
||||
if (RemoteClientLogger.value !== '') {
|
||||
RemoteClientLogger.value += `\n`;
|
||||
@ -88,6 +87,24 @@ export class RemoteClientLogger {
|
||||
|
||||
return false;
|
||||
}
|
||||
public static HandleLogHash(message: string) {
|
||||
if (message.includes('LOGHASH: ')) {
|
||||
RemoteClientLogger.md5 = message.split(`LOGHASH: `)[1];
|
||||
CloudRunnerLogger.log(`LOGHASH: ${RemoteClientLogger.md5}`);
|
||||
} else {
|
||||
throw new Error(`LOGHASH: not found`);
|
||||
}
|
||||
}
|
||||
public static HandleLogFull(message: string): boolean {
|
||||
const hashedValue = md5(message);
|
||||
if (RemoteClientLogger.md5 === hashedValue) {
|
||||
CloudRunnerLogger.log(`LOG COMPLETE`);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
static value: string = '';
|
||||
static md5: any;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ describe('Cloud Runner Remote Client', () => {
|
||||
const testLogStream = 'Test \n Log \n Stream';
|
||||
|
||||
const splitLogStream = testLogStream.split('\n');
|
||||
RemoteClientLogger.HandleLogChunkLine(`LOGHASH: ${md5(testLogStream)}`);
|
||||
RemoteClientLogger.HandleLog(`LOGHASH: ${md5(testLogStream)}`);
|
||||
let completed = false;
|
||||
for (const element of splitLogStream) {
|
||||
completed = RemoteClientLogger.HandleLogChunkLine(element);
|
||||
completed = RemoteClientLogger.HandleLog(element);
|
||||
}
|
||||
expect(completed).toBeTruthy();
|
||||
}, 1_000_000_000);
|
||||
|
Loading…
Reference in New Issue
Block a user