Refactor CLI/cleanup

pull/310/head
Frostebite 2021-12-25 20:05:17 +00:00
parent b4618a7e68
commit c5d3bc59ff
12 changed files with 137 additions and 52 deletions

View File

@ -57,7 +57,7 @@ jobs:
AWS_DEFAULT_REGION: eu-west-2
CloudRunnerBranch: remote-builder/unified-providers
DEBUG: true
remoteBuilderIntegrationTests: true
CloudRunnerTests: true
cloudRunnerCluster: aws
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}

View File

@ -60,7 +60,7 @@ jobs:
AWS_DEFAULT_REGION: eu-west-2
CloudRunnerBranch: remote-builder/unified-providers
DEBUG: true
remoteBuilderIntegrationTests: true
CloudRunnerTests: true
cloudRunnerCluster: k8s
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}

View File

@ -0,0 +1,96 @@
[Cloud-Runner-Agent] awsStackName=game-ci-3-test
[Cloud-Runner-Agent] androidKeystoreBase64=
[Cloud-Runner-Agent] androidKeystorePass=
[Cloud-Runner-Agent] ANDROID_VERSION_CODE=0
[Cloud-Runner-Agent] kubeConfig=
[Cloud-Runner-Agent] customImage=false
[Cloud-Runner-Agent] HOSTNAME=ip-10-0-0-92.eu-west-2.compute.internal
[Cloud-Runner-Agent] remoteBuildCluster=
[Cloud-Runner-Agent] BUILDID=0-windows64-7zhj
[Cloud-Runner-Agent] androidKeyaliasPass=
[Cloud-Runner-Agent] SHLVL=1
[Cloud-Runner-Agent] githubRepo=game-ci/unity-builder
[Cloud-Runner-Agent] branch=remote-builder/unified-providers
[Cloud-Runner-Agent] HOME=/root
[Cloud-Runner-Agent] cloudRunnerCpu=1.0
[Cloud-Runner-Agent] cloudRunnerTests=true
[Cloud-Runner-Agent] versioningStrategy=None
[Cloud-Runner-Agent] platform=StandaloneWindows64
[Cloud-Runner-Agent] ANDROID_KEYSTORE_NAME=
[Cloud-Runner-Agent] githubEnabled=false
[Cloud-Runner-Agent] buildPathFull=/data/0-windows64-7zhj
[Cloud-Runner-Agent] version=2019.2.11f1
[Cloud-Runner-Agent] region=eu-west-2
[Cloud-Runner-Agent] AWS_EXECUTION_ENV=AWS_ECS_FARGATE
[Cloud-Runner-Agent] specifiedVersion=
[Cloud-Runner-Agent] runNumber=0
[Cloud-Runner-Agent] chownFilesTo=
[Cloud-Runner-Agent] BUILD_FILE=StandaloneWindows64.exe
[Cloud-Runner-Agent] ANDROID_KEYALIAS_NAME=
[Cloud-Runner-Agent] BUILD_NAME=StandaloneWindows64
[Cloud-Runner-Agent] buildMethod=
[Cloud-Runner-Agent] VERSION=none
[Cloud-Runner-Agent] logToFile=true
[Cloud-Runner-Agent] AWS_DEFAULT_REGION=eu-west-2
[Cloud-Runner-Agent] runnerTempPath=undefined
[Cloud-Runner-Agent] sshAgent=
[Cloud-Runner-Agent] androidVersionCode=false
[Cloud-Runner-Agent] androidKeystoreName=
[Cloud-Runner-Agent] gitPrivateToken=
[Cloud-Runner-Agent] BUILD_METHOD=
[Cloud-Runner-Agent] ECS_CONTAINER_METADATA_URI_V4=http://169.254.170.2/v4/606b4f3707824e329480a612293343cb-1854725462
[Cloud-Runner-Agent] customParameters=
[Cloud-Runner-Agent] CUSTOM_PARAMETERS=
[Cloud-Runner-Agent] steamPathFull=/data/0-windows64-7zhj/steam
[Cloud-Runner-Agent] kubeVolumeSize=5Gi
[Cloud-Runner-Agent] ECS_CONTAINER_METADATA_URI=http://169.254.170.2/v3/606b4f3707824e329480a612293343cb-1854725462
[Cloud-Runner-Agent] buildParameters={"version":"2019.2.11f1","customImage":false,"platform":"StandaloneWindows64","projectPath":"test-project","buildName":"StandaloneWindows64","buildPath":"build/StandaloneWindows64","buildFile":"StandaloneWindows64.exe","buildMethod":"","buildVersion":"none","androidVersionCode":0,"androidKeystoreName":"","androidKeystoreBase64":"","androidKeystorePass":"","androidKeyaliasName":"","androidKeyaliasPass":"","androidTargetSdkVersion":"","androidSdkManagerParameters":"","customParameters":"","sshAgent":"","gitPrivateToken":"","chownFilesTo":"","cloudRunnerCluster":"","awsBaseStackName":"game-ci-3-test","kubeConfig":"","githubToken":"","cloudRunnerMemory":"750M","cloudRunnerCpu":"1.0","kubeVolumeSize":"5Gi","kubeVolume":"","postBuildSteps":"","preBuildSteps":"","customBuildSteps":"\n - name: 'step 1'\n image: 'alpine'\n commands: ['printenv']\n secrets:\n - name: 'testSecretName'\n value: 'testSecretValue'\n ","runNumber":"0","branch":"remote-builder/unified-providers","githubRepo":"game-ci/unity-builder","logToFile":true,"remoteBuildCluster":"","awsStackName":"game-ci-3-test"}
[Cloud-Runner-Agent] cloudRunnerCluster=
[Cloud-Runner-Agent] repoPathFull=/data/0-windows64-7zhj/repo
[Cloud-Runner-Agent] PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[Cloud-Runner-Agent] androidAppBundle=false
[Cloud-Runner-Agent] libraryFolderFull=/data/0-windows64-7zhj/repo/test-project/Library
[Cloud-Runner-Agent] androidKeyaliasName=
[Cloud-Runner-Agent] preBuildSteps=
[Cloud-Runner-Agent] projectPath=test-project
[Cloud-Runner-Agent] buildFile=StandaloneWindows64.exe
[Cloud-Runner-Agent] ContainerMemory=750M
[Cloud-Runner-Agent] buildName=StandaloneWindows64
[Cloud-Runner-Agent] unityVersion=auto
[Cloud-Runner-Agent] BUILD_TARGET=StandaloneWindows64
[Cloud-Runner-Agent] targetPlatform=StandaloneWindows64
[Cloud-Runner-Agent] ALLOW_EMPTY_PASSWORD=yes
[Cloud-Runner-Agent] BUILD_PATH=build/StandaloneWindows64
[Cloud-Runner-Agent] testSecretName=testSecretValue
[Cloud-Runner-Agent] PROJECT_PATH=test-project
[Cloud-Runner-Agent] AWS_REGION=eu-west-2
[Cloud-Runner-Agent] awsBaseStackName=game-ci-3-test
[Cloud-Runner-Agent] GITHUB_WORKSPACE=/github/workspace
[Cloud-Runner-Agent] length=0
[Cloud-Runner-Agent] buildVersion=none
[Cloud-Runner-Agent] builderPathFull=/data/0-windows64-7zhj/builder
[Cloud-Runner-Agent] cliOptions=[object Object]
[Cloud-Runner-Agent] androidSdkManagerParameters=
[Cloud-Runner-Agent] cloudRunnerMemory=750M
[Cloud-Runner-Agent] name=Input
[Cloud-Runner-Agent] postBuildSteps=
[Cloud-Runner-Agent] gitSha=undefined
[Cloud-Runner-Agent] PWD=/data
[Cloud-Runner-Agent] allowDirtyBuild=false
[Cloud-Runner-Agent] buildsPath=build
[Cloud-Runner-Agent] githubToken=
[Cloud-Runner-Agent] UNITY_VERSION=2019.2.11f1
[Cloud-Runner-Agent] androidTargetSdkVersion=
[Cloud-Runner-Agent] buildPath=build/StandaloneWindows64
[Cloud-Runner-Agent] projectPathFull=/data/0-windows64-7zhj/repo/test-project
[Cloud-Runner-Agent] kubeVolume=
[Cloud-Runner-Agent] prototype=[object Object]
[Cloud-Runner-Agent] customBuildSteps=
[Cloud-Runner-Agent] - name: 'step 1'
[Cloud-Runner-Agent] image: 'alpine'
[Cloud-Runner-Agent] commands: ['printenv']
[Cloud-Runner-Agent] secrets:
[Cloud-Runner-Agent] - name: 'testSecretName'
[Cloud-Runner-Agent] value: 'testSecretValue'
[Cloud-Runner-Agent]
[Cloud-Runner-Agent] ContainerCpu=1.0

43
dist/index.js vendored
View File

@ -381,12 +381,12 @@ exports.CLI = void 0;
const commander_ts_1 = __webpack_require__(40451);
const __1 = __webpack_require__(41359);
const core = __importStar(__webpack_require__(42186));
const cloud_runner_client_1 = __webpack_require__(74462);
const remote_client_1 = __webpack_require__(95575);
class CLI {
static RunCli(options) {
return __awaiter(this, void 0, void 0, function* () {
if (options.mode === 'remote-cli') {
yield cloud_runner_client_1.RemoteClient.Run(options);
yield remote_client_1.RemoteClient.Run(options);
}
else {
options.versioning = 'None';
@ -430,7 +430,7 @@ exports.CLI = CLI;
/***/ }),
/***/ 74462:
/***/ 95575:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
@ -447,7 +447,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RemoteClient = void 0;
const cloud_runner_state_1 = __webpack_require__(70912);
const setup_remote_repository_1 = __webpack_require__(40601);
const setup_remote_repository_1 = __webpack_require__(62100);
class RemoteClient {
static Run(options) {
return __awaiter(this, void 0, void 0, function* () {
@ -466,7 +466,7 @@ exports.RemoteClient = RemoteClient;
/***/ }),
/***/ 21227:
/***/ 91269:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
@ -485,25 +485,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.RemoteClientSystem = void 0;
const child_process_1 = __webpack_require__(63129);
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const system_1 = __importDefault(__webpack_require__(62177));
class RemoteClientSystem {
static Run(command) {
return __awaiter(this, void 0, void 0, function* () {
return yield new Promise((promise) => {
child_process_1.exec(command, (error, stdout, stderr) => {
if (error) {
cloud_runner_logger_1.default.logRemoteCli(`[ERROR] ${error.message}`);
throw new Error(error.toString());
}
if (stderr) {
cloud_runner_logger_1.default.logRemoteCli(`[STD-ERROR] ${stderr.toString()}`);
throw new Error(stderr.toString());
}
cloud_runner_logger_1.default.logRemoteCli(`${stdout.toString()}`);
promise(stdout.toString());
});
});
try {
const result = yield system_1.default.run(command);
cloud_runner_logger_1.default.logRemoteCli(`${result}`);
return result;
}
catch (error) {
cloud_runner_logger_1.default.logRemoteCli(`[ERROR] (${command}) ${error}`);
throw error;
}
});
}
}
@ -512,7 +507,7 @@ exports.RemoteClientSystem = RemoteClientSystem;
/***/ }),
/***/ 40601:
/***/ 62100:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
@ -535,7 +530,7 @@ const fs_1 = __importDefault(__webpack_require__(35747));
const path_1 = __importDefault(__webpack_require__(85622));
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
const cloud_runner_state_1 = __webpack_require__(70912);
const remote_client_system_1 = __webpack_require__(21227);
const remote_client_system_1 = __webpack_require__(91269);
class SetupRemoteRepository {
static run() {
return __awaiter(this, void 0, void 0, function* () {
@ -3357,8 +3352,8 @@ const core = __webpack_require__(42186);
* Note that input is always passed as a string, even booleans.
*/
class Input {
static get remoteBuilderIntegrationTests() {
return Input.getInput(`remoteBuilderIntegrationTests`) || Input.getInput(`remoteBuilderTests`);
static get cloudRunnerTests() {
return Input.getInput(`CloudRunnerTests`) || false;
}
static getInput(query) {
return Input.githubEnabled

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
import { Command } from 'commander-ts';
import { BuildParameters, CloudRunner, ImageTag, Input } from '..';
import * as core from '@actions/core';
import { RemoteClient } from './cloud-runner-client';
import { RemoteClient } from './remote-client';
export class CLI {
static async RunCli(options: any) {

View File

@ -1,21 +0,0 @@
import { exec } from 'child_process';
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
export class RemoteClientSystem {
public static async Run(command: string) {
return await new Promise<string>((promise) => {
exec(command, (error, stdout, stderr) => {
if (error) {
CloudRunnerLogger.logRemoteCli(`[ERROR] ${error.message}`);
throw new Error(error.toString());
}
if (stderr) {
CloudRunnerLogger.logRemoteCli(`[STD-ERROR] ${stderr.toString()}`);
throw new Error(stderr.toString());
}
CloudRunnerLogger.logRemoteCli(`${stdout.toString()}`);
promise(stdout.toString());
});
});
}
}

View File

@ -0,0 +1,15 @@
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
import System from '../../system';
export class RemoteClientSystem {
public static async Run(command: string) {
try {
const result = await System.run(command);
CloudRunnerLogger.logRemoteCli(`${result}`);
return result;
} catch (error) {
CloudRunnerLogger.logRemoteCli(`[ERROR] (${command}) ${error}`);
throw error;
}
}
}

View File

@ -25,7 +25,7 @@ describe('Cloud Runner', () => {
};
Input.githubEnabled = false;
it('All build parameters sent to cloud runner as env vars', async () => {
if (Input.remoteBuilderIntegrationTests) {
if (Input.cloudRunnerTests) {
const buildParameter = await BuildParameters.create();
buildParameter.logToFile = true;
const baseImage = new ImageTag(buildParameter);

View File

@ -10,8 +10,8 @@ const core = require('@actions/core');
class Input {
public static githubEnabled = true;
public static cliOptions;
static get remoteBuilderIntegrationTests(): boolean {
return Input.getInput(`remoteBuilderIntegrationTests`) || Input.getInput(`remoteBuilderTests`);
static get cloudRunnerTests(): boolean {
return Input.getInput(`CloudRunnerTests`) || false;
}
private static getInput(query) {
return Input.githubEnabled