cloud runner options

pull/419/head
Frostebite 2022-08-02 20:03:52 +01:00
parent dcbdfba6ad
commit 2b7c589c7b
18 changed files with 340 additions and 295 deletions

377
dist/index.js vendored
View File

@ -220,6 +220,8 @@ const versioning_1 = __importDefault(__nccwpck_require__(93901));
const git_repo_1 = __nccwpck_require__(24271); const git_repo_1 = __nccwpck_require__(24271);
const github_cli_1 = __nccwpck_require__(44990); const github_cli_1 = __nccwpck_require__(44990);
const cli_1 = __nccwpck_require__(55651); const cli_1 = __nccwpck_require__(55651);
const github_1 = __importDefault(__nccwpck_require__(83654));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class BuildParameters { class BuildParameters {
static create() { static create() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -231,7 +233,7 @@ class BuildParameters {
// Todo - Don't use process.env directly, that's what the input model class is for. // Todo - Don't use process.env directly, that's what the input model class is for.
// --- // ---
let unitySerial = ''; let unitySerial = '';
if (!process.env.UNITY_SERIAL && input_1.default.githubInputEnabled) { if (!process.env.UNITY_SERIAL && github_1.default.githubInputEnabled) {
// No serial was present, so it is a personal license that we need to convert // No serial was present, so it is a personal license that we need to convert
if (!process.env.UNITY_LICENSE) { if (!process.env.UNITY_LICENSE) {
throw new Error(`Missing Unity License File and no Serial was found. If this throw new Error(`Missing Unity License File and no Serial was found. If this
@ -268,36 +270,36 @@ class BuildParameters {
sshAgent: input_1.default.sshAgent, sshAgent: input_1.default.sshAgent,
gitPrivateToken: input_1.default.gitPrivateToken || (yield github_cli_1.GithubCliReader.GetGitHubAuthToken()), gitPrivateToken: input_1.default.gitPrivateToken || (yield github_cli_1.GithubCliReader.GetGitHubAuthToken()),
chownFilesTo: input_1.default.chownFilesTo, chownFilesTo: input_1.default.chownFilesTo,
cloudRunnerCluster: input_1.default.cloudRunnerCluster, cloudRunnerCluster: cloud_runner_options_1.default.cloudRunnerCluster,
cloudRunnerBuilderPlatform: input_1.default.cloudRunnerBuilderPlatform, cloudRunnerBuilderPlatform: cloud_runner_options_1.default.cloudRunnerBuilderPlatform,
awsBaseStackName: input_1.default.awsBaseStackName, awsBaseStackName: cloud_runner_options_1.default.awsBaseStackName,
kubeConfig: input_1.default.kubeConfig, kubeConfig: cloud_runner_options_1.default.kubeConfig,
cloudRunnerMemory: input_1.default.cloudRunnerMemory, cloudRunnerMemory: cloud_runner_options_1.default.cloudRunnerMemory,
cloudRunnerCpu: input_1.default.cloudRunnerCpu, cloudRunnerCpu: cloud_runner_options_1.default.cloudRunnerCpu,
kubeVolumeSize: input_1.default.kubeVolumeSize, kubeVolumeSize: cloud_runner_options_1.default.kubeVolumeSize,
kubeVolume: input_1.default.kubeVolume, kubeVolume: cloud_runner_options_1.default.kubeVolume,
postBuildSteps: input_1.default.postBuildSteps, postBuildSteps: cloud_runner_options_1.default.postBuildSteps,
preBuildSteps: input_1.default.preBuildSteps, preBuildSteps: cloud_runner_options_1.default.preBuildSteps,
customJob: input_1.default.customJob, customJob: cloud_runner_options_1.default.customJob,
runNumber: input_1.default.runNumber, runNumber: input_1.default.runNumber,
branch: input_1.default.branch.replace('/head', '') || (yield git_repo_1.GitRepoReader.GetBranch()), branch: input_1.default.branch.replace('/head', '') || (yield git_repo_1.GitRepoReader.GetBranch()),
cloudRunnerBranch: input_1.default.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerBranch: cloud_runner_options_1.default.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerIntegrationTests: input_1.default.cloudRunnerTests, cloudRunnerIntegrationTests: cloud_runner_options_1.default.cloudRunnerTests,
githubRepo: input_1.default.githubRepo || (yield git_repo_1.GitRepoReader.GetRemote()) || 'game-ci/unity-builder', githubRepo: input_1.default.githubRepo || (yield git_repo_1.GitRepoReader.GetRemote()) || 'game-ci/unity-builder',
isCliMode: cli_1.Cli.isCliMode, isCliMode: cli_1.Cli.isCliMode,
awsStackName: input_1.default.awsBaseStackName, awsStackName: cloud_runner_options_1.default.awsBaseStackName,
gitSha: input_1.default.gitSha, gitSha: input_1.default.gitSha,
logId: nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)(), logId: nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)(),
buildGuid: cloud_runner_guid_1.default.generateGuid(input_1.default.runNumber, input_1.default.targetPlatform), buildGuid: cloud_runner_guid_1.default.generateGuid(input_1.default.runNumber, input_1.default.targetPlatform),
customJobHooks: input_1.default.customJobHooks(), customJobHooks: cloud_runner_options_1.default.customJobHooks(),
cachePullOverrideCommand: input_1.default.cachePullOverrideCommand(), cachePullOverrideCommand: cloud_runner_options_1.default.cachePullOverrideCommand(),
cachePushOverrideCommand: input_1.default.cachePushOverrideCommand(), cachePushOverrideCommand: cloud_runner_options_1.default.cachePushOverrideCommand(),
readInputOverrideCommand: input_1.default.readInputOverrideCommand(), readInputOverrideCommand: cloud_runner_options_1.default.readInputOverrideCommand(),
readInputFromOverrideList: input_1.default.readInputFromOverrideList(), readInputFromOverrideList: cloud_runner_options_1.default.readInputFromOverrideList(),
kubeStorageClass: input_1.default.kubeStorageClass, kubeStorageClass: cloud_runner_options_1.default.kubeStorageClass,
checkDependencyHealthOverride: input_1.default.checkDependencyHealthOverride, checkDependencyHealthOverride: cloud_runner_options_1.default.checkDependencyHealthOverride,
startDependenciesOverride: input_1.default.startDependenciesOverride, startDependenciesOverride: cloud_runner_options_1.default.startDependenciesOverride,
cacheKey: input_1.default.cacheKey, cacheKey: cloud_runner_options_1.default.cacheKey,
}; };
}); });
} }
@ -483,6 +485,8 @@ const aws_cli_commands_1 = __nccwpck_require__(34340);
const caching_1 = __nccwpck_require__(32885); const caching_1 = __nccwpck_require__(32885);
const lfs_hashing_1 = __nccwpck_require__(8915); const lfs_hashing_1 = __nccwpck_require__(8915);
const remote_client_1 = __nccwpck_require__(48135); const remote_client_1 = __nccwpck_require__(48135);
const cloud_runner_options_reader_1 = __importDefault(__nccwpck_require__(3343));
const github_1 = __importDefault(__nccwpck_require__(83654));
class Cli { class Cli {
static get isCliMode() { static get isCliMode() {
return Cli.options !== undefined && Cli.options.mode !== undefined && Cli.options.mode !== ''; return Cli.options !== undefined && Cli.options.mode !== undefined && Cli.options.mode !== '';
@ -503,7 +507,7 @@ class Cli {
cli_functions_repository_1.CliFunctionsRepository.PushCliFunctionSource(remote_client_1.RemoteClient); cli_functions_repository_1.CliFunctionsRepository.PushCliFunctionSource(remote_client_1.RemoteClient);
const program = new commander_ts_1.Command(); const program = new commander_ts_1.Command();
program.version('0.0.1'); program.version('0.0.1');
const properties = Object.getOwnPropertyNames(__1.Input); const properties = cloud_runner_options_reader_1.default.GetProperties();
const actionYamlReader = new action_yaml_1.ActionYamlReader(); const actionYamlReader = new action_yaml_1.ActionYamlReader();
for (const element of properties) { for (const element of properties) {
program.option(`--${element} <${element}>`, actionYamlReader.GetActionYamlValue(element)); program.option(`--${element} <${element}>`, actionYamlReader.GetActionYamlValue(element));
@ -521,7 +525,7 @@ class Cli {
} }
static RunCli() { static RunCli() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
__1.Input.githubInputEnabled = false; github_1.default.githubInputEnabled = false;
if (Cli.options['populateOverride'] === `true`) { if (Cli.options['populateOverride'] === `true`) {
yield cloud_runner_query_override_1.default.PopulateQueryOverrideInput(); yield cloud_runner_query_override_1.default.PopulateQueryOverrideInput();
} }
@ -537,7 +541,7 @@ class Cli {
static logInput() { static logInput() {
core.info(`\n`); core.info(`\n`);
core.info(`INPUT:`); core.info(`INPUT:`);
const properties = Object.getOwnPropertyNames(__1.Input); const properties = cloud_runner_options_reader_1.default.GetProperties();
for (const element of properties) { for (const element of properties) {
if (__1.Input[element] !== undefined && if (__1.Input[element] !== undefined &&
__1.Input[element] !== '' && __1.Input[element] !== '' &&
@ -567,6 +571,160 @@ __decorate([
exports.Cli = Cli; exports.Cli = Cli;
/***/ }),
/***/ 96552:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const cli_1 = __nccwpck_require__(55651);
const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011));
const github_1 = __importDefault(__nccwpck_require__(83654));
const core = __nccwpck_require__(42186);
class CloudRunnerOptions {
static getInput(query) {
if (github_1.default.githubInputEnabled) {
const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') {
return coreInput;
}
}
const alternativeQuery = CloudRunnerOptions.ToEnvVarFormat(query);
// Query input sources
if (cli_1.Cli.query(query, alternativeQuery)) {
return cli_1.Cli.query(query, alternativeQuery);
}
if (cloud_runner_query_override_1.default.query(query, alternativeQuery)) {
return cloud_runner_query_override_1.default.query(query, alternativeQuery);
}
if (process.env[query] !== undefined) {
return process.env[query];
}
if (alternativeQuery !== query && process.env[alternativeQuery] !== undefined) {
return process.env[alternativeQuery];
}
return;
}
static get region() {
return CloudRunnerOptions.getInput('region') || 'eu-west-2';
}
static get githubRepo() {
return CloudRunnerOptions.getInput('GITHUB_REPOSITORY') || CloudRunnerOptions.getInput('GITHUB_REPO') || undefined;
}
static get branch() {
if (CloudRunnerOptions.getInput(`GITHUB_REF`)) {
return CloudRunnerOptions.getInput(`GITHUB_REF`).replace('refs/', '').replace(`head/`, '').replace(`heads/`, '');
}
else if (CloudRunnerOptions.getInput('branch')) {
return CloudRunnerOptions.getInput('branch');
}
else {
return '';
}
}
static get cloudRunnerBuilderPlatform() {
const input = CloudRunnerOptions.getInput('cloudRunnerBuilderPlatform');
if (input) {
return input;
}
if (CloudRunnerOptions.cloudRunnerCluster !== 'local') {
return 'linux';
}
return;
}
static get gitSha() {
if (CloudRunnerOptions.getInput(`GITHUB_SHA`)) {
return CloudRunnerOptions.getInput(`GITHUB_SHA`);
}
else if (CloudRunnerOptions.getInput(`GitSHA`)) {
return CloudRunnerOptions.getInput(`GitSHA`);
}
}
static get customJob() {
return CloudRunnerOptions.getInput('customJob') || '';
}
static customJobHooks() {
return CloudRunnerOptions.getInput('customJobHooks') || '';
}
static cachePushOverrideCommand() {
return CloudRunnerOptions.getInput('cachePushOverrideCommand') || '';
}
static cachePullOverrideCommand() {
return CloudRunnerOptions.getInput('cachePullOverrideCommand') || '';
}
static readInputFromOverrideList() {
return CloudRunnerOptions.getInput('readInputFromOverrideList') || '';
}
static readInputOverrideCommand() {
return CloudRunnerOptions.getInput('readInputOverrideCommand') || '';
}
static get cloudRunnerBranch() {
return CloudRunnerOptions.getInput('cloudRunnerBranch') || 'cloud-runner-develop';
}
static get postBuildSteps() {
return CloudRunnerOptions.getInput('postBuildSteps') || '';
}
static get preBuildSteps() {
return CloudRunnerOptions.getInput('preBuildSteps') || '';
}
static get awsBaseStackName() {
return CloudRunnerOptions.getInput('awsBaseStackName') || 'game-ci';
}
static get cloudRunnerCluster() {
if (cli_1.Cli.isCliMode) {
return CloudRunnerOptions.getInput('cloudRunnerCluster') || 'aws';
}
return CloudRunnerOptions.getInput('cloudRunnerCluster') || 'local';
}
static get cloudRunnerCpu() {
return CloudRunnerOptions.getInput('cloudRunnerCpu');
}
static get cloudRunnerMemory() {
return CloudRunnerOptions.getInput('cloudRunnerMemory');
}
static get kubeConfig() {
return CloudRunnerOptions.getInput('kubeConfig') || '';
}
static get kubeVolume() {
return CloudRunnerOptions.getInput('kubeVolume') || '';
}
static get kubeVolumeSize() {
return CloudRunnerOptions.getInput('kubeVolumeSize') || '5Gi';
}
static get kubeStorageClass() {
return CloudRunnerOptions.getInput('kubeStorageClass') || '';
}
static get checkDependencyHealthOverride() {
return CloudRunnerOptions.getInput('checkDependencyHealthOverride') || '';
}
static get startDependenciesOverride() {
return CloudRunnerOptions.getInput('startDependenciesOverride') || '';
}
static get cacheKey() {
return CloudRunnerOptions.getInput('cacheKey') || CloudRunnerOptions.branch;
}
static get cloudRunnerTests() {
return CloudRunnerOptions.getInput(`cloudRunnerTests`) || false;
}
static ToEnvVarFormat(input) {
if (input.toUpperCase() === input) {
return input;
}
return input
.replace(/([A-Z])/g, ' $1')
.trim()
.toUpperCase()
.replace(/ /g, '_');
}
}
exports["default"] = CloudRunnerOptions;
/***/ }), /***/ }),
/***/ 90828: /***/ 90828:
@ -2383,7 +2541,7 @@ class TaskService {
if (list.length > 0) { if (list.length > 0) {
const describeInput = { tasks: list, cluster: element }; const describeInput = { tasks: list, cluster: element };
const describeList = (yield ecs.describeTasks(describeInput).promise()).tasks || []; const describeList = (yield ecs.describeTasks(describeInput).promise()).tasks || [];
if (describeList === []) { if (describeList.length === 0) {
continue; continue;
} }
cloud_runner_logger_1.default.log(`Tasks ${describeList.length}`); cloud_runner_logger_1.default.log(`Tasks ${describeList.length}`);
@ -4015,6 +4173,27 @@ class CloudRunnerLogger {
exports["default"] = CloudRunnerLogger; exports["default"] = CloudRunnerLogger;
/***/ }),
/***/ 3343:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const input_1 = __importDefault(__nccwpck_require__(91933));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class CloudRunnerOptionsReader {
static GetProperties() {
return [...Object.getOwnPropertyNames(input_1.default), ...Object.getOwnPropertyNames(cloud_runner_options_1.default)];
}
}
exports["default"] = CloudRunnerOptionsReader;
/***/ }), /***/ }),
/***/ 31011: /***/ 31011:
@ -4037,6 +4216,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const input_1 = __importDefault(__nccwpck_require__(91933)); const input_1 = __importDefault(__nccwpck_require__(91933));
const generic_input_reader_1 = __nccwpck_require__(2263); const generic_input_reader_1 = __nccwpck_require__(2263);
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
const formatFunction = (value, arguments_) => { const formatFunction = (value, arguments_) => {
for (const element of arguments_) { for (const element of arguments_) {
value = value.replace(`{${element.key}}`, element.value); value = value.replace(`{${element.key}}`, element.value);
@ -4056,10 +4236,10 @@ class CloudRunnerQueryOverride {
return; return;
} }
static shouldUseOverride(query) { static shouldUseOverride(query) {
if (input_1.default.readInputOverrideCommand() !== '') { if (cloud_runner_options_1.default.readInputOverrideCommand() !== '') {
if (input_1.default.readInputFromOverrideList() !== '') { if (cloud_runner_options_1.default.readInputFromOverrideList() !== '') {
const doesInclude = input_1.default.readInputFromOverrideList().split(',').includes(query) || const doesInclude = cloud_runner_options_1.default.readInputFromOverrideList().split(',').includes(query) ||
input_1.default.readInputFromOverrideList().split(',').includes(input_1.default.ToEnvVarFormat(query)); cloud_runner_options_1.default.readInputFromOverrideList().split(',').includes(input_1.default.ToEnvVarFormat(query));
return doesInclude ? true : false; return doesInclude ? true : false;
} }
else { else {
@ -4072,12 +4252,12 @@ class CloudRunnerQueryOverride {
if (!this.shouldUseOverride(query)) { if (!this.shouldUseOverride(query)) {
throw new Error(`Should not be trying to run override query on ${query}`); throw new Error(`Should not be trying to run override query on ${query}`);
} }
return yield generic_input_reader_1.GenericInputReader.Run(formatFunction(input_1.default.readInputOverrideCommand(), [{ key: 0, value: query }])); return yield generic_input_reader_1.GenericInputReader.Run(formatFunction(cloud_runner_options_1.default.readInputOverrideCommand(), [{ key: 0, value: query }]));
}); });
} }
static PopulateQueryOverrideInput() { static PopulateQueryOverrideInput() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const queries = input_1.default.readInputFromOverrideList().split(','); const queries = cloud_runner_options_1.default.readInputFromOverrideList().split(',');
CloudRunnerQueryOverride.queryOverrides = new Array(); CloudRunnerQueryOverride.queryOverrides = new Array();
for (const element of queries) { for (const element of queries) {
if (CloudRunnerQueryOverride.shouldUseOverride(element)) { if (CloudRunnerQueryOverride.shouldUseOverride(element)) {
@ -4177,14 +4357,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const input_1 = __importDefault(__nccwpck_require__(91933));
const cloud_runner_system_1 = __nccwpck_require__(99393); const cloud_runner_system_1 = __nccwpck_require__(99393);
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class DependencyOverrideService { class DependencyOverrideService {
static CheckHealth() { static CheckHealth() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.checkDependencyHealthOverride) { if (cloud_runner_options_1.default.checkDependencyHealthOverride) {
try { try {
yield cloud_runner_system_1.CloudRunnerSystem.Run(input_1.default.checkDependencyHealthOverride); yield cloud_runner_system_1.CloudRunnerSystem.Run(cloud_runner_options_1.default.checkDependencyHealthOverride);
} }
catch (_a) { catch (_a) {
return false; return false;
@ -4195,8 +4375,8 @@ class DependencyOverrideService {
} }
static TryStartDependencies() { static TryStartDependencies() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.startDependenciesOverride) { if (cloud_runner_options_1.default.startDependenciesOverride) {
yield cloud_runner_system_1.CloudRunnerSystem.Run(input_1.default.startDependenciesOverride); yield cloud_runner_system_1.CloudRunnerSystem.Run(cloud_runner_options_1.default.startDependenciesOverride);
} }
}); });
} }
@ -4372,6 +4552,7 @@ const __1 = __nccwpck_require__(41359);
const image_environment_factory_1 = __importDefault(__nccwpck_require__(25145)); const image_environment_factory_1 = __importDefault(__nccwpck_require__(25145));
const cloud_runner_custom_hooks_1 = __nccwpck_require__(58873); const cloud_runner_custom_hooks_1 = __nccwpck_require__(58873);
const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011)); const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011));
const cloud_runner_options_reader_1 = __importDefault(__nccwpck_require__(3343));
class TaskParameterSerializer { class TaskParameterSerializer {
static readBuildEnvironmentVariables() { static readBuildEnvironmentVariables() {
return [ return [
@ -4420,7 +4601,7 @@ class TaskParameterSerializer {
return array; return array;
} }
static readInput(array) { static readInput(array) {
const input = Object.getOwnPropertyNames(__1.Input); const input = cloud_runner_options_reader_1.default.GetProperties();
for (const element of input) { for (const element of input) {
if (typeof __1.Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) { if (typeof __1.Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
array.push({ array.push({
@ -4852,6 +5033,20 @@ class ValidationError extends Error {
exports["default"] = ValidationError; exports["default"] = ValidationError;
/***/ }),
/***/ 83654:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
class GitHub {
}
GitHub.githubInputEnabled = true;
exports["default"] = GitHub;
/***/ }), /***/ }),
/***/ 25145: /***/ 25145:
@ -5168,11 +5363,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GenericInputReader = void 0; exports.GenericInputReader = void 0;
const cloud_runner_system_1 = __nccwpck_require__(99393); const cloud_runner_system_1 = __nccwpck_require__(99393);
const input_1 = __importDefault(__nccwpck_require__(91933)); const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class GenericInputReader { class GenericInputReader {
static Run(command) { static Run(command) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') { if (cloud_runner_options_1.default.cloudRunnerCluster === 'local') {
return ''; return '';
} }
return yield cloud_runner_system_1.CloudRunnerSystem.Run(command, false, true); return yield cloud_runner_system_1.CloudRunnerSystem.Run(command, false, true);
@ -5207,11 +5402,11 @@ const console_1 = __nccwpck_require__(96206);
const fs_1 = __importDefault(__nccwpck_require__(57147)); const fs_1 = __importDefault(__nccwpck_require__(57147));
const cloud_runner_system_1 = __nccwpck_require__(99393); const cloud_runner_system_1 = __nccwpck_require__(99393);
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855)); const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
const input_1 = __importDefault(__nccwpck_require__(91933)); const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class GitRepoReader { class GitRepoReader {
static GetRemote() { static GetRemote() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') { if (cloud_runner_options_1.default.cloudRunnerCluster === 'local') {
return ''; return '';
} }
console_1.assert(fs_1.default.existsSync(`.git`)); console_1.assert(fs_1.default.existsSync(`.git`));
@ -5223,7 +5418,7 @@ class GitRepoReader {
} }
static GetBranch() { static GetBranch() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') { if (cloud_runner_options_1.default.cloudRunnerCluster === 'local') {
return ''; return '';
} }
console_1.assert(fs_1.default.existsSync(`.git`)); console_1.assert(fs_1.default.existsSync(`.git`));
@ -5279,11 +5474,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GithubCliReader = void 0; exports.GithubCliReader = void 0;
const cloud_runner_system_1 = __nccwpck_require__(99393); const cloud_runner_system_1 = __nccwpck_require__(99393);
const core = __importStar(__nccwpck_require__(42186)); const core = __importStar(__nccwpck_require__(42186));
const input_1 = __importDefault(__nccwpck_require__(91933)); const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
class GithubCliReader { class GithubCliReader {
static GetGitHubAuthToken() { static GetGitHubAuthToken() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') { if (cloud_runner_options_1.default.cloudRunnerCluster === 'local') {
return ''; return '';
} }
try { try {
@ -5321,9 +5516,9 @@ exports.ReadLicense = void 0;
const path_1 = __importDefault(__nccwpck_require__(71017)); const path_1 = __importDefault(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147)); const fs_1 = __importDefault(__nccwpck_require__(57147));
const yaml_1 = __importDefault(__nccwpck_require__(44603)); const yaml_1 = __importDefault(__nccwpck_require__(44603));
const input_1 = __importDefault(__nccwpck_require__(91933)); const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
function ReadLicense() { function ReadLicense() {
if (input_1.default.cloudRunnerCluster === 'local') { if (cloud_runner_options_1.default.cloudRunnerCluster === 'local') {
return ''; return '';
} }
const pipelineFile = path_1.default.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`); const pipelineFile = path_1.default.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);
@ -5348,6 +5543,7 @@ const path_1 = __importDefault(__nccwpck_require__(71017));
const cli_1 = __nccwpck_require__(55651); const cli_1 = __nccwpck_require__(55651);
const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011)); const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011));
const platform_1 = __importDefault(__nccwpck_require__(9707)); const platform_1 = __importDefault(__nccwpck_require__(9707));
const github_1 = __importDefault(__nccwpck_require__(83654));
const core = __nccwpck_require__(42186); const core = __nccwpck_require__(42186);
/** /**
* Input variables specified in workflows using "with" prop. * Input variables specified in workflows using "with" prop.
@ -5358,7 +5554,7 @@ const core = __nccwpck_require__(42186);
*/ */
class Input { class Input {
static getInput(query) { static getInput(query) {
if (Input.githubInputEnabled) { if (github_1.default.githubInputEnabled) {
const coreInput = core.getInput(query); const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') { if (coreInput && coreInput !== '') {
return coreInput; return coreInput;
@ -5397,16 +5593,6 @@ class Input {
return ''; return '';
} }
} }
static get cloudRunnerBuilderPlatform() {
const input = Input.getInput('cloudRunnerBuilderPlatform');
if (input) {
return input;
}
if (Input.cloudRunnerCluster !== 'local') {
return 'linux';
}
return;
}
static get gitSha() { static get gitSha() {
if (Input.getInput(`GITHUB_SHA`)) { if (Input.getInput(`GITHUB_SHA`)) {
return Input.getInput(`GITHUB_SHA`); return Input.getInput(`GITHUB_SHA`);
@ -5486,27 +5672,6 @@ class Input {
static get gitPrivateToken() { static get gitPrivateToken() {
return core.getInput('gitPrivateToken') || false; return core.getInput('gitPrivateToken') || false;
} }
static get customJob() {
return Input.getInput('customJob') || '';
}
static customJobHooks() {
return Input.getInput('customJobHooks') || '';
}
static cachePushOverrideCommand() {
return Input.getInput('cachePushOverrideCommand') || '';
}
static cachePullOverrideCommand() {
return Input.getInput('cachePullOverrideCommand') || '';
}
static readInputFromOverrideList() {
return Input.getInput('readInputFromOverrideList') || '';
}
static readInputOverrideCommand() {
return Input.getInput('readInputOverrideCommand') || '';
}
static get cloudRunnerBranch() {
return Input.getInput('cloudRunnerBranch') || 'cloud-runner-develop';
}
static get chownFilesTo() { static get chownFilesTo() {
return Input.getInput('chownFilesTo') || ''; return Input.getInput('chownFilesTo') || '';
} }
@ -5514,51 +5679,6 @@ class Input {
const input = Input.getInput('allowDirtyBuild') || false; const input = Input.getInput('allowDirtyBuild') || false;
return input === 'true'; return input === 'true';
} }
static get postBuildSteps() {
return Input.getInput('postBuildSteps') || '';
}
static get preBuildSteps() {
return Input.getInput('preBuildSteps') || '';
}
static get awsBaseStackName() {
return Input.getInput('awsBaseStackName') || 'game-ci';
}
static get cloudRunnerCluster() {
if (cli_1.Cli.isCliMode) {
return Input.getInput('cloudRunnerCluster') || 'aws';
}
return Input.getInput('cloudRunnerCluster') || 'local';
}
static get cloudRunnerCpu() {
return Input.getInput('cloudRunnerCpu');
}
static get cloudRunnerMemory() {
return Input.getInput('cloudRunnerMemory');
}
static get kubeConfig() {
return Input.getInput('kubeConfig') || '';
}
static get kubeVolume() {
return Input.getInput('kubeVolume') || '';
}
static get kubeVolumeSize() {
return Input.getInput('kubeVolumeSize') || '5Gi';
}
static get kubeStorageClass() {
return Input.getInput('kubeStorageClass') || '';
}
static get checkDependencyHealthOverride() {
return Input.getInput('checkDependencyHealthOverride') || '';
}
static get startDependenciesOverride() {
return Input.getInput('startDependenciesOverride') || '';
}
static get cacheKey() {
return Input.getInput('cacheKey') || Input.branch;
}
static get cloudRunnerTests() {
return Input.getInput(`cloudRunnerTests`) || false;
}
static ToEnvVarFormat(input) { static ToEnvVarFormat(input) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;
@ -5570,7 +5690,6 @@ class Input {
.replace(/ /g, '_'); .replace(/ /g, '_');
} }
} }
Input.githubInputEnabled = true;
exports["default"] = Input; exports["default"] = Input;
@ -134969,7 +135088,7 @@ Object.defineProperty(apiLoader.services['cloudfront'], '2016-11-25', {
Object.defineProperty(apiLoader.services['cloudfront'], '2017-03-25', { Object.defineProperty(apiLoader.services['cloudfront'], '2017-03-25', {
get: function get() { get: function get() {
var model = __nccwpck_require__(76944); var model = __nccwpck_require__(76944);
model.paginators = (__nccwpck_require__(83654)/* .pagination */ .o); model.paginators = (__nccwpck_require__(34974)/* .pagination */ .o);
model.waiters = (__nccwpck_require__(83406)/* .waiters */ .V); model.waiters = (__nccwpck_require__(83406)/* .waiters */ .V);
return model; return model;
}, },
@ -385433,7 +385552,7 @@ module.exports = JSON.parse('{"version":"2.0","metadata":{"apiVersion":"2017-03-
/***/ }), /***/ }),
/***/ 83654: /***/ 34974:
/***/ ((module) => { /***/ ((module) => {
"use strict"; "use strict";

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,8 @@ import Versioning from './versioning';
import { GitRepoReader } from './input-readers/git-repo'; import { GitRepoReader } from './input-readers/git-repo';
import { GithubCliReader } from './input-readers/github-cli'; import { GithubCliReader } from './input-readers/github-cli';
import { Cli } from './cli/cli'; import { Cli } from './cli/cli';
import GitHub from './github';
import CloudRunnerOptions from './cloud-runner/cloud-runner-options';
class BuildParameters { class BuildParameters {
public editorVersion!: string; public editorVersion!: string;
@ -76,7 +78,7 @@ class BuildParameters {
// Todo - Don't use process.env directly, that's what the input model class is for. // Todo - Don't use process.env directly, that's what the input model class is for.
// --- // ---
let unitySerial = ''; let unitySerial = '';
if (!process.env.UNITY_SERIAL && Input.githubInputEnabled) { if (!process.env.UNITY_SERIAL && GitHub.githubInputEnabled) {
// No serial was present, so it is a personal license that we need to convert // No serial was present, so it is a personal license that we need to convert
if (!process.env.UNITY_LICENSE) { if (!process.env.UNITY_LICENSE) {
throw new Error(`Missing Unity License File and no Serial was found. If this throw new Error(`Missing Unity License File and no Serial was found. If this
@ -114,36 +116,36 @@ class BuildParameters {
sshAgent: Input.sshAgent, sshAgent: Input.sshAgent,
gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()), gitPrivateToken: Input.gitPrivateToken || (await GithubCliReader.GetGitHubAuthToken()),
chownFilesTo: Input.chownFilesTo, chownFilesTo: Input.chownFilesTo,
cloudRunnerCluster: Input.cloudRunnerCluster, cloudRunnerCluster: CloudRunnerOptions.cloudRunnerCluster,
cloudRunnerBuilderPlatform: Input.cloudRunnerBuilderPlatform, cloudRunnerBuilderPlatform: CloudRunnerOptions.cloudRunnerBuilderPlatform,
awsBaseStackName: Input.awsBaseStackName, awsBaseStackName: CloudRunnerOptions.awsBaseStackName,
kubeConfig: Input.kubeConfig, kubeConfig: CloudRunnerOptions.kubeConfig,
cloudRunnerMemory: Input.cloudRunnerMemory, cloudRunnerMemory: CloudRunnerOptions.cloudRunnerMemory,
cloudRunnerCpu: Input.cloudRunnerCpu, cloudRunnerCpu: CloudRunnerOptions.cloudRunnerCpu,
kubeVolumeSize: Input.kubeVolumeSize, kubeVolumeSize: CloudRunnerOptions.kubeVolumeSize,
kubeVolume: Input.kubeVolume, kubeVolume: CloudRunnerOptions.kubeVolume,
postBuildSteps: Input.postBuildSteps, postBuildSteps: CloudRunnerOptions.postBuildSteps,
preBuildSteps: Input.preBuildSteps, preBuildSteps: CloudRunnerOptions.preBuildSteps,
customJob: Input.customJob, customJob: CloudRunnerOptions.customJob,
runNumber: Input.runNumber, runNumber: Input.runNumber,
branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()), branch: Input.branch.replace('/head', '') || (await GitRepoReader.GetBranch()),
cloudRunnerBranch: Input.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerBranch: CloudRunnerOptions.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerIntegrationTests: Input.cloudRunnerTests, cloudRunnerIntegrationTests: CloudRunnerOptions.cloudRunnerTests,
githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder', githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder',
isCliMode: Cli.isCliMode, isCliMode: Cli.isCliMode,
awsStackName: Input.awsBaseStackName, awsStackName: CloudRunnerOptions.awsBaseStackName,
gitSha: Input.gitSha, gitSha: Input.gitSha,
logId: customAlphabet(CloudRunnerConstants.alphabet, 9)(), logId: customAlphabet(CloudRunnerConstants.alphabet, 9)(),
buildGuid: CloudRunnerBuildGuid.generateGuid(Input.runNumber, Input.targetPlatform), buildGuid: CloudRunnerBuildGuid.generateGuid(Input.runNumber, Input.targetPlatform),
customJobHooks: Input.customJobHooks(), customJobHooks: CloudRunnerOptions.customJobHooks(),
cachePullOverrideCommand: Input.cachePullOverrideCommand(), cachePullOverrideCommand: CloudRunnerOptions.cachePullOverrideCommand(),
cachePushOverrideCommand: Input.cachePushOverrideCommand(), cachePushOverrideCommand: CloudRunnerOptions.cachePushOverrideCommand(),
readInputOverrideCommand: Input.readInputOverrideCommand(), readInputOverrideCommand: CloudRunnerOptions.readInputOverrideCommand(),
readInputFromOverrideList: Input.readInputFromOverrideList(), readInputFromOverrideList: CloudRunnerOptions.readInputFromOverrideList(),
kubeStorageClass: Input.kubeStorageClass, kubeStorageClass: CloudRunnerOptions.kubeStorageClass,
checkDependencyHealthOverride: Input.checkDependencyHealthOverride, checkDependencyHealthOverride: CloudRunnerOptions.checkDependencyHealthOverride,
startDependenciesOverride: Input.startDependenciesOverride, startDependenciesOverride: CloudRunnerOptions.startDependenciesOverride,
cacheKey: Input.cacheKey, cacheKey: CloudRunnerOptions.cacheKey,
}; };
} }

View File

@ -9,6 +9,8 @@ import { AwsCliCommands } from '../cloud-runner/providers/aws/commands/aws-cli-c
import { Caching } from '../cloud-runner/remote-client/caching'; import { Caching } from '../cloud-runner/remote-client/caching';
import { LfsHashing } from '../cloud-runner/services/lfs-hashing'; import { LfsHashing } from '../cloud-runner/services/lfs-hashing';
import { RemoteClient } from '../cloud-runner/remote-client'; import { RemoteClient } from '../cloud-runner/remote-client';
import CloudRunnerOptionsReader from '../cloud-runner/services/cloud-runner-options-reader';
import GitHub from '../github';
export class Cli { export class Cli {
public static options; public static options;
@ -33,7 +35,8 @@ export class Cli {
CliFunctionsRepository.PushCliFunctionSource(RemoteClient); CliFunctionsRepository.PushCliFunctionSource(RemoteClient);
const program = new Command(); const program = new Command();
program.version('0.0.1'); program.version('0.0.1');
const properties = Object.getOwnPropertyNames(Input);
const properties = CloudRunnerOptionsReader.GetProperties();
const actionYamlReader: ActionYamlReader = new ActionYamlReader(); const actionYamlReader: ActionYamlReader = new ActionYamlReader();
for (const element of properties) { for (const element of properties) {
program.option(`--${element} <${element}>`, actionYamlReader.GetActionYamlValue(element)); program.option(`--${element} <${element}>`, actionYamlReader.GetActionYamlValue(element));
@ -55,7 +58,7 @@ export class Cli {
} }
static async RunCli(): Promise<void> { static async RunCli(): Promise<void> {
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
if (Cli.options['populateOverride'] === `true`) { if (Cli.options['populateOverride'] === `true`) {
await CloudRunnerQueryOverride.PopulateQueryOverrideInput(); await CloudRunnerQueryOverride.PopulateQueryOverrideInput();
} }
@ -73,7 +76,7 @@ export class Cli {
private static logInput() { private static logInput() {
core.info(`\n`); core.info(`\n`);
core.info(`INPUT:`); core.info(`INPUT:`);
const properties = Object.getOwnPropertyNames(Input); const properties = CloudRunnerOptionsReader.GetProperties();
for (const element of properties) { for (const element of properties) {
if ( if (
Input[element] !== undefined && Input[element] !== undefined &&

View File

@ -1,11 +1,11 @@
import { Cli } from '../cli/cli'; import { Cli } from '../cli/cli';
import CloudRunnerQueryOverride from './services/cloud-runner-query-override'; import CloudRunnerQueryOverride from './services/cloud-runner-query-override';
import Input from '../input'; import GitHub from '../github';
const core = require('@actions/core'); const core = require('@actions/core');
class CloudRunnerOptions { class CloudRunnerOptions {
public static getInput(query) { public static getInput(query) {
if (Input.githubInputEnabled) { if (GitHub.githubInputEnabled) {
const coreInput = core.getInput(query); const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') { if (coreInput && coreInput !== '') {
return coreInput; return coreInput;

View File

@ -7,6 +7,8 @@ import UnityVersioning from '../unity-versioning';
import { Cli } from '../cli/cli'; import { Cli } from '../cli/cli';
import CloudRunnerLogger from './services/cloud-runner-logger'; import CloudRunnerLogger from './services/cloud-runner-logger';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import CloudRunnerOptions from './cloud-runner-options';
import GitHub from '../github';
describe('Cloud Runner', () => { describe('Cloud Runner', () => {
it('responds', () => {}); it('responds', () => {});
@ -14,7 +16,7 @@ describe('Cloud Runner', () => {
describe('Cloud Runner', () => { describe('Cloud Runner', () => {
const testSecretName = 'testSecretName'; const testSecretName = 'testSecretName';
const testSecretValue = 'testSecretValue'; const testSecretValue = 'testSecretValue';
if (Input.cloudRunnerTests) { if (CloudRunnerOptions.cloudRunnerTests) {
it('All build parameters sent to cloud runner as env vars', async () => { it('All build parameters sent to cloud runner as env vars', async () => {
// Build parameters // Build parameters
Cli.options = { Cli.options = {
@ -31,11 +33,11 @@ describe('Cloud Runner', () => {
value: '${testSecretValue}' value: '${testSecretValue}'
`, `,
}; };
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
// Setup parameters // Setup parameters
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
Input.githubInputEnabled = true; GitHub.githubInputEnabled = true;
const baseImage = new ImageTag(buildParameter); const baseImage = new ImageTag(buildParameter);
// Run the job // Run the job
@ -72,7 +74,7 @@ describe('Cloud Runner', () => {
targetPlatform: 'StandaloneLinux64', targetPlatform: 'StandaloneLinux64',
cacheKey: `test-case-${uuidv4()}`, cacheKey: `test-case-${uuidv4()}`,
}; };
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
const baseImage = new ImageTag(buildParameter); const baseImage = new ImageTag(buildParameter);
const results = await CloudRunner.run(buildParameter, baseImage.toString()); const results = await CloudRunner.run(buildParameter, baseImage.toString());
@ -87,7 +89,7 @@ describe('Cloud Runner', () => {
CloudRunnerLogger.log(`run 2 succeeded`); CloudRunnerLogger.log(`run 2 succeeded`);
expect(results2).toContain(buildSucceededString); expect(results2).toContain(buildSucceededString);
expect(results2).toEqual(expect.not.stringContaining(libraryString)); expect(results2).toEqual(expect.not.stringContaining(libraryString));
Input.githubInputEnabled = true; GitHub.githubInputEnabled = true;
delete Cli.options; delete Cli.options;
}, 1000000); }, 1000000);
} }
@ -108,7 +110,7 @@ describe('Cloud Runner', () => {
value: '${testSecretValue}' value: '${testSecretValue}'
`, `,
}; };
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
// Setup parameters // Setup parameters
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
@ -116,7 +118,7 @@ describe('Cloud Runner', () => {
// Run the job // Run the job
await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow(); await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow();
Input.githubInputEnabled = true; GitHub.githubInputEnabled = true;
delete Cli.options; delete Cli.options;
}, 1000000); }, 1000000);
it('Test cloud runner returns commands', async () => { it('Test cloud runner returns commands', async () => {
@ -128,7 +130,7 @@ describe('Cloud Runner', () => {
cloudRunnerCluster: 'test', cloudRunnerCluster: 'test',
targetPlatform: 'StandaloneLinux64', targetPlatform: 'StandaloneLinux64',
}; };
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
// Setup parameters // Setup parameters
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
@ -136,7 +138,7 @@ describe('Cloud Runner', () => {
// Run the job // Run the job
await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow(); await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow();
Input.githubInputEnabled = true; GitHub.githubInputEnabled = true;
delete Cli.options; delete Cli.options;
}, 1000000); }, 1000000);
}); });

View File

@ -59,7 +59,7 @@ export class TaskService {
if (list.length > 0) { if (list.length > 0) {
const describeInput: AWS.ECS.DescribeTasksRequest = { tasks: list, cluster: element }; const describeInput: AWS.ECS.DescribeTasksRequest = { tasks: list, cluster: element };
const describeList = (await ecs.describeTasks(describeInput).promise()).tasks || []; const describeList = (await ecs.describeTasks(describeInput).promise()).tasks || [];
if (describeList === []) { if (describeList.length === 0) {
continue; continue;
} }
CloudRunnerLogger.log(`Tasks ${describeList.length}`); CloudRunnerLogger.log(`Tasks ${describeList.length}`);

View File

@ -2,12 +2,12 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import BuildParameters from '../../build-parameters'; import BuildParameters from '../../build-parameters';
import { Cli } from '../../cli/cli'; import { Cli } from '../../cli/cli';
import Input from '../../input';
import UnityVersioning from '../../unity-versioning'; import UnityVersioning from '../../unity-versioning';
import CloudRunner from '../cloud-runner'; import CloudRunner from '../cloud-runner';
import { CloudRunnerSystem } from '../services/cloud-runner-system'; import { CloudRunnerSystem } from '../services/cloud-runner-system';
import { Caching } from './caching'; import { Caching } from './caching';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import GitHub from '../../github';
describe('Cloud Runner Caching', () => { describe('Cloud Runner Caching', () => {
it('responds', () => {}); it('responds', () => {});
@ -22,7 +22,7 @@ describe('Cloud Runner Caching', () => {
targetPlatform: 'StandaloneLinux64', targetPlatform: 'StandaloneLinux64',
cacheKey: `test-case-${uuidv4()}`, cacheKey: `test-case-${uuidv4()}`,
}; };
Input.githubInputEnabled = false; GitHub.githubInputEnabled = false;
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
CloudRunner.buildParameters = buildParameter; CloudRunner.buildParameters = buildParameter;
@ -56,7 +56,7 @@ describe('Cloud Runner Caching', () => {
fs.rmdirSync(testFolder, { recursive: true }); fs.rmdirSync(testFolder, { recursive: true });
fs.rmdirSync(cacheFolder, { recursive: true }); fs.rmdirSync(cacheFolder, { recursive: true });
Input.githubInputEnabled = true; GitHub.githubInputEnabled = true;
delete Cli.options; delete Cli.options;
}, 1000000); }, 1000000);
} }

View File

@ -0,0 +1,10 @@
import Input from '../../input';
import CloudRunnerOptions from '../cloud-runner-options';
class CloudRunnerOptionsReader {
static GetProperties() {
return [...Object.getOwnPropertyNames(Input), ...Object.getOwnPropertyNames(CloudRunnerOptions)];
}
}
export default CloudRunnerOptionsReader;

View File

@ -1,5 +1,6 @@
import Input from '../../input'; import Input from '../../input';
import { GenericInputReader } from '../../input-readers/generic-input-reader'; import { GenericInputReader } from '../../input-readers/generic-input-reader';
import CloudRunnerOptions from '../cloud-runner-options';
const formatFunction = (value, arguments_) => { const formatFunction = (value, arguments_) => {
for (const element of arguments_) { for (const element of arguments_) {
@ -28,11 +29,11 @@ class CloudRunnerQueryOverride {
} }
private static shouldUseOverride(query) { private static shouldUseOverride(query) {
if (Input.readInputOverrideCommand() !== '') { if (CloudRunnerOptions.readInputOverrideCommand() !== '') {
if (Input.readInputFromOverrideList() !== '') { if (CloudRunnerOptions.readInputFromOverrideList() !== '') {
const doesInclude = const doesInclude =
Input.readInputFromOverrideList().split(',').includes(query) || CloudRunnerOptions.readInputFromOverrideList().split(',').includes(query) ||
Input.readInputFromOverrideList().split(',').includes(Input.ToEnvVarFormat(query)); CloudRunnerOptions.readInputFromOverrideList().split(',').includes(Input.ToEnvVarFormat(query));
return doesInclude ? true : false; return doesInclude ? true : false;
} else { } else {
@ -46,11 +47,13 @@ class CloudRunnerQueryOverride {
throw new Error(`Should not be trying to run override query on ${query}`); throw new Error(`Should not be trying to run override query on ${query}`);
} }
return await GenericInputReader.Run(formatFunction(Input.readInputOverrideCommand(), [{ key: 0, value: query }])); return await GenericInputReader.Run(
formatFunction(CloudRunnerOptions.readInputOverrideCommand(), [{ key: 0, value: query }]),
);
} }
public static async PopulateQueryOverrideInput() { public static async PopulateQueryOverrideInput() {
const queries = Input.readInputFromOverrideList().split(','); const queries = CloudRunnerOptions.readInputFromOverrideList().split(',');
CloudRunnerQueryOverride.queryOverrides = new Array(); CloudRunnerQueryOverride.queryOverrides = new Array();
for (const element of queries) { for (const element of queries) {
if (CloudRunnerQueryOverride.shouldUseOverride(element)) { if (CloudRunnerQueryOverride.shouldUseOverride(element)) {

View File

@ -1,11 +1,11 @@
import Input from '../../input';
import { CloudRunnerSystem } from './cloud-runner-system'; import { CloudRunnerSystem } from './cloud-runner-system';
import CloudRunnerOptions from '../cloud-runner-options';
class DependencyOverrideService { class DependencyOverrideService {
public static async CheckHealth() { public static async CheckHealth() {
if (Input.checkDependencyHealthOverride) { if (CloudRunnerOptions.checkDependencyHealthOverride) {
try { try {
await CloudRunnerSystem.Run(Input.checkDependencyHealthOverride); await CloudRunnerSystem.Run(CloudRunnerOptions.checkDependencyHealthOverride);
} catch { } catch {
return false; return false;
} }
@ -14,8 +14,8 @@ class DependencyOverrideService {
return true; return true;
} }
public static async TryStartDependencies() { public static async TryStartDependencies() {
if (Input.startDependenciesOverride) { if (CloudRunnerOptions.startDependenciesOverride) {
await CloudRunnerSystem.Run(Input.startDependenciesOverride); await CloudRunnerSystem.Run(CloudRunnerOptions.startDependenciesOverride);
} }
} }
} }

View File

@ -4,6 +4,7 @@ import CloudRunnerEnvironmentVariable from './cloud-runner-environment-variable'
import { CloudRunnerCustomHooks } from './cloud-runner-custom-hooks'; import { CloudRunnerCustomHooks } from './cloud-runner-custom-hooks';
import CloudRunnerSecret from './cloud-runner-secret'; import CloudRunnerSecret from './cloud-runner-secret';
import CloudRunnerQueryOverride from './cloud-runner-query-override'; import CloudRunnerQueryOverride from './cloud-runner-query-override';
import CloudRunnerOptionsReader from './cloud-runner-options-reader';
export class TaskParameterSerializer { export class TaskParameterSerializer {
public static readBuildEnvironmentVariables(): CloudRunnerEnvironmentVariable[] { public static readBuildEnvironmentVariables(): CloudRunnerEnvironmentVariable[] {
@ -61,7 +62,7 @@ export class TaskParameterSerializer {
} }
private static readInput(array: any[]) { private static readInput(array: any[]) {
const input = Object.getOwnPropertyNames(Input); const input = CloudRunnerOptionsReader.GetProperties();
for (const element of input) { for (const element of input) {
if (typeof Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) { if (typeof Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
array.push({ array.push({

View File

@ -0,0 +1,5 @@
class GitHub {
public static githubInputEnabled: boolean = true;
}
export default GitHub;

View File

@ -1,9 +1,9 @@
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system'; import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import Input from '../input'; import CloudRunnerOptions from '../cloud-runner/cloud-runner-options';
export class GenericInputReader { export class GenericInputReader {
public static async Run(command) { public static async Run(command) {
if (Input.cloudRunnerCluster === 'local') { if (CloudRunnerOptions.cloudRunnerCluster === 'local') {
return ''; return '';
} }

View File

@ -2,11 +2,11 @@ import { assert } from 'console';
import fs from 'fs'; import fs from 'fs';
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system'; import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger'; import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
import Input from '../input'; import CloudRunnerOptions from '../cloud-runner/cloud-runner-options';
export class GitRepoReader { export class GitRepoReader {
public static async GetRemote() { public static async GetRemote() {
if (Input.cloudRunnerCluster === 'local') { if (CloudRunnerOptions.cloudRunnerCluster === 'local') {
return ''; return '';
} }
assert(fs.existsSync(`.git`)); assert(fs.existsSync(`.git`));
@ -18,7 +18,7 @@ export class GitRepoReader {
} }
public static async GetBranch() { public static async GetBranch() {
if (Input.cloudRunnerCluster === 'local') { if (CloudRunnerOptions.cloudRunnerCluster === 'local') {
return ''; return '';
} }
assert(fs.existsSync(`.git`)); assert(fs.existsSync(`.git`));

View File

@ -1,10 +1,10 @@
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system'; import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import * as core from '@actions/core'; import * as core from '@actions/core';
import Input from '../input'; import CloudRunnerOptions from '../cloud-runner/cloud-runner-options';
export class GithubCliReader { export class GithubCliReader {
static async GetGitHubAuthToken() { static async GetGitHubAuthToken() {
if (Input.cloudRunnerCluster === 'local') { if (CloudRunnerOptions.cloudRunnerCluster === 'local') {
return ''; return '';
} }
try { try {

View File

@ -1,10 +1,10 @@
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import YAML from 'yaml'; import YAML from 'yaml';
import Input from '../input'; import CloudRunnerOptions from '../cloud-runner/cloud-runner-options';
export function ReadLicense() { export function ReadLicense() {
if (Input.cloudRunnerCluster === 'local') { if (CloudRunnerOptions.cloudRunnerCluster === 'local') {
return ''; return '';
} }
const pipelineFile = path.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`); const pipelineFile = path.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);

View File

@ -3,6 +3,7 @@ import path from 'path';
import { Cli } from './cli/cli'; import { Cli } from './cli/cli';
import CloudRunnerQueryOverride from './cloud-runner/services/cloud-runner-query-override'; import CloudRunnerQueryOverride from './cloud-runner/services/cloud-runner-query-override';
import Platform from './platform'; import Platform from './platform';
import GitHub from './github';
const core = require('@actions/core'); const core = require('@actions/core');
@ -14,10 +15,8 @@ const core = require('@actions/core');
* Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow * Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow
*/ */
class Input { class Input {
public static githubInputEnabled: boolean = true;
public static getInput(query) { public static getInput(query) {
if (Input.githubInputEnabled) { if (GitHub.githubInputEnabled) {
const coreInput = core.getInput(query); const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') { if (coreInput && coreInput !== '') {
return coreInput; return coreInput;
@ -61,17 +60,6 @@ class Input {
return ''; return '';
} }
} }
static get cloudRunnerBuilderPlatform() {
const input = Input.getInput('cloudRunnerBuilderPlatform');
if (input) {
return input;
}
if (Input.cloudRunnerCluster !== 'local') {
return 'linux';
}
return;
}
static get gitSha() { static get gitSha() {
if (Input.getInput(`GITHUB_SHA`)) { if (Input.getInput(`GITHUB_SHA`)) {
@ -175,34 +163,6 @@ class Input {
return core.getInput('gitPrivateToken') || false; return core.getInput('gitPrivateToken') || false;
} }
static get customJob() {
return Input.getInput('customJob') || '';
}
static customJobHooks() {
return Input.getInput('customJobHooks') || '';
}
static cachePushOverrideCommand() {
return Input.getInput('cachePushOverrideCommand') || '';
}
static cachePullOverrideCommand() {
return Input.getInput('cachePullOverrideCommand') || '';
}
static readInputFromOverrideList() {
return Input.getInput('readInputFromOverrideList') || '';
}
static readInputOverrideCommand() {
return Input.getInput('readInputOverrideCommand') || '';
}
static get cloudRunnerBranch() {
return Input.getInput('cloudRunnerBranch') || 'cloud-runner-develop';
}
static get chownFilesTo() { static get chownFilesTo() {
return Input.getInput('chownFilesTo') || ''; return Input.getInput('chownFilesTo') || '';
} }
@ -213,66 +173,6 @@ class Input {
return input === 'true'; return input === 'true';
} }
static get postBuildSteps() {
return Input.getInput('postBuildSteps') || '';
}
static get preBuildSteps() {
return Input.getInput('preBuildSteps') || '';
}
static get awsBaseStackName() {
return Input.getInput('awsBaseStackName') || 'game-ci';
}
static get cloudRunnerCluster() {
if (Cli.isCliMode) {
return Input.getInput('cloudRunnerCluster') || 'aws';
}
return Input.getInput('cloudRunnerCluster') || 'local';
}
static get cloudRunnerCpu() {
return Input.getInput('cloudRunnerCpu');
}
static get cloudRunnerMemory() {
return Input.getInput('cloudRunnerMemory');
}
static get kubeConfig() {
return Input.getInput('kubeConfig') || '';
}
static get kubeVolume() {
return Input.getInput('kubeVolume') || '';
}
static get kubeVolumeSize() {
return Input.getInput('kubeVolumeSize') || '5Gi';
}
static get kubeStorageClass(): string {
return Input.getInput('kubeStorageClass') || '';
}
static get checkDependencyHealthOverride(): string {
return Input.getInput('checkDependencyHealthOverride') || '';
}
static get startDependenciesOverride(): string {
return Input.getInput('startDependenciesOverride') || '';
}
static get cacheKey(): string {
return Input.getInput('cacheKey') || Input.branch;
}
static get cloudRunnerTests(): boolean {
return Input.getInput(`cloudRunnerTests`) || false;
}
public static ToEnvVarFormat(input: string) { public static ToEnvVarFormat(input: string) {
if (input.toUpperCase() === input) { if (input.toUpperCase() === input) {
return input; return input;