further cleanup input
parent
5568402e54
commit
06d1a20e83
|
|
@ -55,9 +55,7 @@ function runMain() {
|
||||||
const { workspace, actionFolder } = model_1.Action;
|
const { workspace, actionFolder } = model_1.Action;
|
||||||
const buildParameters = yield model_1.BuildParameters.create();
|
const buildParameters = yield model_1.BuildParameters.create();
|
||||||
const baseImage = new model_1.ImageTag(buildParameters);
|
const baseImage = new model_1.ImageTag(buildParameters);
|
||||||
if (buildParameters.cloudRunnerCluster &&
|
if (buildParameters.cloudRunnerCluster) {
|
||||||
buildParameters.cloudRunnerCluster !== '' &&
|
|
||||||
buildParameters.cloudRunnerCluster !== 'local') {
|
|
||||||
yield model_1.CloudRunner.run(buildParameters, baseImage.toString());
|
yield model_1.CloudRunner.run(buildParameters, baseImage.toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -506,8 +504,14 @@ class CLI {
|
||||||
static get cliMode() {
|
static get cliMode() {
|
||||||
return CLI.options !== undefined && CLI.options.mode !== undefined && CLI.options.mode !== '';
|
return CLI.options !== undefined && CLI.options.mode !== undefined && CLI.options.mode !== '';
|
||||||
}
|
}
|
||||||
static query(key) {
|
static query(key, alternativeKey) {
|
||||||
return CLI.cliMode && CLI.options[key] !== undefined ? CLI.options[key] : undefined;
|
if (CLI.options && CLI.options[key] !== undefined) {
|
||||||
|
return CLI.options[key];
|
||||||
|
}
|
||||||
|
if (CLI.options && alternativeKey && CLI.options[alternativeKey] !== undefined) {
|
||||||
|
return CLI.options[alternativeKey];
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
static InitCliMode() {
|
static InitCliMode() {
|
||||||
const program = new commander_ts_1.Command();
|
const program = new commander_ts_1.Command();
|
||||||
|
|
@ -778,29 +782,50 @@ class CloudRunnerSystem {
|
||||||
remote_client_logger_1.RemoteClientLogger.log(element);
|
remote_client_logger_1.RemoteClientLogger.log(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return yield new Promise((promise) => {
|
return yield new Promise((promise, throwError) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
const child = child_process_1.exec(command, (error, stdout, stderr) => {
|
const child = child_process_1.exec(command, (error, stdout, stderr) => {
|
||||||
if (error && !suppressError) {
|
if (!suppressError && error) {
|
||||||
throw error;
|
remote_client_logger_1.RemoteClientLogger.log(error.toString());
|
||||||
|
throwError(error);
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('stderr');
|
||||||
const diagnosticOutput = `${stderr.toString()}`;
|
const diagnosticOutput = `${stderr.toString()}`;
|
||||||
if (!suppressLogs) {
|
if (!suppressLogs) {
|
||||||
remote_client_logger_1.RemoteClientLogger.logCliDiagnostic(diagnosticOutput);
|
remote_client_logger_1.RemoteClientLogger.logCliDiagnostic(diagnosticOutput);
|
||||||
}
|
}
|
||||||
output += diagnosticOutput;
|
output += diagnosticOutput;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('stdout');
|
||||||
const outputChunk = `${stdout}`;
|
const outputChunk = `${stdout}`;
|
||||||
output += outputChunk;
|
output += outputChunk;
|
||||||
});
|
});
|
||||||
child.on('close', function (code) {
|
child.on('message', (message) => {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('message');
|
||||||
|
const outputChunk = `${message}`;
|
||||||
|
output += outputChunk;
|
||||||
|
});
|
||||||
|
child.on('error', (error) => {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('error');
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(error.toString());
|
||||||
|
if (error) {
|
||||||
|
throwError(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.on('disconnect', (error) => {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('disconnect');
|
||||||
|
if (error) {
|
||||||
|
throwError(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.on('close', (code) => {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log('close');
|
||||||
if (!suppressLogs) {
|
if (!suppressLogs) {
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`);
|
remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`);
|
||||||
}
|
}
|
||||||
if (code !== 0 && !suppressError) {
|
if (code !== 0 && !suppressError) {
|
||||||
throw new Error(output);
|
throwError(output);
|
||||||
}
|
}
|
||||||
const outputLines = output.split(`\n`);
|
const outputLines = output.split(`\n`);
|
||||||
for (const element of outputLines) {
|
for (const element of outputLines) {
|
||||||
|
|
@ -1827,6 +1852,9 @@ const workflow_composition_root_1 = __nccwpck_require__(54204);
|
||||||
const cloud_runner_error_1 = __nccwpck_require__(91477);
|
const cloud_runner_error_1 = __nccwpck_require__(91477);
|
||||||
const task_parameter_serializer_1 = __nccwpck_require__(35346);
|
const task_parameter_serializer_1 = __nccwpck_require__(35346);
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
const core = __importStar(__nccwpck_require__(42186));
|
||||||
|
const test_1 = __importDefault(__nccwpck_require__(95449));
|
||||||
|
const local_1 = __importDefault(__nccwpck_require__(38588));
|
||||||
|
const local_docker_1 = __importDefault(__nccwpck_require__(26955));
|
||||||
class CloudRunner {
|
class CloudRunner {
|
||||||
static setup(buildParameters) {
|
static setup(buildParameters) {
|
||||||
cloud_runner_logger_1.default.setup();
|
cloud_runner_logger_1.default.setup();
|
||||||
|
|
@ -1841,16 +1869,23 @@ class CloudRunner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static setupBuildPlatform() {
|
static setupBuildPlatform() {
|
||||||
|
cloud_runner_logger_1.default.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.cloudRunnerCluster}`);
|
||||||
switch (CloudRunner.buildParameters.cloudRunnerCluster) {
|
switch (CloudRunner.buildParameters.cloudRunnerCluster) {
|
||||||
case 'k8s':
|
case 'k8s':
|
||||||
cloud_runner_logger_1.default.log('Cloud Runner platform selected Kubernetes');
|
|
||||||
CloudRunner.CloudRunnerProviderPlatform = new k8s_1.default(CloudRunner.buildParameters);
|
CloudRunner.CloudRunnerProviderPlatform = new k8s_1.default(CloudRunner.buildParameters);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
case 'aws':
|
case 'aws':
|
||||||
cloud_runner_logger_1.default.log('Cloud Runner platform selected AWS');
|
|
||||||
CloudRunner.CloudRunnerProviderPlatform = new aws_1.default(CloudRunner.buildParameters);
|
CloudRunner.CloudRunnerProviderPlatform = new aws_1.default(CloudRunner.buildParameters);
|
||||||
break;
|
break;
|
||||||
|
case 'test':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new test_1.default();
|
||||||
|
break;
|
||||||
|
case 'local':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new local_1.default();
|
||||||
|
break;
|
||||||
|
case 'local-docker':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new local_docker_1.default();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static run(buildParameters, baseImage) {
|
static run(buildParameters, baseImage) {
|
||||||
|
|
@ -2666,6 +2701,118 @@ class KubernetesTaskRunner {
|
||||||
exports["default"] = KubernetesTaskRunner;
|
exports["default"] = KubernetesTaskRunner;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 26955:
|
||||||
|
/***/ (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 cloud_runner_system_1 = __nccwpck_require__(66879);
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
|
class LocalDockerCloudRunner {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
runTask(commands, buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
image,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets) {
|
||||||
|
cloud_runner_logger_1.default.log(buildGuid);
|
||||||
|
cloud_runner_logger_1.default.log(commands);
|
||||||
|
return cloud_runner_system_1.CloudRunnerSystem.Run(commands, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports["default"] = LocalDockerCloudRunner;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 38588:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
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 cloud_runner_system_1 = __nccwpck_require__(66879);
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
|
class LocalCloudRunner {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
runTask(buildGuid, image, commands,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
cloud_runner_logger_1.default.log(image);
|
||||||
|
cloud_runner_logger_1.default.log(buildGuid);
|
||||||
|
cloud_runner_logger_1.default.log(commands);
|
||||||
|
return yield cloud_runner_system_1.CloudRunnerSystem.Run(commands);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports["default"] = LocalCloudRunner;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 71899:
|
/***/ 71899:
|
||||||
|
|
@ -2907,10 +3054,16 @@ const formatFunction = (value, arguments_) => {
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
class CloudRunnerQueryOverride {
|
class CloudRunnerQueryOverride {
|
||||||
static query(key) {
|
static query(key, alternativeKey) {
|
||||||
return CloudRunnerQueryOverride.queryOverrides && CloudRunnerQueryOverride.queryOverrides[key] !== undefined
|
if (CloudRunnerQueryOverride.queryOverrides && CloudRunnerQueryOverride.queryOverrides[key] !== undefined) {
|
||||||
? CloudRunnerQueryOverride.queryOverrides[key]
|
return CloudRunnerQueryOverride.queryOverrides[key];
|
||||||
: undefined;
|
}
|
||||||
|
if (CloudRunnerQueryOverride.queryOverrides &&
|
||||||
|
alternativeKey &&
|
||||||
|
CloudRunnerQueryOverride.queryOverrides[alternativeKey] !== undefined) {
|
||||||
|
return CloudRunnerQueryOverride.queryOverrides[alternativeKey];
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
static shouldUseOverride(query) {
|
static shouldUseOverride(query) {
|
||||||
if (input_1.default.readInputOverrideCommand() !== '') {
|
if (input_1.default.readInputOverrideCommand() !== '') {
|
||||||
|
|
@ -3073,6 +3226,7 @@ class TaskParameterSerializer {
|
||||||
const array = new Array();
|
const array = new Array();
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
|
||||||
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL', 'UNITY_USERNAME');
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
|
||||||
array.push(...image_environment_factory_1.default.getEnvironmentVariables(__1.CloudRunner.buildParameters).map((x) => {
|
array.push(...image_environment_factory_1.default.getEnvironmentVariables(__1.CloudRunner.buildParameters).map((x) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -3089,20 +3243,91 @@ class TaskParameterSerializer {
|
||||||
? cloud_runner_query_override_1.default.queryOverrides[key]
|
? cloud_runner_query_override_1.default.queryOverrides[key]
|
||||||
: process.env[key];
|
: process.env[key];
|
||||||
}
|
}
|
||||||
static tryAddInput(array, key) {
|
static tryAddInput(array, key, override = '') {
|
||||||
if (TaskParameterSerializer.getValue(key) !== undefined) {
|
if (TaskParameterSerializer.getValue(key) !== undefined) {
|
||||||
|
if (override !== '') {
|
||||||
|
array.push({
|
||||||
|
ParameterKey: override,
|
||||||
|
EnvironmentVariable: override,
|
||||||
|
ParameterValue: TaskParameterSerializer.getValue(key),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
array.push({
|
array.push({
|
||||||
ParameterKey: key,
|
ParameterKey: key,
|
||||||
EnvironmentVariable: key,
|
EnvironmentVariable: key,
|
||||||
ParameterValue: TaskParameterSerializer.getValue(key),
|
ParameterValue: TaskParameterSerializer.getValue(key),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.TaskParameterSerializer = TaskParameterSerializer;
|
exports.TaskParameterSerializer = TaskParameterSerializer;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 95449:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
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 cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
|
class TestCloudRunner {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray) { }
|
||||||
|
runTask(commands, buildGuid, image,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
cloud_runner_logger_1.default.log(image);
|
||||||
|
cloud_runner_logger_1.default.log(buildGuid);
|
||||||
|
cloud_runner_logger_1.default.log(commands);
|
||||||
|
return yield new Promise((result) => {
|
||||||
|
result(commands);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports["default"] = TestCloudRunner;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 94655:
|
/***/ 94655:
|
||||||
|
|
@ -3827,24 +4052,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.GitRepoReader = void 0;
|
exports.GitRepoReader = void 0;
|
||||||
const console_1 = __nccwpck_require__(96206);
|
const console_1 = __nccwpck_require__(96206);
|
||||||
const system_1 = __importDefault(__nccwpck_require__(62177));
|
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
const fs_1 = __importDefault(__nccwpck_require__(57147));
|
||||||
const cloud_runner_system_1 = __nccwpck_require__(66879);
|
const cloud_runner_system_1 = __nccwpck_require__(66879);
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
class GitRepoReader {
|
class GitRepoReader {
|
||||||
static GetRemote() {
|
static GetRemote() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true))
|
console_1.assert(fs_1.default.existsSync(`.git`));
|
||||||
.split(' ')[1]
|
const value = (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
|
||||||
.split('https://github.com/')[1]
|
cloud_runner_logger_1.default.log(`value ${value}`);
|
||||||
.split('.git')[0];
|
console_1.assert(value.includes('github.com'));
|
||||||
|
return value.split('github.com/')[1].split('.git')[0];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static GetBranch() {
|
static GetBranch() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
console_1.assert(fs_1.default.existsSync(`.git`));
|
console_1.assert(fs_1.default.existsSync(`.git`));
|
||||||
return (yield system_1.default.run(`git branch`, [], {}, false))
|
return (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git branch --show-current`, false, true))
|
||||||
.split('*')[1]
|
.split('\n')[0]
|
||||||
.split(`\n`)[0]
|
|
||||||
.replace(/ /g, ``)
|
.replace(/ /g, ``)
|
||||||
.replace('/head', '');
|
.replace('/head', '');
|
||||||
});
|
});
|
||||||
|
|
@ -3962,26 +4187,26 @@ const core = __nccwpck_require__(42186);
|
||||||
* 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 {
|
||||||
// also enabled debug logging for cloud runner
|
|
||||||
static get cloudRunnerTests() {
|
|
||||||
return Input.getInput(`cloudRunnerTests`) || Input.getInput(`CloudRunnerTests`) || false;
|
|
||||||
}
|
|
||||||
static getInput(query) {
|
static getInput(query) {
|
||||||
|
if (Input.githubInputEnabled) {
|
||||||
const coreInput = core.getInput(query);
|
const coreInput = core.getInput(query);
|
||||||
if (Input.githubInputEnabled && coreInput && coreInput !== '') {
|
if (coreInput && coreInput !== '') {
|
||||||
return coreInput;
|
return coreInput;
|
||||||
}
|
}
|
||||||
if (cli_1.CLI.query(query)) {
|
|
||||||
return cli_1.CLI.query(query);
|
|
||||||
}
|
}
|
||||||
if (cloud_runner_query_override_1.default.query(query)) {
|
const alternativeQuery = Input.ToEnvVarFormat(query);
|
||||||
return cloud_runner_query_override_1.default.query(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) {
|
if (process.env[query] !== undefined) {
|
||||||
return process.env[query];
|
return process.env[query];
|
||||||
}
|
}
|
||||||
if (Input.ToEnvVarFormat(query) !== query) {
|
if (alternativeQuery !== query && process.env[alternativeQuery] !== undefined) {
|
||||||
return Input.getInput(Input.ToEnvVarFormat(query));
|
return process.env[alternativeQuery];
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
@ -3989,7 +4214,7 @@ class Input {
|
||||||
return Input.getInput('region') || 'eu-west-2';
|
return Input.getInput('region') || 'eu-west-2';
|
||||||
}
|
}
|
||||||
static get githubRepo() {
|
static get githubRepo() {
|
||||||
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || false;
|
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || undefined;
|
||||||
}
|
}
|
||||||
static get branch() {
|
static get branch() {
|
||||||
if (Input.getInput(`GITHUB_REF`)) {
|
if (Input.getInput(`GITHUB_REF`)) {
|
||||||
|
|
@ -4003,7 +4228,14 @@ class Input {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static get cloudRunnerBuilderPlatform() {
|
static get cloudRunnerBuilderPlatform() {
|
||||||
return Input.cloudRunnerCluster === 'local' ? Input.getInput('cloudRunnerBuilderPlatform') || false : 'ubuntu';
|
const input = Input.getInput('cloudRunnerBuilderPlatform');
|
||||||
|
if (input) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
if (this.cloudRunnerCluster) {
|
||||||
|
return 'ubuntu';
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
static get gitSha() {
|
static get gitSha() {
|
||||||
if (Input.getInput(`GITHUB_SHA`)) {
|
if (Input.getInput(`GITHUB_SHA`)) {
|
||||||
|
|
@ -4125,7 +4357,7 @@ class Input {
|
||||||
if (cli_1.CLI.cliMode) {
|
if (cli_1.CLI.cliMode) {
|
||||||
return Input.getInput('cloudRunnerCluster') || 'aws';
|
return Input.getInput('cloudRunnerCluster') || 'aws';
|
||||||
}
|
}
|
||||||
return Input.getInput('cloudRunnerCluster') || 'local';
|
return Input.getInput('cloudRunnerCluster') || false;
|
||||||
}
|
}
|
||||||
static get cloudRunnerCpu() {
|
static get cloudRunnerCpu() {
|
||||||
return Input.getInput('cloudRunnerCpu') || '1.0';
|
return Input.getInput('cloudRunnerCpu') || '1.0';
|
||||||
|
|
@ -4154,6 +4386,9 @@ class Input {
|
||||||
static get cacheKey() {
|
static get cacheKey() {
|
||||||
return Input.getInput('cacheKey') || '';
|
return Input.getInput('cacheKey') || '';
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -17,11 +17,7 @@ async function runMain() {
|
||||||
const buildParameters = await BuildParameters.create();
|
const buildParameters = await BuildParameters.create();
|
||||||
const baseImage = new ImageTag(buildParameters);
|
const baseImage = new ImageTag(buildParameters);
|
||||||
|
|
||||||
if (
|
if (buildParameters.cloudRunnerCluster) {
|
||||||
buildParameters.cloudRunnerCluster &&
|
|
||||||
buildParameters.cloudRunnerCluster !== '' &&
|
|
||||||
buildParameters.cloudRunnerCluster !== 'local'
|
|
||||||
) {
|
|
||||||
await CloudRunner.run(buildParameters, baseImage.toString());
|
await CloudRunner.run(buildParameters, baseImage.toString());
|
||||||
} else {
|
} else {
|
||||||
core.info('Building locally');
|
core.info('Building locally');
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class BuildParameters {
|
||||||
public buildGuid!: string;
|
public buildGuid!: string;
|
||||||
public cloudRunnerBranch!: string;
|
public cloudRunnerBranch!: string;
|
||||||
public cloudRunnerIntegrationTests!: boolean;
|
public cloudRunnerIntegrationTests!: boolean;
|
||||||
public cloudRunnerBuilderPlatform!: string;
|
public cloudRunnerBuilderPlatform!: string | undefined;
|
||||||
public cliMode!: boolean;
|
public cliMode!: boolean;
|
||||||
|
|
||||||
static async create(): Promise<BuildParameters> {
|
static async create(): Promise<BuildParameters> {
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,14 @@ export class CLI {
|
||||||
static get cliMode() {
|
static get cliMode() {
|
||||||
return CLI.options !== undefined && CLI.options.mode !== undefined && CLI.options.mode !== '';
|
return CLI.options !== undefined && CLI.options.mode !== undefined && CLI.options.mode !== '';
|
||||||
}
|
}
|
||||||
public static query(key) {
|
public static query(key, alternativeKey) {
|
||||||
return CLI.cliMode && CLI.options[key] !== undefined ? CLI.options[key] : undefined;
|
if (CLI.options && CLI.options[key] !== undefined) {
|
||||||
|
return CLI.options[key];
|
||||||
|
}
|
||||||
|
if (CLI.options && alternativeKey && CLI.options[alternativeKey] !== undefined) {
|
||||||
|
return CLI.options[alternativeKey];
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InitCliMode() {
|
public static InitCliMode() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { RemoteClientLogger } from './remote-client-logger';
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class CloudRunnerSystem {
|
export class CloudRunnerSystem {
|
||||||
public static async Run(command: string, suppressError = false, suppressLogs = false) {
|
public static async Run(command: string, suppressError = false, suppressLogs = false) {
|
||||||
for (const element of command.split(`\n`)) {
|
for (const element of command.split(`\n`)) {
|
||||||
|
|
@ -8,29 +7,50 @@ export class CloudRunnerSystem {
|
||||||
RemoteClientLogger.log(element);
|
RemoteClientLogger.log(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return await new Promise<string>((promise) => {
|
return await new Promise<string>((promise, throwError) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
const child = exec(command, (error, stdout, stderr) => {
|
const child = exec(command, (error, stdout, stderr) => {
|
||||||
if (error && !suppressError) {
|
if (!suppressError && error) {
|
||||||
throw error;
|
RemoteClientLogger.log(error.toString());
|
||||||
|
throwError(error);
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
|
RemoteClientLogger.log('stderr');
|
||||||
const diagnosticOutput = `${stderr.toString()}`;
|
const diagnosticOutput = `${stderr.toString()}`;
|
||||||
if (!suppressLogs) {
|
if (!suppressLogs) {
|
||||||
RemoteClientLogger.logCliDiagnostic(diagnosticOutput);
|
RemoteClientLogger.logCliDiagnostic(diagnosticOutput);
|
||||||
}
|
}
|
||||||
output += diagnosticOutput;
|
output += diagnosticOutput;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
RemoteClientLogger.log('stdout');
|
||||||
const outputChunk = `${stdout}`;
|
const outputChunk = `${stdout}`;
|
||||||
output += outputChunk;
|
output += outputChunk;
|
||||||
});
|
});
|
||||||
child.on('close', function (code) {
|
child.on('message', (message) => {
|
||||||
|
RemoteClientLogger.log('message');
|
||||||
|
const outputChunk = `${message}`;
|
||||||
|
output += outputChunk;
|
||||||
|
});
|
||||||
|
child.on('error', (error) => {
|
||||||
|
RemoteClientLogger.log('error');
|
||||||
|
RemoteClientLogger.log(error.toString());
|
||||||
|
if (error) {
|
||||||
|
throwError(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.on('disconnect', (error) => {
|
||||||
|
RemoteClientLogger.log('disconnect');
|
||||||
|
if (error) {
|
||||||
|
throwError(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
child.on('close', (code) => {
|
||||||
|
RemoteClientLogger.log('close');
|
||||||
if (!suppressLogs) {
|
if (!suppressLogs) {
|
||||||
RemoteClientLogger.log(`[Exit code ${code}]`);
|
RemoteClientLogger.log(`[Exit code ${code}]`);
|
||||||
}
|
}
|
||||||
if (code !== 0 && !suppressError) {
|
if (code !== 0 && !suppressError) {
|
||||||
throw new Error(output);
|
throwError(output);
|
||||||
}
|
}
|
||||||
const outputLines = output.split(`\n`);
|
const outputLines = output.split(`\n`);
|
||||||
for (const element of outputLines) {
|
for (const element of outputLines) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,50 @@ describe('Cloud Runner', () => {
|
||||||
describe('Cloud Runner', () => {
|
describe('Cloud Runner', () => {
|
||||||
const testSecretName = 'testSecretName';
|
const testSecretName = 'testSecretName';
|
||||||
const testSecretValue = 'testSecretValue';
|
const testSecretValue = 'testSecretValue';
|
||||||
|
it('Local cloud runner returns commands', async () => {
|
||||||
|
// build parameters
|
||||||
|
CLI.options = {
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
|
cloudRunnerCluster: 'local',
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
|
customJob: `
|
||||||
|
- name: 'step 1'
|
||||||
|
image: 'alpine'
|
||||||
|
commands: 'ls'
|
||||||
|
secrets:
|
||||||
|
- name: '${testSecretName}'
|
||||||
|
value: '${testSecretValue}'
|
||||||
|
`,
|
||||||
|
};
|
||||||
|
Input.githubInputEnabled = false;
|
||||||
|
// setup parameters
|
||||||
|
const buildParameter = await BuildParameters.create();
|
||||||
|
const baseImage = new ImageTag(buildParameter);
|
||||||
|
// run the job
|
||||||
|
await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow();
|
||||||
|
Input.githubInputEnabled = true;
|
||||||
|
CLI.options = undefined;
|
||||||
|
}, 1000000);
|
||||||
|
it('Test cloud runner returns commands', async () => {
|
||||||
|
// build parameters
|
||||||
|
CLI.options = {
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
|
cloudRunnerCluster: 'test',
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
|
};
|
||||||
|
Input.githubInputEnabled = false;
|
||||||
|
// setup parameters
|
||||||
|
const buildParameter = await BuildParameters.create();
|
||||||
|
const baseImage = new ImageTag(buildParameter);
|
||||||
|
// run the job
|
||||||
|
await expect(CloudRunner.run(buildParameter, baseImage.toString())).resolves.not.toThrow();
|
||||||
|
Input.githubInputEnabled = true;
|
||||||
|
CLI.options = undefined;
|
||||||
|
}, 1000000);
|
||||||
if (Input.cloudRunnerTests) {
|
if (Input.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
|
||||||
|
|
@ -27,6 +71,7 @@ describe('Cloud Runner', () => {
|
||||||
versioning: 'None',
|
versioning: 'None',
|
||||||
projectPath: 'test-project',
|
projectPath: 'test-project',
|
||||||
unityVersion: UnityVersioning.read('test-project'),
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
customJob: `
|
customJob: `
|
||||||
- name: 'step 1'
|
- name: 'step 1'
|
||||||
image: 'alpine'
|
image: 'alpine'
|
||||||
|
|
@ -58,23 +103,26 @@ describe('Cloud Runner', () => {
|
||||||
expect(newLinePurgedFile).toContain(`${element.name}=${element.value}`);
|
expect(newLinePurgedFile).toContain(`${element.name}=${element.value}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Input.githubInputEnabled = true;
|
CLI.options = undefined;
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
it('Run one build it should not use cache, run subsequent build which should use cache', async () => {
|
it('Run one build it should not use cache, run subsequent build which should use cache', async () => {
|
||||||
CLI.options = {
|
CLI.options = {
|
||||||
versioning: 'None',
|
versioning: 'None',
|
||||||
projectPath: 'test-project',
|
projectPath: 'test-project',
|
||||||
unityVersion: UnityVersioning.read('test-project'),
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
cacheKey: `test-case-${guidGenerator()}`,
|
cacheKey: `test-case-${guidGenerator()}`,
|
||||||
};
|
};
|
||||||
Input.githubInputEnabled = false;
|
Input.githubInputEnabled = false;
|
||||||
const buildParameter = await BuildParameters.create();
|
const buildParameter = await BuildParameters.create();
|
||||||
|
Input.githubInputEnabled = true;
|
||||||
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());
|
||||||
const libraryString = 'Rebuilding Library because the asset database could not be found!';
|
const libraryString = 'Rebuilding Library because the asset database could not be found!';
|
||||||
expect(results).toContain(libraryString);
|
expect(results).toContain(libraryString);
|
||||||
const results2 = await CloudRunner.run(buildParameter, baseImage.toString());
|
const results2 = await CloudRunner.run(buildParameter, baseImage.toString());
|
||||||
expect(results2).toEqual(expect.not.stringContaining(libraryString));
|
expect(results2).toEqual(expect.not.stringContaining(libraryString));
|
||||||
|
CLI.options = undefined;
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import * as core from '@actions/core';
|
||||||
import CloudRunnerSecret from './services/cloud-runner-secret';
|
import CloudRunnerSecret from './services/cloud-runner-secret';
|
||||||
import { CloudRunnerProviderInterface } from './services/cloud-runner-provider-interface';
|
import { CloudRunnerProviderInterface } from './services/cloud-runner-provider-interface';
|
||||||
import CloudRunnerEnvironmentVariable from './services/cloud-runner-environment-variable';
|
import CloudRunnerEnvironmentVariable from './services/cloud-runner-environment-variable';
|
||||||
|
import TestCloudRunner from './test';
|
||||||
|
import LocalCloudRunner from './local';
|
||||||
|
import LocalDockerCloudRunner from './local-docker';
|
||||||
|
|
||||||
class CloudRunner {
|
class CloudRunner {
|
||||||
public static CloudRunnerProviderPlatform: CloudRunnerProviderInterface;
|
public static CloudRunnerProviderPlatform: CloudRunnerProviderInterface;
|
||||||
|
|
@ -30,16 +33,23 @@ class CloudRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static setupBuildPlatform() {
|
private static setupBuildPlatform() {
|
||||||
|
CloudRunnerLogger.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.cloudRunnerCluster}`);
|
||||||
switch (CloudRunner.buildParameters.cloudRunnerCluster) {
|
switch (CloudRunner.buildParameters.cloudRunnerCluster) {
|
||||||
case 'k8s':
|
case 'k8s':
|
||||||
CloudRunnerLogger.log('Cloud Runner platform selected Kubernetes');
|
|
||||||
CloudRunner.CloudRunnerProviderPlatform = new Kubernetes(CloudRunner.buildParameters);
|
CloudRunner.CloudRunnerProviderPlatform = new Kubernetes(CloudRunner.buildParameters);
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
case 'aws':
|
case 'aws':
|
||||||
CloudRunnerLogger.log('Cloud Runner platform selected AWS');
|
|
||||||
CloudRunner.CloudRunnerProviderPlatform = new AWSBuildPlatform(CloudRunner.buildParameters);
|
CloudRunner.CloudRunnerProviderPlatform = new AWSBuildPlatform(CloudRunner.buildParameters);
|
||||||
break;
|
break;
|
||||||
|
case 'test':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new TestCloudRunner();
|
||||||
|
break;
|
||||||
|
case 'local':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new LocalCloudRunner();
|
||||||
|
break;
|
||||||
|
case 'local-docker':
|
||||||
|
CloudRunner.CloudRunnerProviderPlatform = new LocalDockerCloudRunner();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
import BuildParameters from '../../build-parameters';
|
||||||
|
import { CloudRunnerSystem } from '../../cli/remote-client/remote-client-services/cloud-runner-system';
|
||||||
|
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
import { CloudRunnerProviderInterface } from '../services/cloud-runner-provider-interface';
|
||||||
|
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
||||||
|
|
||||||
|
class LocalDockerCloudRunner implements CloudRunnerProviderInterface {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
public runTask(
|
||||||
|
commands: string,
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
image: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment: CloudRunnerEnvironmentVariable[],
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets: CloudRunnerSecret[],
|
||||||
|
): Promise<string> {
|
||||||
|
CloudRunnerLogger.log(buildGuid);
|
||||||
|
CloudRunnerLogger.log(commands);
|
||||||
|
return CloudRunnerSystem.Run(commands, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default LocalDockerCloudRunner;
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
import BuildParameters from '../../build-parameters';
|
||||||
|
import { CloudRunnerSystem } from '../../cli/remote-client/remote-client-services/cloud-runner-system';
|
||||||
|
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
import { CloudRunnerProviderInterface } from '../services/cloud-runner-provider-interface';
|
||||||
|
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
||||||
|
|
||||||
|
class LocalCloudRunner implements CloudRunnerProviderInterface {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
public setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
public async runTask(
|
||||||
|
buildGuid: string,
|
||||||
|
image: string,
|
||||||
|
commands: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment: CloudRunnerEnvironmentVariable[],
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets: CloudRunnerSecret[],
|
||||||
|
): Promise<string> {
|
||||||
|
CloudRunnerLogger.log(image);
|
||||||
|
CloudRunnerLogger.log(buildGuid);
|
||||||
|
CloudRunnerLogger.log(commands);
|
||||||
|
return await CloudRunnerSystem.Run(commands);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default LocalCloudRunner;
|
||||||
|
|
@ -11,10 +11,18 @@ const formatFunction = (value, arguments_) => {
|
||||||
class CloudRunnerQueryOverride {
|
class CloudRunnerQueryOverride {
|
||||||
static queryOverrides: any;
|
static queryOverrides: any;
|
||||||
|
|
||||||
public static query(key) {
|
public static query(key, alternativeKey) {
|
||||||
return CloudRunnerQueryOverride.queryOverrides && CloudRunnerQueryOverride.queryOverrides[key] !== undefined
|
if (CloudRunnerQueryOverride.queryOverrides && CloudRunnerQueryOverride.queryOverrides[key] !== undefined) {
|
||||||
? CloudRunnerQueryOverride.queryOverrides[key]
|
return CloudRunnerQueryOverride.queryOverrides[key];
|
||||||
: undefined;
|
}
|
||||||
|
if (
|
||||||
|
CloudRunnerQueryOverride.queryOverrides &&
|
||||||
|
alternativeKey &&
|
||||||
|
CloudRunnerQueryOverride.queryOverrides[alternativeKey] !== undefined
|
||||||
|
) {
|
||||||
|
return CloudRunnerQueryOverride.queryOverrides[alternativeKey];
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static shouldUseOverride(query) {
|
private static shouldUseOverride(query) {
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ export class TaskParameterSerializer {
|
||||||
const array = new Array();
|
const array = new Array();
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_SERIAL');
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL');
|
||||||
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_EMAIL', 'UNITY_USERNAME');
|
||||||
TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
|
TaskParameterSerializer.tryAddInput(array, 'UNITY_PASSWORD');
|
||||||
array.push(
|
array.push(
|
||||||
...ImageEnvironmentFactory.getEnvironmentVariables(CloudRunner.buildParameters).map((x) => {
|
...ImageEnvironmentFactory.getEnvironmentVariables(CloudRunner.buildParameters).map((x) => {
|
||||||
|
|
@ -92,14 +93,22 @@ export class TaskParameterSerializer {
|
||||||
? CloudRunnerQueryOverride.queryOverrides[key]
|
? CloudRunnerQueryOverride.queryOverrides[key]
|
||||||
: process.env[key];
|
: process.env[key];
|
||||||
}
|
}
|
||||||
private static tryAddInput(array, key): CloudRunnerSecret[] {
|
private static tryAddInput(array, key, override = ''): CloudRunnerSecret[] {
|
||||||
if (TaskParameterSerializer.getValue(key) !== undefined) {
|
if (TaskParameterSerializer.getValue(key) !== undefined) {
|
||||||
|
if (override !== '') {
|
||||||
|
array.push({
|
||||||
|
ParameterKey: override,
|
||||||
|
EnvironmentVariable: override,
|
||||||
|
ParameterValue: TaskParameterSerializer.getValue(key),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
array.push({
|
array.push({
|
||||||
ParameterKey: key,
|
ParameterKey: key,
|
||||||
EnvironmentVariable: key,
|
EnvironmentVariable: key,
|
||||||
ParameterValue: TaskParameterSerializer.getValue(key),
|
ParameterValue: TaskParameterSerializer.getValue(key),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import BuildParameters from '../../build-parameters';
|
||||||
|
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
import { CloudRunnerProviderInterface } from '../services/cloud-runner-provider-interface';
|
||||||
|
import CloudRunnerSecret from '../services/cloud-runner-secret';
|
||||||
|
|
||||||
|
class TestCloudRunner implements CloudRunnerProviderInterface {
|
||||||
|
cleanupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
setupSharedResources(
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildGuid: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
buildParameters: BuildParameters,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
branchName: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
|
||||||
|
) {}
|
||||||
|
public async runTask(
|
||||||
|
commands: string,
|
||||||
|
buildGuid: string,
|
||||||
|
image: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
mountdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
workingdir: string,
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
environment: CloudRunnerEnvironmentVariable[],
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
secrets: CloudRunnerSecret[],
|
||||||
|
): Promise<string> {
|
||||||
|
CloudRunnerLogger.log(image);
|
||||||
|
CloudRunnerLogger.log(buildGuid);
|
||||||
|
CloudRunnerLogger.log(commands);
|
||||||
|
return await new Promise((result) => {
|
||||||
|
result(commands);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default TestCloudRunner;
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import { assert } from 'console';
|
import { assert } from 'console';
|
||||||
import System from '../system';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { CloudRunnerSystem } from '../cli/remote-client/remote-client-services/cloud-runner-system';
|
import { CloudRunnerSystem } from '../cli/remote-client/remote-client-services/cloud-runner-system';
|
||||||
|
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
|
||||||
|
|
||||||
export class GitRepoReader {
|
export class GitRepoReader {
|
||||||
public static async GetRemote() {
|
public static async GetRemote() {
|
||||||
return (await CloudRunnerSystem.Run(`git remote -v`, false, true))
|
assert(fs.existsSync(`.git`));
|
||||||
.split(' ')[1]
|
const value = (await CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
|
||||||
.split('https://github.com/')[1]
|
CloudRunnerLogger.log(`value ${value}`);
|
||||||
.split('.git')[0];
|
assert(value.includes('github.com'));
|
||||||
|
return value.split('github.com/')[1].split('.git')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async GetBranch() {
|
public static async GetBranch() {
|
||||||
assert(fs.existsSync(`.git`));
|
assert(fs.existsSync(`.git`));
|
||||||
return (await System.run(`git branch`, [], {}, false))
|
return (await CloudRunnerSystem.Run(`git branch --show-current`, false, true))
|
||||||
.split('*')[1]
|
.split('\n')[0]
|
||||||
.split(`\n`)[0]
|
|
||||||
.replace(/ /g, ``)
|
.replace(/ /g, ``)
|
||||||
.replace('/head', '');
|
.replace('/head', '');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,31 +16,27 @@ const core = require('@actions/core');
|
||||||
class Input {
|
class Input {
|
||||||
public static githubInputEnabled: boolean = true;
|
public static githubInputEnabled: boolean = true;
|
||||||
|
|
||||||
// also enabled debug logging for cloud runner
|
|
||||||
static get cloudRunnerTests(): boolean {
|
|
||||||
return Input.getInput(`cloudRunnerTests`) || Input.getInput(`CloudRunnerTests`) || false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getInput(query) {
|
public static getInput(query) {
|
||||||
|
if (Input.githubInputEnabled) {
|
||||||
const coreInput = core.getInput(query);
|
const coreInput = core.getInput(query);
|
||||||
if (Input.githubInputEnabled && coreInput && coreInput !== '') {
|
if (coreInput && coreInput !== '') {
|
||||||
return coreInput;
|
return coreInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLI.query(query)) {
|
|
||||||
return CLI.query(query);
|
|
||||||
}
|
}
|
||||||
|
const alternativeQuery = Input.ToEnvVarFormat(query);
|
||||||
|
|
||||||
if (CloudRunnerQueryOverride.query(query)) {
|
// query input sources
|
||||||
return CloudRunnerQueryOverride.query(query);
|
if (CLI.query(query, alternativeQuery)) {
|
||||||
|
return CLI.query(query, alternativeQuery);
|
||||||
|
}
|
||||||
|
if (CloudRunnerQueryOverride.query(query, alternativeQuery)) {
|
||||||
|
return CloudRunnerQueryOverride.query(query, alternativeQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env[query] !== undefined) {
|
if (process.env[query] !== undefined) {
|
||||||
return process.env[query];
|
return process.env[query];
|
||||||
}
|
}
|
||||||
|
if (alternativeQuery !== query && process.env[alternativeQuery] !== undefined) {
|
||||||
if (Input.ToEnvVarFormat(query) !== query) {
|
return process.env[alternativeQuery];
|
||||||
return Input.getInput(Input.ToEnvVarFormat(query));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|
@ -51,7 +47,7 @@ class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
static get githubRepo() {
|
static get githubRepo() {
|
||||||
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || false;
|
return Input.getInput('GITHUB_REPOSITORY') || Input.getInput('GITHUB_REPO') || undefined;
|
||||||
}
|
}
|
||||||
static get branch() {
|
static get branch() {
|
||||||
if (Input.getInput(`GITHUB_REF`)) {
|
if (Input.getInput(`GITHUB_REF`)) {
|
||||||
|
|
@ -63,7 +59,14 @@ class Input {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static get cloudRunnerBuilderPlatform() {
|
static get cloudRunnerBuilderPlatform() {
|
||||||
return Input.cloudRunnerCluster === 'local' ? Input.getInput('cloudRunnerBuilderPlatform') || false : 'ubuntu';
|
const input = Input.getInput('cloudRunnerBuilderPlatform');
|
||||||
|
if (input) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
if (this.cloudRunnerCluster) {
|
||||||
|
return 'ubuntu';
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get gitSha() {
|
static get gitSha() {
|
||||||
|
|
@ -222,7 +225,7 @@ class Input {
|
||||||
if (CLI.cliMode) {
|
if (CLI.cliMode) {
|
||||||
return Input.getInput('cloudRunnerCluster') || 'aws';
|
return Input.getInput('cloudRunnerCluster') || 'aws';
|
||||||
}
|
}
|
||||||
return Input.getInput('cloudRunnerCluster') || 'local';
|
return Input.getInput('cloudRunnerCluster') || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static get cloudRunnerCpu() {
|
static get cloudRunnerCpu() {
|
||||||
|
|
@ -261,6 +264,10 @@ class Input {
|
||||||
return Input.getInput('cacheKey') || '';
|
return Input.getInput('cacheKey') || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue