pull/289/head
Frostebite 2021-09-09 01:31:33 +01:00
parent 66b320318f
commit a7be23ee91
3 changed files with 45 additions and 43 deletions

29
dist/index.js vendored
View File

@ -733,25 +733,14 @@ class AWSBuildRunner {
const taskArn = ((_o = task.tasks) === null || _o === void 0 ? void 0 : _o[0].taskArn) || ''; const taskArn = ((_o = task.tasks) === null || _o === void 0 ? void 0 : _o[0].taskArn) || '';
try { try {
yield ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise(); yield ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise();
}
catch (error_) {
const error = error_;
yield new Promise((resolve) => setTimeout(resolve, 3000));
const describeTasks = yield ECS.describeTasks({
tasks: [taskArn],
cluster,
}).promise();
core.info(`Cloud runner job has ended ${(_q = (_p = describeTasks.tasks) === null || _p === void 0 ? void 0 : _p[0].containers) === null || _q === void 0 ? void 0 : _q[0].lastStatus}`);
core.setFailed(error);
core.error(error);
}
core.info(`Cloud runner job is running`); core.info(`Cloud runner job is running`);
yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName); yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
yield ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise(); yield ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
const exitCode = (_s = (_r = (yield ECS.describeTasks({ const exitCode = (_q = (_p = (yield ECS.describeTasks({
tasks: [taskArn], tasks: [taskArn],
cluster, cluster,
}).promise()).tasks) === null || _r === void 0 ? void 0 : _r[0].containers) === null || _s === void 0 ? void 0 : _s[0].exitCode; }).promise()).tasks) === null || _p === void 0 ? void 0 : _p[0].containers) === null || _q === void 0 ? void 0 : _q[0].exitCode;
core.info(`Cloud runner job exit code ${exitCode}`);
if (exitCode !== 0) { if (exitCode !== 0) {
core.error(`job failed with exit code ${exitCode} ${JSON.stringify(yield ECS.describeTasks({ core.error(`job failed with exit code ${exitCode} ${JSON.stringify(yield ECS.describeTasks({
tasks: [taskArn], tasks: [taskArn],
@ -762,6 +751,18 @@ class AWSBuildRunner {
else { else {
core.info(`Cloud runner job has finished successfully`); core.info(`Cloud runner job has finished successfully`);
} }
}
catch (error_) {
const error = error_;
yield new Promise((resolve) => setTimeout(resolve, 3000));
const describeTasks = yield ECS.describeTasks({
tasks: [taskArn],
cluster,
}).promise();
core.info(`Cloud runner job has ended ${(_s = (_r = describeTasks.tasks) === null || _r === void 0 ? void 0 : _r[0].containers) === null || _s === void 0 ? void 0 : _s[0].lastStatus}`);
core.setFailed(error);
core.error(error);
}
}); });
} }
static streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName) { static streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -53,18 +53,6 @@ class AWSBuildRunner {
try { try {
await ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise(); await ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise();
} catch (error_) {
const error = error_ as Error;
await new Promise((resolve) => setTimeout(resolve, 3000));
const describeTasks = await ECS.describeTasks({
tasks: [taskArn],
cluster,
}).promise();
core.info(`Cloud runner job has ended ${describeTasks.tasks?.[0].containers?.[0].lastStatus}`);
core.setFailed(error);
core.error(error);
}
core.info(`Cloud runner job is running`); core.info(`Cloud runner job is running`);
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName); await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
await ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise(); await ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
@ -74,6 +62,7 @@ class AWSBuildRunner {
cluster, cluster,
}).promise() }).promise()
).tasks?.[0].containers?.[0].exitCode; ).tasks?.[0].containers?.[0].exitCode;
core.info(`Cloud runner job exit code ${exitCode}`);
if (exitCode !== 0) { if (exitCode !== 0) {
core.error( core.error(
`job failed with exit code ${exitCode} ${JSON.stringify( `job failed with exit code ${exitCode} ${JSON.stringify(
@ -89,6 +78,18 @@ class AWSBuildRunner {
} else { } else {
core.info(`Cloud runner job has finished successfully`); core.info(`Cloud runner job has finished successfully`);
} }
} catch (error_) {
const error = error_ as Error;
await new Promise((resolve) => setTimeout(resolve, 3000));
const describeTasks = await ECS.describeTasks({
tasks: [taskArn],
cluster,
}).promise();
core.info(`Cloud runner job has ended ${describeTasks.tasks?.[0].containers?.[0].lastStatus}`);
core.setFailed(error);
core.error(error);
}
} }
static async streamLogsUntilTaskStops( static async streamLogsUntilTaskStops(