cleanup
parent
a3cf12c7c4
commit
c857c1af84
|
|
@ -362,14 +362,14 @@ class AWS {
|
|||
ParameterValue: buildParameters.androidKeyaliasPass ? buildParameters.androidKeyaliasPass : '0',
|
||||
},
|
||||
]);
|
||||
core.info('starting part 3/4 (zip and publish latest Library to cache)');
|
||||
core.info('starting part 3/4 (zip build and latest Library for caching)');
|
||||
// Cleanup
|
||||
yield this.run(buildUid, buildParameters.awsStackName, 'alpine', ['/bin/sh'], [
|
||||
'-c',
|
||||
`
|
||||
apk update;
|
||||
apk add zip
|
||||
zip -r ./${buildUid}/Library/. ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/Library/* ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/output.zip ./${buildUid}/repo/build
|
||||
ls
|
||||
`,
|
||||
|
|
@ -508,7 +508,7 @@ class AWS {
|
|||
StackName: taskDefStackName,
|
||||
}).promise();
|
||||
const baseResources = yield CF.describeStackResources({ StackName: stackName }).promise();
|
||||
core.info('Build cluster created successfully (skipping waiting for cleanup cluster to start)');
|
||||
core.info('Build cluster created successfully (skipping wait for cleanup cluster to create)');
|
||||
return {
|
||||
taskDefStackName,
|
||||
taskDefCloudFormation,
|
||||
|
|
@ -522,14 +522,14 @@ class AWS {
|
|||
static runTask(taskDef, ECS, CF, environment, buildUid) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const clusterName = ((_b = (_a = taskDef.baseResources.StackResources) === null || _a === void 0 ? void 0 : _a.find((x) => x.LogicalResourceId === 'ECSCluster')) === null || _b === void 0 ? void 0 : _b.PhysicalResourceId) || '';
|
||||
const cluster = ((_b = (_a = taskDef.baseResources.StackResources) === null || _a === void 0 ? void 0 : _a.find((x) => x.LogicalResourceId === 'ECSCluster')) === null || _b === void 0 ? void 0 : _b.PhysicalResourceId) || '';
|
||||
const taskDefinition = ((_d = (_c = taskDef.taskDefResources.StackResources) === null || _c === void 0 ? void 0 : _c.find((x) => x.LogicalResourceId === 'TaskDefinition')) === null || _d === void 0 ? void 0 : _d.PhysicalResourceId) || '';
|
||||
const SubnetOne = ((_f = (_e = taskDef.baseResources.StackResources) === null || _e === void 0 ? void 0 : _e.find((x) => x.LogicalResourceId === 'PublicSubnetOne')) === null || _f === void 0 ? void 0 : _f.PhysicalResourceId) || '';
|
||||
const SubnetTwo = ((_h = (_g = taskDef.baseResources.StackResources) === null || _g === void 0 ? void 0 : _g.find((x) => x.LogicalResourceId === 'PublicSubnetTwo')) === null || _h === void 0 ? void 0 : _h.PhysicalResourceId) || '';
|
||||
const ContainerSecurityGroup = ((_k = (_j = taskDef.baseResources.StackResources) === null || _j === void 0 ? void 0 : _j.find((x) => x.LogicalResourceId === 'ContainerSecurityGroup')) === null || _k === void 0 ? void 0 : _k.PhysicalResourceId) || '';
|
||||
const streamName = ((_m = (_l = taskDef.taskDefResources.StackResources) === null || _l === void 0 ? void 0 : _l.find((x) => x.LogicalResourceId === 'KinesisStream')) === null || _m === void 0 ? void 0 : _m.PhysicalResourceId) || '';
|
||||
const task = yield ECS.runTask({
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
taskDefinition,
|
||||
platformVersion: '1.4.0',
|
||||
overrides: {
|
||||
|
|
@ -552,24 +552,24 @@ class AWS {
|
|||
core.info('Build job is starting');
|
||||
const taskArn = ((_o = task.tasks) === null || _o === void 0 ? void 0 : _o[0].taskArn) || '';
|
||||
try {
|
||||
yield ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster: clusterName }).promise();
|
||||
yield ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise();
|
||||
}
|
||||
catch (error) {
|
||||
yield new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
const describeTasks = yield ECS.describeTasks({
|
||||
tasks: [taskArn],
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
}).promise();
|
||||
core.info(`Build 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(`Build job is running`);
|
||||
yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, streamName);
|
||||
yield ECS.waitFor('tasksStopped', { cluster: clusterName, tasks: [taskArn] }).promise();
|
||||
yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
||||
yield ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
|
||||
const exitCode = (_s = (_r = (yield ECS.describeTasks({
|
||||
tasks: [taskArn],
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
}).promise()).tasks) === null || _r === void 0 ? void 0 : _r[0].containers) === null || _s === void 0 ? void 0 : _s[0].exitCode;
|
||||
if (exitCode !== 0) {
|
||||
core.error(`job failed with exit code ${exitCode}`);
|
||||
|
|
@ -606,7 +606,7 @@ class AWS {
|
|||
yield CF.waitFor('stackCreateComplete', { StackName: taskDef.taskDefStackNameTTL }).promise();
|
||||
core.info(`Task status is ${yield getTaskStatus()}`);
|
||||
const logBaseUrl = `https://console.aws.amazon.com/cloudwatch/home?region=${SDK.config.region}#logsV2:log-groups/${taskDef.taskDefStackName}`;
|
||||
core.info(`You can also watch the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
core.info(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
let readingLogs = true;
|
||||
while (readingLogs) {
|
||||
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -167,7 +167,7 @@ class AWS {
|
|||
},
|
||||
],
|
||||
);
|
||||
core.info('starting part 3/4 (zip and publish latest Library to cache)');
|
||||
core.info('starting part 3/4 (zip build and latest Library for caching)');
|
||||
// Cleanup
|
||||
await this.run(
|
||||
buildUid,
|
||||
|
|
@ -179,7 +179,7 @@ class AWS {
|
|||
`
|
||||
apk update;
|
||||
apk add zip
|
||||
zip -r ./${buildUid}/Library/. ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/Library/* ./cache/lib-${buildUid}.zip
|
||||
zip -r ./${buildUid}/output.zip ./${buildUid}/repo/build
|
||||
ls
|
||||
`,
|
||||
|
|
@ -367,7 +367,7 @@ class AWS {
|
|||
|
||||
const baseResources = await CF.describeStackResources({ StackName: stackName }).promise();
|
||||
|
||||
core.info('Build cluster created successfully (skipping waiting for cleanup cluster to start)');
|
||||
core.info('Build cluster created successfully (skipping wait for cleanup cluster to create)');
|
||||
|
||||
return {
|
||||
taskDefStackName,
|
||||
|
|
@ -380,8 +380,9 @@ class AWS {
|
|||
}
|
||||
|
||||
static async runTask(taskDef, ECS, CF, environment, buildUid) {
|
||||
const clusterName =
|
||||
taskDef.baseResources.StackResources?.find((x) => x.LogicalResourceId === 'ECSCluster')?.PhysicalResourceId || '';
|
||||
const cluster =
|
||||
taskDef.baseResources.StackResources?.find((x) => x.LogicalResourceId === 'ECSCluster')
|
||||
?.PhysicalResourceId || '';
|
||||
const taskDefinition =
|
||||
taskDef.taskDefResources.StackResources?.find((x) => x.LogicalResourceId === 'TaskDefinition')
|
||||
?.PhysicalResourceId || '';
|
||||
|
|
@ -399,7 +400,7 @@ class AWS {
|
|||
?.PhysicalResourceId || '';
|
||||
|
||||
const task = await ECS.runTask({
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
taskDefinition,
|
||||
platformVersion: '1.4.0',
|
||||
overrides: {
|
||||
|
|
@ -424,24 +425,24 @@ class AWS {
|
|||
const taskArn = task.tasks?.[0].taskArn || '';
|
||||
|
||||
try {
|
||||
await ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster: clusterName }).promise();
|
||||
await ECS.waitFor('tasksRunning', { tasks: [taskArn], cluster }).promise();
|
||||
} catch (error) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||
const describeTasks = await ECS.describeTasks({
|
||||
tasks: [taskArn],
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
}).promise();
|
||||
core.info(`Build job has ended ${describeTasks.tasks?.[0].containers?.[0].lastStatus}`);
|
||||
core.setFailed(error);
|
||||
core.error(error);
|
||||
}
|
||||
core.info(`Build job is running`);
|
||||
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, streamName);
|
||||
await ECS.waitFor('tasksStopped', { cluster: clusterName, tasks: [taskArn] }).promise();
|
||||
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
||||
await ECS.waitFor('tasksStopped', { cluster, tasks: [taskArn] }).promise();
|
||||
const exitCode = (
|
||||
await ECS.describeTasks({
|
||||
tasks: [taskArn],
|
||||
cluster: clusterName,
|
||||
cluster,
|
||||
}).promise()
|
||||
).tasks?.[0].containers?.[0].exitCode;
|
||||
if (exitCode !== 0) {
|
||||
|
|
@ -485,7 +486,7 @@ class AWS {
|
|||
core.info(`Task status is ${await getTaskStatus()}`);
|
||||
|
||||
const logBaseUrl = `https://console.aws.amazon.com/cloudwatch/home?region=${SDK.config.region}#logsV2:log-groups/${taskDef.taskDefStackName}`;
|
||||
core.info(`You can also watch the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
core.info(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||
|
||||
let readingLogs = true;
|
||||
while (readingLogs) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue