Support for inspect builds

pull/419/head
Frostebite 2022-08-10 04:36:22 +01:00
parent 824f017b0b
commit 2b4e2c44e1
11 changed files with 91 additions and 22 deletions

55
dist/index.js vendored
View File

@ -519,6 +519,7 @@ class Cli {
program.option('--cachePushFrom <cachePushFrom>', 'cache push from source folder');
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
program.option('--artifactName <artifactName>', 'caching artifact name');
program.option('--select <select>', 'select a particular resource');
program.parse(process.argv);
Cli.options = program.opts();
return Cli.isCliMode;
@ -535,7 +536,7 @@ class Cli {
const results = cli_functions_repository_1.CliFunctionsRepository.GetCliFunctions(Cli.options.mode);
cloud_runner_logger_1.default.log(`Entrypoint: ${results.key}`);
Cli.options.versioning = 'None';
return yield results.target[results.propertyKey]();
return yield results.target[results.propertyKey](Cli.options);
});
}
static logInput() {
@ -2180,6 +2181,12 @@ class AwsCliCommands {
return task_service_1.TaskService.watch();
});
}
static describe(options) {
return __awaiter(this, void 0, void 0, function* () {
// return CloudRunner.Provider.inspect();
return yield task_service_1.TaskService.awsDescribeJob(options.select);
});
}
}
__decorate([
cli_functions_repository_1.CliFunction(`aws-list-all`, `List all resources`)
@ -2211,6 +2218,9 @@ __decorate([
__decorate([
cli_functions_repository_1.CliFunction(`watch`, `List tasks`)
], AwsCliCommands, "watchTasks", null);
__decorate([
cli_functions_repository_1.CliFunction(`describe-resource`, `desribe tasks`)
], AwsCliCommands, "describe", null);
exports.AwsCliCommands = AwsCliCommands;
@ -2261,12 +2271,15 @@ const aws_base_stack_1 = __nccwpck_require__(26112);
const __1 = __nccwpck_require__(41359);
const aws_cli_commands_1 = __nccwpck_require__(34340);
const tertiary_resources_service_1 = __nccwpck_require__(61627);
const task_service_1 = __nccwpck_require__(67205);
class AWSBuildEnvironment {
constructor(buildParameters) {
this.baseStackName = buildParameters.awsBaseStackName;
}
inspect() {
throw new Error('Method not implemented.');
return __awaiter(this, void 0, void 0, function* () {
return yield task_service_1.TaskService.awsDescribeJob('');
});
}
watch() {
throw new Error('Method not implemented.');
@ -2575,6 +2588,29 @@ class TaskService {
}
});
}
static awsDescribeJob(job) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
process.env.AWS_REGION = input_1.default.region;
const CF = new aws_sdk_1.default.CloudFormation();
const stack = ((_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.find((_x) => _x.StackName === job)) || undefined;
const stackInfo = (yield CF.describeStackResources({ StackName: job }).promise()) || undefined;
const stackInfo2 = (yield CF.describeStacks({ StackName: job }).promise()) || undefined;
if (stack === undefined) {
throw new Error('stack not defined');
}
const ageDate = new Date(Date.now() - stack.CreationTime.getTime());
const message = `
Task Stack ${stack.StackName}
Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}
${JSON.stringify(stack, undefined, 4)}
${JSON.stringify(stackInfo, undefined, 4)}
${JSON.stringify(stackInfo2, undefined, 4)}
`;
cloud_runner_logger_1.default.log(message);
return message;
});
}
}
exports.TaskService = TaskService;
@ -3757,10 +3793,10 @@ class Caching {
}
}
catch (error) {
process.chdir(`${startPath}`);
process.chdir(startPath);
throw error;
}
process.chdir(`${startPath}`);
process.chdir(startPath);
});
}
static handleCachePurging() {
@ -3870,7 +3906,7 @@ class RemoteClient {
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_1.default.buildParameters.branch}`);
yield cloud_runner_system_1.CloudRunnerSystem.Run(`git checkout ${cloud_runner_1.default.buildParameters.branch}`);
console_1.assert(fs_1.default.existsSync(path_1.default.join(`.git`, `lfs`)), 'LFS folder should not exist before caching');
remote_client_logger_1.RemoteClientLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
remote_client_logger_1.RemoteClientLogger.log(`Checked out ${cloud_runner_1.default.buildParameters.branch}`);
}
catch (error) {
throw error;
@ -4546,6 +4582,7 @@ class TaskParameterSerializer {
}
static get serializeBuildParamsAndInput() {
let array = new Array();
__1.CloudRunner.buildParameters.projectPath = '.';
array = TaskParameterSerializer.readBuildParameters(array);
array = TaskParameterSerializer.readInput(array);
const configurableHooks = cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getHooks(__1.CloudRunner.buildParameters.customJobHooks);
@ -4554,7 +4591,8 @@ class TaskParameterSerializer {
// eslint-disable-next-line unicorn/no-array-reduce
array.push(secrets.reduce((x, y) => [...x, ...y]));
}
array = array.filter((x) => x.value !== undefined && x.name !== '0' && x.value !== '' && x.name !== 'prototype' && x.name !== 'length');
const blocked = new Set(['0', 'length', 'prototype', '', 'projectPath']);
array = array.filter((x) => !blocked.has(x.name));
array = array.map((x) => {
x.name = __1.Input.ToEnvVarFormat(x.name);
x.value = `${x.value}`;
@ -4590,6 +4628,7 @@ class TaskParameterSerializer {
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
__1.CloudRunner.buildParameters.projectPath = '.';
array.push(...image_environment_factory_1.default.getEnvironmentVariables(__1.CloudRunner.buildParameters)
.filter((x) => array.every((y) => y.ParameterKey !== x.name))
.map((x) => {
@ -5170,7 +5209,7 @@ class ImageTag {
// Can only build windows-il2cpp on a windows based system
if (process.platform === 'win32') {
// Unity versions before 2019.3 do not support il2cpp
if (major >= 2020 || (major === 2019 && minor >= 3)) {
if ((process.env.il2cppEnabled && major >= 2020) || (major === 2019 && minor >= 3)) {
return windowsIl2cpp;
}
else {
@ -5181,7 +5220,7 @@ class ImageTag {
return windows;
case platform_1.default.types.StandaloneLinux64: {
// Unity versions before 2019.3 do not support il2cpp
if (major >= 2020 || (major === 2019 && minor >= 3)) {
if ((process.env.il2cppEnabled && major >= 2020) || (major === 2019 && minor >= 3)) {
return linuxIl2cpp;
}
return linux;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,7 @@ export class Cli {
program.option('--cachePushFrom <cachePushFrom>', 'cache push from source folder');
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
program.option('--artifactName <artifactName>', 'caching artifact name');
program.option('--select <select>', 'select a particular resource');
program.parse(process.argv);
Cli.options = program.opts();
@ -69,7 +70,7 @@ export class Cli {
CloudRunnerLogger.log(`Entrypoint: ${results.key}`);
Cli.options.versioning = 'None';
return await results.target[results.propertyKey]();
return await results.target[results.propertyKey](Cli.options);
}
@CliFunction(`print-input`, `prints all input`)

View File

@ -19,7 +19,7 @@ class CloudRunner {
static buildParameters: BuildParameters;
public static defaultSecrets: CloudRunnerSecret[];
public static cloudRunnerEnvironmentVariables: CloudRunnerEnvironmentVariable[];
private static setup(buildParameters: BuildParameters) {
public static setup(buildParameters: BuildParameters) {
CloudRunnerLogger.setup();
CloudRunner.buildParameters = buildParameters;
CloudRunner.setupBuildPlatform();

View File

@ -2,7 +2,6 @@ import { CliFunction } from '../../../../cli/cli-functions-repository';
import { TaskService } from '../services/task-service';
import { GarbageCollectionService } from '../services/garbage-collection-service';
import { TertiaryResourcesService } from '../services/tertiary-resources-service';
export class AwsCliCommands {
@CliFunction(`aws-list-all`, `List all resources`)
public static async awsListAll() {
@ -54,4 +53,10 @@ export class AwsCliCommands {
static async watchTasks() {
return TaskService.watch();
}
@CliFunction(`describe-resource`, `desribe tasks`)
static async describe(options) {
// return CloudRunner.Provider.inspect();
return await TaskService.awsDescribeJob(options.select);
}
}

View File

@ -11,6 +11,7 @@ import { AWSBaseStack } from './aws-base-stack';
import { Input } from '../../..';
import { AwsCliCommands } from './commands/aws-cli-commands';
import { TertiaryResourcesService } from './services/tertiary-resources-service';
import { TaskService } from './services/task-service';
class AWSBuildEnvironment implements ProviderInterface {
private baseStackName: string;
@ -18,8 +19,8 @@ class AWSBuildEnvironment implements ProviderInterface {
constructor(buildParameters: BuildParameters) {
this.baseStackName = buildParameters.awsBaseStackName;
}
inspect(): Promise<string> {
throw new Error('Method not implemented.');
async inspect(): Promise<string> {
return await TaskService.awsDescribeJob('');
}
watch(): Promise<string> {
throw new Error('Method not implemented.');

View File

@ -102,4 +102,25 @@ export class TaskService {
if (perResultCallback) await perResultCallback(element);
}
}
public static async awsDescribeJob(job: string) {
process.env.AWS_REGION = Input.region;
const CF = new AWS.CloudFormation();
const stack = (await CF.listStacks().promise()).StackSummaries?.find((_x) => _x.StackName === job) || undefined;
const stackInfo = (await CF.describeStackResources({ StackName: job }).promise()) || undefined;
const stackInfo2 = (await CF.describeStacks({ StackName: job }).promise()) || undefined;
if (stack === undefined) {
throw new Error('stack not defined');
}
const ageDate: Date = new Date(Date.now() - stack.CreationTime.getTime());
const message = `
Task Stack ${stack.StackName}
Age D${Math.floor(ageDate.getHours() / 24)} H${ageDate.getHours()} M${ageDate.getMinutes()}
${JSON.stringify(stack, undefined, 4)}
${JSON.stringify(stackInfo, undefined, 4)}
${JSON.stringify(stackInfo2, undefined, 4)}
`;
CloudRunnerLogger.log(message);
return message;
}
}

View File

@ -159,10 +159,10 @@ export class Caching {
}
}
} catch (error) {
process.chdir(`${startPath}`);
process.chdir(startPath);
throw error;
}
process.chdir(`${startPath}`);
process.chdir(startPath);
}
public static async handleCachePurging() {

View File

@ -70,7 +70,7 @@ export class RemoteClient {
RemoteClientLogger.log(`${CloudRunner.buildParameters.branch}`);
await CloudRunnerSystem.Run(`git checkout ${CloudRunner.buildParameters.branch}`);
assert(fs.existsSync(path.join(`.git`, `lfs`)), 'LFS folder should not exist before caching');
RemoteClientLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
RemoteClientLogger.log(`Checked out ${CloudRunner.buildParameters.branch}`);
} catch (error) {
throw error;
}

View File

@ -26,6 +26,7 @@ export class TaskParameterSerializer {
}
private static get serializeBuildParamsAndInput() {
let array = new Array();
CloudRunner.buildParameters.projectPath = '.';
array = TaskParameterSerializer.readBuildParameters(array);
array = TaskParameterSerializer.readInput(array);
const configurableHooks = CloudRunnerCustomHooks.getHooks(CloudRunner.buildParameters.customJobHooks);
@ -35,9 +36,9 @@ export class TaskParameterSerializer {
array.push(secrets.reduce((x, y) => [...x, ...y]));
}
array = array.filter(
(x) => x.value !== undefined && x.name !== '0' && x.value !== '' && x.name !== 'prototype' && x.name !== 'length',
);
const blocked = new Set(['0', 'length', 'prototype', '', 'projectPath']);
array = array.filter((x) => !blocked.has(x.name));
array = array.map((x) => {
x.name = Input.ToEnvVarFormat(x.name);
x.value = `${x.value}`;
@ -80,6 +81,7 @@ export class TaskParameterSerializer {
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
array = TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
CloudRunner.buildParameters.projectPath = '.';
array.push(
...ImageEnvironmentFactory.getEnvironmentVariables(CloudRunner.buildParameters)
.filter((x) => array.every((y) => y.ParameterKey !== x.name))

View File

@ -85,7 +85,7 @@ class ImageTag {
// Can only build windows-il2cpp on a windows based system
if (process.platform === 'win32') {
// Unity versions before 2019.3 do not support il2cpp
if (major >= 2020 || (major === 2019 && minor >= 3)) {
if ((process.env.il2cppEnabled && major >= 2020) || (major === 2019 && minor >= 3)) {
return windowsIl2cpp;
} else {
throw new Error(`Windows-based builds are only supported on 2019.3.X+ versions of Unity.
@ -96,7 +96,7 @@ class ImageTag {
return windows;
case Platform.types.StandaloneLinux64: {
// Unity versions before 2019.3 do not support il2cpp
if (major >= 2020 || (major === 2019 && minor >= 3)) {
if ((process.env.il2cppEnabled && major >= 2020) || (major === 2019 && minor >= 3)) {
return linuxIl2cpp;
}