Cleanup
parent
c5d3bc59ff
commit
d25a814372
|
|
@ -414,6 +414,7 @@ class CLI {
|
||||||
core.info(`\r\n`);
|
core.info(`\r\n`);
|
||||||
core.info(`INPUT:`);
|
core.info(`INPUT:`);
|
||||||
for (const element of properties) {
|
for (const element of properties) {
|
||||||
|
// TODO pull description from action.yml
|
||||||
program.option(`--${element} <${element}>`, 'default description');
|
program.option(`--${element} <${element}>`, 'default description');
|
||||||
if (__1.Input[element] !== undefined && __1.Input[element] !== '') {
|
if (__1.Input[element] !== undefined && __1.Input[element] !== '') {
|
||||||
core.info(`${element} ${__1.Input[element]}`);
|
core.info(`${element} ${__1.Input[element]}`);
|
||||||
|
|
@ -826,219 +827,6 @@ class AWSBaseStack {
|
||||||
exports.AWSBaseStack = AWSBaseStack;
|
exports.AWSBaseStack = AWSBaseStack;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 29102:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
const AWS = __importStar(__webpack_require__(71786));
|
|
||||||
const core = __importStar(__webpack_require__(42186));
|
|
||||||
const zlib = __importStar(__webpack_require__(78761));
|
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
|
||||||
const __1 = __webpack_require__(41359);
|
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
|
||||||
const cloud_runner_statics_1 = __webpack_require__(90828);
|
|
||||||
class AWSBuildRunner {
|
|
||||||
static runTask(taskDef, ECS, CF, environment, buildGuid, commands) {
|
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const cluster = ((_b = (_a = taskDef.baseResources) === 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) === 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) === 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) === 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) === 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) === 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,
|
|
||||||
taskDefinition,
|
|
||||||
platformVersion: '1.4.0',
|
|
||||||
overrides: {
|
|
||||||
containerOverrides: [
|
|
||||||
{
|
|
||||||
name: taskDef.taskDefStackName,
|
|
||||||
environment: [...environment, { name: 'BUILDID', value: buildGuid }],
|
|
||||||
command: ['-c', ...commands],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
launchType: 'FARGATE',
|
|
||||||
networkConfiguration: {
|
|
||||||
awsvpcConfiguration: {
|
|
||||||
subnets: [SubnetOne, SubnetTwo],
|
|
||||||
assignPublicIp: 'ENABLED',
|
|
||||||
securityGroups: [ContainerSecurityGroup],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}).promise();
|
|
||||||
cloud_runner_logger_1.default.log('Cloud runner 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 }).promise();
|
|
||||||
}
|
|
||||||
catch (error_) {
|
|
||||||
const error = error_;
|
|
||||||
yield new Promise((resolve) => setTimeout(resolve, 3000));
|
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job has ended ${(_p = (yield AWSBuildRunner.describeTasks(ECS, cluster, taskArn)).containers) === null || _p === void 0 ? void 0 : _p[0].lastStatus}`);
|
|
||||||
core.setFailed(error);
|
|
||||||
core.error(error);
|
|
||||||
}
|
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job is running`);
|
|
||||||
yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
|
||||||
const exitCode = (_q = (yield AWSBuildRunner.describeTasks(ECS, cluster, taskArn)).containers) === null || _q === void 0 ? void 0 : _q[0].exitCode;
|
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job exit code ${exitCode}`);
|
|
||||||
if (exitCode !== 0 && exitCode !== undefined) {
|
|
||||||
core.error(`job failed with exit code ${exitCode} ${JSON.stringify(yield ECS.describeTasks({ tasks: [taskArn], cluster }).promise(), undefined, 4)}`);
|
|
||||||
throw new Error(`job failed with exit code ${exitCode}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job has finished successfully`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static describeTasks(ECS, clusterName, taskArn) {
|
|
||||||
var _a, _b;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const tasks = yield ECS.describeTasks({
|
|
||||||
cluster: clusterName,
|
|
||||||
tasks: [taskArn],
|
|
||||||
}).promise();
|
|
||||||
if ((_a = tasks.tasks) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
||||||
return (_b = tasks.tasks) === null || _b === void 0 ? void 0 : _b[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('No task found');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName) {
|
|
||||||
var _a;
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const kinesis = new AWS.Kinesis();
|
|
||||||
const stream = yield AWSBuildRunner.getLogStream(kinesis, kinesisStreamName);
|
|
||||||
let iterator = yield AWSBuildRunner.getLogIterator(kinesis, stream);
|
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job status is ${(_a = (yield AWSBuildRunner.describeTasks(ECS, clusterName, taskArn))) === null || _a === void 0 ? void 0 : _a.lastStatus}`);
|
|
||||||
const logBaseUrl = `https://${__1.Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
|
||||||
cloud_runner_logger_1.default.log(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
|
||||||
let readingLogs = true;
|
|
||||||
let timestamp = 0;
|
|
||||||
while (readingLogs) {
|
|
||||||
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
|
||||||
const taskData = yield AWSBuildRunner.describeTasks(ECS, clusterName, taskArn);
|
|
||||||
({ timestamp, readingLogs } = AWSBuildRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
|
||||||
({ iterator, readingLogs } = yield AWSBuildRunner.handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const records = yield kinesis
|
|
||||||
.getRecords({
|
|
||||||
ShardIterator: iterator,
|
|
||||||
})
|
|
||||||
.promise();
|
|
||||||
iterator = records.NextShardIterator || '';
|
|
||||||
readingLogs = AWSBuildRunner.logRecords(records, iterator, taskDef, readingLogs);
|
|
||||||
return { iterator, readingLogs };
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static checkStreamingShouldContinue(taskData, timestamp, readingLogs) {
|
|
||||||
if ((taskData === null || taskData === void 0 ? void 0 : taskData.lastStatus) !== 'RUNNING') {
|
|
||||||
if (timestamp === 0) {
|
|
||||||
cloud_runner_logger_1.default.log('## Cloud runner job stopped, streaming end of logs');
|
|
||||||
timestamp = Date.now();
|
|
||||||
}
|
|
||||||
if (timestamp !== 0 && Date.now() - timestamp > 30000) {
|
|
||||||
cloud_runner_logger_1.default.log('## Cloud runner status is not RUNNING for 30 seconds, last query for logs');
|
|
||||||
readingLogs = false;
|
|
||||||
}
|
|
||||||
cloud_runner_logger_1.default.log(`## Status of job: ${taskData.lastStatus}`);
|
|
||||||
}
|
|
||||||
return { timestamp, readingLogs };
|
|
||||||
}
|
|
||||||
static logRecords(records, iterator, taskDef, readingLogs) {
|
|
||||||
if (records.Records.length > 0 && iterator) {
|
|
||||||
for (let index = 0; index < records.Records.length; index++) {
|
|
||||||
const json = JSON.parse(zlib.gunzipSync(Buffer.from(records.Records[index].Data, 'base64')).toString('utf8'));
|
|
||||||
if (json.messageType === 'DATA_MESSAGE') {
|
|
||||||
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
|
||||||
let message = json.logEvents[logEventsIndex].message;
|
|
||||||
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
|
||||||
cloud_runner_logger_1.default.log('End of cloud runner job logs');
|
|
||||||
readingLogs = false;
|
|
||||||
}
|
|
||||||
else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
|
||||||
core.warning('LIBRARY NOT FOUND!');
|
|
||||||
}
|
|
||||||
message = `[${cloud_runner_statics_1.CloudRunnerStatics.logPrefix}] ${message}`;
|
|
||||||
if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) {
|
|
||||||
fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
|
|
||||||
}
|
|
||||||
cloud_runner_logger_1.default.log(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return readingLogs;
|
|
||||||
}
|
|
||||||
static getLogStream(kinesis, kinesisStreamName) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return yield kinesis
|
|
||||||
.describeStream({
|
|
||||||
StreamName: kinesisStreamName,
|
|
||||||
})
|
|
||||||
.promise();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
static getLogIterator(kinesis, stream) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return ((yield kinesis
|
|
||||||
.getShardIterator({
|
|
||||||
ShardIteratorType: 'TRIM_HORIZON',
|
|
||||||
StreamName: stream.StreamDescription.StreamName,
|
|
||||||
ShardId: stream.StreamDescription.Shards[0].ShardId,
|
|
||||||
})
|
|
||||||
.promise()).ShardIterator || '');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.default = AWSBuildRunner;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 83683:
|
/***/ 83683:
|
||||||
|
|
@ -1290,6 +1078,219 @@ class AWSJobStack {
|
||||||
exports.AWSJobStack = AWSJobStack;
|
exports.AWSJobStack = AWSJobStack;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 74668:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const AWS = __importStar(__webpack_require__(71786));
|
||||||
|
const core = __importStar(__webpack_require__(42186));
|
||||||
|
const zlib = __importStar(__webpack_require__(78761));
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
|
const __1 = __webpack_require__(41359);
|
||||||
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
|
const cloud_runner_statics_1 = __webpack_require__(90828);
|
||||||
|
class AWSTaskRunner {
|
||||||
|
static runTask(taskDef, ECS, CF, environment, buildGuid, commands) {
|
||||||
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const cluster = ((_b = (_a = taskDef.baseResources) === 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) === 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) === 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) === 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) === 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) === 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,
|
||||||
|
taskDefinition,
|
||||||
|
platformVersion: '1.4.0',
|
||||||
|
overrides: {
|
||||||
|
containerOverrides: [
|
||||||
|
{
|
||||||
|
name: taskDef.taskDefStackName,
|
||||||
|
environment: [...environment, { name: 'BUILDID', value: buildGuid }],
|
||||||
|
command: ['-c', ...commands],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
launchType: 'FARGATE',
|
||||||
|
networkConfiguration: {
|
||||||
|
awsvpcConfiguration: {
|
||||||
|
subnets: [SubnetOne, SubnetTwo],
|
||||||
|
assignPublicIp: 'ENABLED',
|
||||||
|
securityGroups: [ContainerSecurityGroup],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}).promise();
|
||||||
|
cloud_runner_logger_1.default.log('Cloud runner 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 }).promise();
|
||||||
|
}
|
||||||
|
catch (error_) {
|
||||||
|
const error = error_;
|
||||||
|
yield new Promise((resolve) => setTimeout(resolve, 3000));
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud runner job has ended ${(_p = (yield AWSTaskRunner.describeTasks(ECS, cluster, taskArn)).containers) === null || _p === void 0 ? void 0 : _p[0].lastStatus}`);
|
||||||
|
core.setFailed(error);
|
||||||
|
core.error(error);
|
||||||
|
}
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud runner job is running`);
|
||||||
|
yield this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
||||||
|
const exitCode = (_q = (yield AWSTaskRunner.describeTasks(ECS, cluster, taskArn)).containers) === null || _q === void 0 ? void 0 : _q[0].exitCode;
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud runner job exit code ${exitCode}`);
|
||||||
|
if (exitCode !== 0 && exitCode !== undefined) {
|
||||||
|
core.error(`job failed with exit code ${exitCode} ${JSON.stringify(yield ECS.describeTasks({ tasks: [taskArn], cluster }).promise(), undefined, 4)}`);
|
||||||
|
throw new Error(`job failed with exit code ${exitCode}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud runner job has finished successfully`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static describeTasks(ECS, clusterName, taskArn) {
|
||||||
|
var _a, _b;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const tasks = yield ECS.describeTasks({
|
||||||
|
cluster: clusterName,
|
||||||
|
tasks: [taskArn],
|
||||||
|
}).promise();
|
||||||
|
if ((_a = tasks.tasks) === null || _a === void 0 ? void 0 : _a[0]) {
|
||||||
|
return (_b = tasks.tasks) === null || _b === void 0 ? void 0 : _b[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('No task found');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static streamLogsUntilTaskStops(ECS, CF, taskDef, clusterName, taskArn, kinesisStreamName) {
|
||||||
|
var _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const kinesis = new AWS.Kinesis();
|
||||||
|
const stream = yield AWSTaskRunner.getLogStream(kinesis, kinesisStreamName);
|
||||||
|
let iterator = yield AWSTaskRunner.getLogIterator(kinesis, stream);
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud runner job status is ${(_a = (yield AWSTaskRunner.describeTasks(ECS, clusterName, taskArn))) === null || _a === void 0 ? void 0 : _a.lastStatus}`);
|
||||||
|
const logBaseUrl = `https://${__1.Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
||||||
|
cloud_runner_logger_1.default.log(`You can also see the logs at AWS Cloud Watch: ${logBaseUrl}`);
|
||||||
|
let readingLogs = true;
|
||||||
|
let timestamp = 0;
|
||||||
|
while (readingLogs) {
|
||||||
|
yield new Promise((resolve) => setTimeout(resolve, 1500));
|
||||||
|
const taskData = yield AWSTaskRunner.describeTasks(ECS, clusterName, taskArn);
|
||||||
|
({ timestamp, readingLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
||||||
|
({ iterator, readingLogs } = yield AWSTaskRunner.handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static handleLogStreamIteration(kinesis, iterator, readingLogs, taskDef) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const records = yield kinesis
|
||||||
|
.getRecords({
|
||||||
|
ShardIterator: iterator,
|
||||||
|
})
|
||||||
|
.promise();
|
||||||
|
iterator = records.NextShardIterator || '';
|
||||||
|
readingLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, readingLogs);
|
||||||
|
return { iterator, readingLogs };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static checkStreamingShouldContinue(taskData, timestamp, readingLogs) {
|
||||||
|
if ((taskData === null || taskData === void 0 ? void 0 : taskData.lastStatus) !== 'RUNNING') {
|
||||||
|
if (timestamp === 0) {
|
||||||
|
cloud_runner_logger_1.default.log('## Cloud runner job stopped, streaming end of logs');
|
||||||
|
timestamp = Date.now();
|
||||||
|
}
|
||||||
|
if (timestamp !== 0 && Date.now() - timestamp > 30000) {
|
||||||
|
cloud_runner_logger_1.default.log('## Cloud runner status is not RUNNING for 30 seconds, last query for logs');
|
||||||
|
readingLogs = false;
|
||||||
|
}
|
||||||
|
cloud_runner_logger_1.default.log(`## Status of job: ${taskData.lastStatus}`);
|
||||||
|
}
|
||||||
|
return { timestamp, readingLogs };
|
||||||
|
}
|
||||||
|
static logRecords(records, iterator, taskDef, readingLogs) {
|
||||||
|
if (records.Records.length > 0 && iterator) {
|
||||||
|
for (let index = 0; index < records.Records.length; index++) {
|
||||||
|
const json = JSON.parse(zlib.gunzipSync(Buffer.from(records.Records[index].Data, 'base64')).toString('utf8'));
|
||||||
|
if (json.messageType === 'DATA_MESSAGE') {
|
||||||
|
for (let logEventsIndex = 0; logEventsIndex < json.logEvents.length; logEventsIndex++) {
|
||||||
|
let message = json.logEvents[logEventsIndex].message;
|
||||||
|
if (json.logEvents[logEventsIndex].message.includes(taskDef.logid)) {
|
||||||
|
cloud_runner_logger_1.default.log('End of cloud runner job logs');
|
||||||
|
readingLogs = false;
|
||||||
|
}
|
||||||
|
else if (message.includes('Rebuilding Library because the asset database could not be found!')) {
|
||||||
|
core.warning('LIBRARY NOT FOUND!');
|
||||||
|
}
|
||||||
|
message = `[${cloud_runner_statics_1.CloudRunnerStatics.logPrefix}] ${message}`;
|
||||||
|
if (cloud_runner_state_1.CloudRunnerState.buildParams.logToFile) {
|
||||||
|
fs_1.default.appendFileSync(`${cloud_runner_state_1.CloudRunnerState.buildGuid}-outputfile.txt`, `${message}\r\n`);
|
||||||
|
}
|
||||||
|
cloud_runner_logger_1.default.log(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return readingLogs;
|
||||||
|
}
|
||||||
|
static getLogStream(kinesis, kinesisStreamName) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return yield kinesis
|
||||||
|
.describeStream({
|
||||||
|
StreamName: kinesisStreamName,
|
||||||
|
})
|
||||||
|
.promise();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static getLogIterator(kinesis, stream) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return ((yield kinesis
|
||||||
|
.getShardIterator({
|
||||||
|
ShardIteratorType: 'TRIM_HORIZON',
|
||||||
|
StreamName: stream.StreamDescription.StreamName,
|
||||||
|
ShardId: stream.StreamDescription.Shards[0].ShardId,
|
||||||
|
})
|
||||||
|
.promise()).ShardIterator || '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.default = AWSTaskRunner;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6436:
|
/***/ 6436:
|
||||||
|
|
@ -1394,7 +1395,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const SDK = __importStar(__webpack_require__(71786));
|
const SDK = __importStar(__webpack_require__(71786));
|
||||||
const aws_build_runner_1 = __importDefault(__webpack_require__(29102));
|
const aws_task_runner_1 = __importDefault(__webpack_require__(74668));
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
const aws_job_stack_1 = __webpack_require__(85819);
|
const aws_job_stack_1 = __webpack_require__(85819);
|
||||||
const aws_base_stack_1 = __webpack_require__(28730);
|
const aws_base_stack_1 = __webpack_require__(28730);
|
||||||
|
|
@ -1403,7 +1404,7 @@ class AWSBuildEnvironment {
|
||||||
constructor(buildParameters) {
|
constructor(buildParameters) {
|
||||||
this.baseStackName = buildParameters.awsBaseStackName;
|
this.baseStackName = buildParameters.awsBaseStackName;
|
||||||
}
|
}
|
||||||
cleanupSharedBuildResources(
|
cleanupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid,
|
buildGuid,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -1414,7 +1415,7 @@ class AWSBuildEnvironment {
|
||||||
defaultSecretsArray) {
|
defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () { });
|
return __awaiter(this, void 0, void 0, function* () { });
|
||||||
}
|
}
|
||||||
setupSharedBuildResources(
|
setupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid,
|
buildGuid,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -1425,7 +1426,7 @@ class AWSBuildEnvironment {
|
||||||
defaultSecretsArray) {
|
defaultSecretsArray) {
|
||||||
return __awaiter(this, void 0, void 0, function* () { });
|
return __awaiter(this, void 0, void 0, function* () { });
|
||||||
}
|
}
|
||||||
runBuildTask(buildId, image, commands, mountdir, workingdir, environment, secrets) {
|
runTask(buildId, image, commands, mountdir, workingdir, environment, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
process.env.AWS_REGION = __1.Input.region;
|
process.env.AWS_REGION = __1.Input.region;
|
||||||
const ECS = new SDK.ECS();
|
const ECS = new SDK.ECS();
|
||||||
|
|
@ -1439,7 +1440,7 @@ class AWSBuildEnvironment {
|
||||||
try {
|
try {
|
||||||
const t1 = Date.now();
|
const t1 = Date.now();
|
||||||
cloud_runner_logger_1.default.log(`Setup job time: ${Math.floor((t1 - t0) / 1000)}s`);
|
cloud_runner_logger_1.default.log(`Setup job time: ${Math.floor((t1 - t0) / 1000)}s`);
|
||||||
yield aws_build_runner_1.default.runTask(taskDef, ECS, CF, environment, buildId, commands);
|
yield aws_task_runner_1.default.runTask(taskDef, ECS, CF, environment, buildId, commands);
|
||||||
t2 = Date.now();
|
t2 = Date.now();
|
||||||
cloud_runner_logger_1.default.log(`Run job time: ${Math.floor((t2 - t1) / 1000)}s`);
|
cloud_runner_logger_1.default.log(`Run job time: ${Math.floor((t2 - t1) / 1000)}s`);
|
||||||
}
|
}
|
||||||
|
|
@ -1542,9 +1543,9 @@ class CloudRunner {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
CloudRunner.setup(buildParameters);
|
CloudRunner.setup(buildParameters);
|
||||||
try {
|
try {
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.setupSharedBuildResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.setupSharedResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
||||||
yield new workflow_composition_root_1.WorkflowCompositionRoot().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
yield new workflow_composition_root_1.WorkflowCompositionRoot().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedBuildResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
yield cloud_runner_error_1.CloudRunnerError.handleException(error);
|
yield cloud_runner_error_1.CloudRunnerError.handleException(error);
|
||||||
|
|
@ -1604,7 +1605,7 @@ class CloudRunnerError {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cloud_runner_logger_1.default.error(JSON.stringify(error, undefined, 4));
|
cloud_runner_logger_1.default.error(JSON.stringify(error, undefined, 4));
|
||||||
core.setFailed('Cloud Runner failed');
|
core.setFailed('Cloud Runner failed');
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedBuildResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedResources(cloud_runner_state_1.CloudRunnerState.buildGuid, cloud_runner_state_1.CloudRunnerState.buildParams, cloud_runner_state_1.CloudRunnerState.branchName, cloud_runner_state_1.CloudRunnerState.defaultSecrets);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1679,7 +1680,7 @@ class Kubernetes {
|
||||||
this.namespace = 'default';
|
this.namespace = 'default';
|
||||||
this.buildParameters = buildParameters;
|
this.buildParameters = buildParameters;
|
||||||
}
|
}
|
||||||
setupSharedBuildResources(buildGuid, buildParameters,
|
setupSharedResources(buildGuid, buildParameters,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
branchName,
|
branchName,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -1697,7 +1698,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
runBuildTask(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
|
runTask(buildGuid, image, commands, mountdir, workingdir, environment, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
// setup
|
// setup
|
||||||
|
|
@ -1755,7 +1756,7 @@ class Kubernetes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cleanupSharedBuildResources(
|
cleanupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid,
|
buildGuid,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -2702,24 +2703,24 @@ class BuildStep {
|
||||||
static BuildStep(image, environmentVariables, secrets) {
|
static BuildStep(image, environmentVariables, secrets) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)');
|
cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)');
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||||
`
|
`
|
||||||
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||||
chmod -R +x "/entrypoint.sh"
|
chmod -R +x "/entrypoint.sh"
|
||||||
chmod -R +x "/steps"
|
chmod -R +x "/steps"
|
||||||
/entrypoint.sh
|
/entrypoint.sh
|
||||||
apk update -q
|
apk update -q
|
||||||
apk add zip tree -q
|
apk add zip tree -q
|
||||||
cd "$libraryFolderFull/.."
|
cd "$libraryFolderFull/.."
|
||||||
zip -r "lib-$BUILDID.zip" "./Library"
|
zip -r "lib-$BUILDID.zip" "./Library"
|
||||||
mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib"
|
mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib"
|
||||||
cd "$repoPathFull"
|
cd "$repoPathFull"
|
||||||
ls -lh "$repoPathFull"
|
ls -lh "$repoPathFull"
|
||||||
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
||||||
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
||||||
`,
|
`,
|
||||||
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
||||||
});
|
});
|
||||||
|
|
@ -2766,7 +2767,7 @@ class SetupStep {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
cloud_runner_logger_1.default.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
cloud_runner_logger_1.default.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||||
`
|
`
|
||||||
apk update -q
|
apk update -q
|
||||||
apk add unzip zip git-lfs jq tree nodejs -q
|
apk add unzip zip git-lfs jq tree nodejs -q
|
||||||
|
|
@ -2894,7 +2895,7 @@ class CustomWorkflow {
|
||||||
};
|
};
|
||||||
return secret;
|
return secret;
|
||||||
});
|
});
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, step['image'], step['commands'], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), [...cloud_runner_state_1.CloudRunnerState.defaultSecrets, ...stepSecrets]);
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, step['image'], step['commands'], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, cloud_runner_state_1.CloudRunnerState.readBuildEnvironmentVariables(), [...cloud_runner_state_1.CloudRunnerState.defaultSecrets, ...stepSecrets]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
@ -2950,7 +2951,7 @@ class EphemeralGitHubRunnerWorkflow {
|
||||||
try {
|
try {
|
||||||
cloud_runner_logger_1.default.log(`Cloud Runner is running in ephemeral GitHub runner mode`);
|
cloud_runner_logger_1.default.log(`Cloud Runner is running in ephemeral GitHub runner mode`);
|
||||||
const installAndStartRunner = ' cd .. & cd .. && ls && mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz';
|
const installAndStartRunner = ' cd .. & cd .. && ls && mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz';
|
||||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [installAndStartRunner], `/runner`, `/runner`, environmentVariables, secrets);
|
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [installAndStartRunner], `/runner`, `/runner`, environmentVariables, secrets);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -9,7 +9,7 @@ import fs from 'fs';
|
||||||
import { CloudRunnerState } from '../state/cloud-runner-state';
|
import { CloudRunnerState } from '../state/cloud-runner-state';
|
||||||
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
||||||
|
|
||||||
class AWSBuildRunner {
|
class AWSTaskRunner {
|
||||||
static async runTask(
|
static async runTask(
|
||||||
taskDef: CloudRunnerTaskDef,
|
taskDef: CloudRunnerTaskDef,
|
||||||
ECS: AWS.ECS,
|
ECS: AWS.ECS,
|
||||||
|
|
@ -63,7 +63,7 @@ class AWSBuildRunner {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 3000));
|
await new Promise((resolve) => setTimeout(resolve, 3000));
|
||||||
CloudRunnerLogger.log(
|
CloudRunnerLogger.log(
|
||||||
`Cloud runner job has ended ${
|
`Cloud runner job has ended ${
|
||||||
(await AWSBuildRunner.describeTasks(ECS, cluster, taskArn)).containers?.[0].lastStatus
|
(await AWSTaskRunner.describeTasks(ECS, cluster, taskArn)).containers?.[0].lastStatus
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ class AWSBuildRunner {
|
||||||
}
|
}
|
||||||
CloudRunnerLogger.log(`Cloud runner job is running`);
|
CloudRunnerLogger.log(`Cloud runner job is running`);
|
||||||
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
await this.streamLogsUntilTaskStops(ECS, CF, taskDef, cluster, taskArn, streamName);
|
||||||
const exitCode = (await AWSBuildRunner.describeTasks(ECS, cluster, taskArn)).containers?.[0].exitCode;
|
const exitCode = (await AWSTaskRunner.describeTasks(ECS, cluster, taskArn)).containers?.[0].exitCode;
|
||||||
CloudRunnerLogger.log(`Cloud runner job exit code ${exitCode}`);
|
CloudRunnerLogger.log(`Cloud runner job exit code ${exitCode}`);
|
||||||
if (exitCode !== 0 && exitCode !== undefined) {
|
if (exitCode !== 0 && exitCode !== undefined) {
|
||||||
core.error(
|
core.error(
|
||||||
|
|
@ -109,11 +109,11 @@ class AWSBuildRunner {
|
||||||
kinesisStreamName: string,
|
kinesisStreamName: string,
|
||||||
) {
|
) {
|
||||||
const kinesis = new AWS.Kinesis();
|
const kinesis = new AWS.Kinesis();
|
||||||
const stream = await AWSBuildRunner.getLogStream(kinesis, kinesisStreamName);
|
const stream = await AWSTaskRunner.getLogStream(kinesis, kinesisStreamName);
|
||||||
let iterator = await AWSBuildRunner.getLogIterator(kinesis, stream);
|
let iterator = await AWSTaskRunner.getLogIterator(kinesis, stream);
|
||||||
|
|
||||||
CloudRunnerLogger.log(
|
CloudRunnerLogger.log(
|
||||||
`Cloud runner job status is ${(await AWSBuildRunner.describeTasks(ECS, clusterName, taskArn))?.lastStatus}`,
|
`Cloud runner job status is ${(await AWSTaskRunner.describeTasks(ECS, clusterName, taskArn))?.lastStatus}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const logBaseUrl = `https://${Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
const logBaseUrl = `https://${Input.region}.console.aws.amazon.com/cloudwatch/home?region=${AWS.config.region}#logsV2:log-groups/log-group/${taskDef.taskDefStackName}`;
|
||||||
|
|
@ -122,9 +122,9 @@ class AWSBuildRunner {
|
||||||
let timestamp: number = 0;
|
let timestamp: number = 0;
|
||||||
while (readingLogs) {
|
while (readingLogs) {
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||||
const taskData = await AWSBuildRunner.describeTasks(ECS, clusterName, taskArn);
|
const taskData = await AWSTaskRunner.describeTasks(ECS, clusterName, taskArn);
|
||||||
({ timestamp, readingLogs } = AWSBuildRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
({ timestamp, readingLogs } = AWSTaskRunner.checkStreamingShouldContinue(taskData, timestamp, readingLogs));
|
||||||
({ iterator, readingLogs } = await AWSBuildRunner.handleLogStreamIteration(
|
({ iterator, readingLogs } = await AWSTaskRunner.handleLogStreamIteration(
|
||||||
kinesis,
|
kinesis,
|
||||||
iterator,
|
iterator,
|
||||||
readingLogs,
|
readingLogs,
|
||||||
|
|
@ -145,7 +145,7 @@ class AWSBuildRunner {
|
||||||
})
|
})
|
||||||
.promise();
|
.promise();
|
||||||
iterator = records.NextShardIterator || '';
|
iterator = records.NextShardIterator || '';
|
||||||
readingLogs = AWSBuildRunner.logRecords(records, iterator, taskDef, readingLogs);
|
readingLogs = AWSTaskRunner.logRecords(records, iterator, taskDef, readingLogs);
|
||||||
return { iterator, readingLogs };
|
return { iterator, readingLogs };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,4 +213,4 @@ class AWSBuildRunner {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default AWSBuildRunner;
|
export default AWSTaskRunner;
|
||||||
|
|
@ -2,7 +2,7 @@ import * as SDK from 'aws-sdk';
|
||||||
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
||||||
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
||||||
import CloudRunnerTaskDef from '../services/cloud-runner-task-def';
|
import CloudRunnerTaskDef from '../services/cloud-runner-task-def';
|
||||||
import AWSBuildRunner from './aws-build-runner';
|
import AWSTaskRunner from './aws-task-runner';
|
||||||
import { CloudRunnerProviderInterface } from '../services/cloud-runner-provider-interface';
|
import { CloudRunnerProviderInterface } from '../services/cloud-runner-provider-interface';
|
||||||
import BuildParameters from '../../build-parameters';
|
import BuildParameters from '../../build-parameters';
|
||||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
|
@ -16,7 +16,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
||||||
constructor(buildParameters: BuildParameters) {
|
constructor(buildParameters: BuildParameters) {
|
||||||
this.baseStackName = buildParameters.awsBaseStackName;
|
this.baseStackName = buildParameters.awsBaseStackName;
|
||||||
}
|
}
|
||||||
async cleanupSharedBuildResources(
|
async cleanupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -26,7 +26,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {}
|
) {}
|
||||||
async setupSharedBuildResources(
|
async setupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -37,7 +37,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async runBuildTask(
|
async runTask(
|
||||||
buildId: string,
|
buildId: string,
|
||||||
image: string,
|
image: string,
|
||||||
commands: string[],
|
commands: string[],
|
||||||
|
|
@ -69,7 +69,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
||||||
try {
|
try {
|
||||||
const t1 = Date.now();
|
const t1 = Date.now();
|
||||||
CloudRunnerLogger.log(`Setup job time: ${Math.floor((t1 - t0) / 1000)}s`);
|
CloudRunnerLogger.log(`Setup job time: ${Math.floor((t1 - t0) / 1000)}s`);
|
||||||
await AWSBuildRunner.runTask(taskDef, ECS, CF, environment, buildId, commands);
|
await AWSTaskRunner.runTask(taskDef, ECS, CF, environment, buildId, commands);
|
||||||
t2 = Date.now();
|
t2 = Date.now();
|
||||||
CloudRunnerLogger.log(`Run job time: ${Math.floor((t2 - t1) / 1000)}s`);
|
CloudRunnerLogger.log(`Run job time: ${Math.floor((t2 - t1) / 1000)}s`);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class CloudRunner {
|
||||||
static async run(buildParameters: BuildParameters, baseImage: string) {
|
static async run(buildParameters: BuildParameters, baseImage: string) {
|
||||||
CloudRunner.setup(buildParameters);
|
CloudRunner.setup(buildParameters);
|
||||||
try {
|
try {
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.setupSharedBuildResources(
|
await CloudRunnerState.CloudRunnerProviderPlatform.setupSharedResources(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
CloudRunnerState.buildParams,
|
CloudRunnerState.buildParams,
|
||||||
CloudRunnerState.branchName,
|
CloudRunnerState.branchName,
|
||||||
|
|
@ -44,7 +44,7 @@ class CloudRunner {
|
||||||
CloudRunnerState.defaultSecrets,
|
CloudRunnerState.defaultSecrets,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedBuildResources(
|
await CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedResources(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
CloudRunnerState.buildParams,
|
CloudRunnerState.buildParams,
|
||||||
CloudRunnerState.branchName,
|
CloudRunnerState.branchName,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export class CloudRunnerError {
|
||||||
public static async handleException(error: unknown) {
|
public static async handleException(error: unknown) {
|
||||||
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
|
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
|
||||||
core.setFailed('Cloud Runner failed');
|
core.setFailed('Cloud Runner failed');
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedBuildResources(
|
await CloudRunnerState.CloudRunnerProviderPlatform.cleanupSharedResources(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
CloudRunnerState.buildParams,
|
CloudRunnerState.buildParams,
|
||||||
CloudRunnerState.branchName,
|
CloudRunnerState.branchName,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
this.namespace = 'default';
|
this.namespace = 'default';
|
||||||
this.buildParameters = buildParameters;
|
this.buildParameters = buildParameters;
|
||||||
}
|
}
|
||||||
public async setupSharedBuildResources(
|
public async setupSharedResources(
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
buildParameters: BuildParameters,
|
buildParameters: BuildParameters,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -65,7 +65,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async runBuildTask(
|
async runTask(
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
image: string,
|
image: string,
|
||||||
commands: string[],
|
commands: string[],
|
||||||
|
|
@ -152,7 +152,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async cleanupSharedBuildResources(
|
async cleanupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import CloudRunnerEnvironmentVariable from './cloud-runner-environment-variable'
|
||||||
import CloudRunnerSecret from './cloud-runner-secret';
|
import CloudRunnerSecret from './cloud-runner-secret';
|
||||||
|
|
||||||
export interface CloudRunnerProviderInterface {
|
export interface CloudRunnerProviderInterface {
|
||||||
cleanupSharedBuildResources(
|
cleanupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -13,7 +13,7 @@ export interface CloudRunnerProviderInterface {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
);
|
);
|
||||||
setupSharedBuildResources(
|
setupSharedResources(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
@ -23,7 +23,7 @@ export interface CloudRunnerProviderInterface {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
);
|
);
|
||||||
runBuildTask(
|
runTask(
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
buildGuid: string,
|
buildGuid: string,
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export class BuildStep implements StepInterface {
|
||||||
secrets: CloudRunnerSecret[],
|
secrets: CloudRunnerSecret[],
|
||||||
) {
|
) {
|
||||||
CloudRunnerLogger.logLine('Starting part 2/2 (build unity project)');
|
CloudRunnerLogger.logLine('Starting part 2/2 (build unity project)');
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
image,
|
image,
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export class SetupStep implements StepInterface {
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
CloudRunnerLogger.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
CloudRunnerLogger.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
image,
|
image,
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export class CustomWorkflow {
|
||||||
};
|
};
|
||||||
return secret;
|
return secret;
|
||||||
});
|
});
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
step['image'],
|
step['image'],
|
||||||
step['commands'],
|
step['commands'],
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export class EphemeralGitHubRunnerWorkflow implements WorkflowInterface {
|
||||||
CloudRunnerLogger.log(`Cloud Runner is running in ephemeral GitHub runner mode`);
|
CloudRunnerLogger.log(`Cloud Runner is running in ephemeral GitHub runner mode`);
|
||||||
const installAndStartRunner =
|
const installAndStartRunner =
|
||||||
' cd .. & cd .. && ls && mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz';
|
' cd .. & cd .. && ls && mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz';
|
||||||
await CloudRunnerState.CloudRunnerProviderPlatform.runBuildTask(
|
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||||
CloudRunnerState.buildGuid,
|
CloudRunnerState.buildGuid,
|
||||||
image,
|
image,
|
||||||
[installAndStartRunner],
|
[installAndStartRunner],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue