PR comments

pull/353/head
Frostebite 2022-04-10 23:01:03 +01:00
parent a28bf4fc3a
commit f2a9adf736
38 changed files with 701 additions and 665 deletions

955
dist/index.js vendored

File diff suppressed because it is too large Load Diff

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import { Action, BuildParameters, Cache, Docker, ImageTag, Output, CloudRunner } from './model'; import { Action, BuildParameters, Cache, Docker, ImageTag, Output, CloudRunner } from './model';
import { CLI } from './model/cli/cli'; import { Cli } from './model/cli/cli';
import MacBuilder from './model/mac-builder'; import MacBuilder from './model/mac-builder';
import PlatformSetup from './model/platform-setup'; import PlatformSetup from './model/platform-setup';
async function runMain() { async function runMain() {
try { try {
if (CLI.InitCliMode()) { if (Cli.InitCliMode()) {
await CLI.RunCli(); await Cli.RunCli();
return; return;
} }
Action.checkCompatibility(); Action.checkCompatibility();

View File

@ -8,7 +8,7 @@ import UnityVersioning from './unity-versioning';
import Versioning from './versioning'; 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';
class BuildParameters { class BuildParameters {
public editorVersion!: string; public editorVersion!: string;
@ -64,7 +64,7 @@ class BuildParameters {
public cloudRunnerBranch!: string; public cloudRunnerBranch!: string;
public cloudRunnerIntegrationTests!: boolean; public cloudRunnerIntegrationTests!: boolean;
public cloudRunnerBuilderPlatform!: string | undefined; public cloudRunnerBuilderPlatform!: string | undefined;
public cliMode!: boolean; public isCliMode!: boolean;
static async create(): Promise<BuildParameters> { static async create(): Promise<BuildParameters> {
const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidAppBundle); const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidAppBundle);
@ -76,7 +76,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 && CLI.options === undefined) { if (!process.env.UNITY_SERIAL && Input.githubInputEnabled && Cli.options === undefined) {
//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
@ -130,7 +130,7 @@ class BuildParameters {
cloudRunnerBranch: Input.cloudRunnerBranch.split('/').reverse()[0], cloudRunnerBranch: Input.cloudRunnerBranch.split('/').reverse()[0],
cloudRunnerIntegrationTests: Input.cloudRunnerTests, cloudRunnerIntegrationTests: Input.cloudRunnerTests,
githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder', githubRepo: Input.githubRepo || (await GitRepoReader.GetRemote()) || 'game-ci/unity-builder',
cliMode: CLI.cliMode, isCliMode: Cli.isCliMode,
awsStackName: Input.awsBaseStackName, awsStackName: Input.awsBaseStackName,
gitSha: Input.gitSha, gitSha: Input.gitSha,
logId: customAlphabet(CloudRunnerConstants.alphabet, 9)(), logId: customAlphabet(CloudRunnerConstants.alphabet, 9)(),

View File

@ -1,4 +1,4 @@
export class CLIFunctionsRepository { export class CliFunctionsRepository {
private static targets: any[] = []; private static targets: any[] = [];
public static PushCliFunction( public static PushCliFunction(
target: any, target: any,
@ -7,7 +7,7 @@ export class CLIFunctionsRepository {
key: string, key: string,
description: string, description: string,
) { ) {
CLIFunctionsRepository.targets.push({ CliFunctionsRepository.targets.push({
target, target,
propertyKey, propertyKey,
descriptor, descriptor,
@ -15,27 +15,30 @@ export class CLIFunctionsRepository {
description, description,
}); });
} }
public static GetCliFunctions(key) { public static GetCliFunctions(key) {
const results = CLIFunctionsRepository.targets.find((x) => x.key === key); const results = CliFunctionsRepository.targets.find((x) => x.key === key);
if (results === undefined || results.length === 0) { if (results === undefined || results.length === 0) {
throw new Error(`no CLI mode found for ${key}`); throw new Error(`no CLI mode found for ${key}`);
} }
return results; return results;
} }
public static GetAllCliModes() { public static GetAllCliModes() {
return CLIFunctionsRepository.targets.map((x) => { return CliFunctionsRepository.targets.map((x) => {
return { return {
key: x.key, key: x.key,
description: x.description, description: x.description,
}; };
}); });
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
public static PushCliFunctionSource(cliFunction: any) {} public static PushCliFunctionSource(cliFunction: any) {}
} }
export function CliFunction(key: string, description: string) { export function CliFunction(key: string, description: string) {
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => { return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
CLIFunctionsRepository.PushCliFunction(target, propertyKey, descriptor, key, description); CliFunctionsRepository.PushCliFunction(target, propertyKey, descriptor, key, description);
}; };
} }

View File

@ -4,32 +4,32 @@ import * as core from '@actions/core';
import { ActionYamlReader } from '../input-readers/action-yaml'; import { ActionYamlReader } from '../input-readers/action-yaml';
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger'; import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
import CloudRunnerQueryOverride from '../cloud-runner/services/cloud-runner-query-override'; import CloudRunnerQueryOverride from '../cloud-runner/services/cloud-runner-query-override';
import { CliFunction, CLIFunctionsRepository } from './cli-functions-repository'; import { CliFunction, CliFunctionsRepository } from './cli-functions-repository';
import { AWSCLICommands } from '../cloud-runner/cloud-runner-providers/aws/commands/aws-cli-commands'; import { AwsCliCommands } from '../cloud-runner/providers/aws/commands/aws-cli-commands';
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 { SetupCloudRunnerRepository } from '../cloud-runner/remote-client/setup-cloud-runner-repository'; import { RemoteClient } from '../cloud-runner/remote-client';
export class CLI { export class Cli {
public static options; public static options;
static get cliMode() { 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 !== '';
} }
public static query(key, alternativeKey) { public static query(key, alternativeKey) {
if (CLI.options && CLI.options[key] !== undefined) { if (Cli.options && Cli.options[key] !== undefined) {
return CLI.options[key]; return Cli.options[key];
} }
if (CLI.options && alternativeKey && CLI.options[alternativeKey] !== undefined) { if (Cli.options && alternativeKey && Cli.options[alternativeKey] !== undefined) {
return CLI.options[alternativeKey]; return Cli.options[alternativeKey];
} }
return; return;
} }
public static InitCliMode() { public static InitCliMode() {
CLIFunctionsRepository.PushCliFunctionSource(AWSCLICommands); CliFunctionsRepository.PushCliFunctionSource(AwsCliCommands);
CLIFunctionsRepository.PushCliFunctionSource(Caching); CliFunctionsRepository.PushCliFunctionSource(Caching);
CLIFunctionsRepository.PushCliFunctionSource(LFSHashing); CliFunctionsRepository.PushCliFunctionSource(LfsHashing);
CLIFunctionsRepository.PushCliFunctionSource(SetupCloudRunnerRepository); 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 = Object.getOwnPropertyNames(Input);
@ -39,7 +39,7 @@ export class CLI {
} }
program.option( program.option(
'-m, --mode <mode>', '-m, --mode <mode>',
CLIFunctionsRepository.GetAllCliModes() CliFunctionsRepository.GetAllCliModes()
.map((x) => `${x.key} (${x.description})`) .map((x) => `${x.key} (${x.description})`)
.join(` | `), .join(` | `),
); );
@ -48,19 +48,19 @@ export class CLI {
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder'); program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
program.option('--artifactName <artifactName>', 'caching artifact name'); program.option('--artifactName <artifactName>', 'caching artifact name');
program.parse(process.argv); program.parse(process.argv);
CLI.options = program.opts(); Cli.options = program.opts();
return CLI.cliMode; return Cli.isCliMode;
} }
static async RunCli(): Promise<void> { static async RunCli(): Promise<void> {
Input.githubInputEnabled = false; Input.githubInputEnabled = false;
if (CLI.options['populateOverride'] === `true`) { if (Cli.options['populateOverride'] === `true`) {
await CloudRunnerQueryOverride.PopulateQueryOverrideInput(); await CloudRunnerQueryOverride.PopulateQueryOverrideInput();
} }
CLI.logInput(); Cli.logInput();
const results = CLIFunctionsRepository.GetCliFunctions(CLI.options.mode); const results = CliFunctionsRepository.GetCliFunctions(Cli.options.mode);
CloudRunnerLogger.log(`Entrypoint: ${results.key}`); CloudRunnerLogger.log(`Entrypoint: ${results.key}`);
CLI.options.versioning = 'None'; Cli.options.versioning = 'None';
return await results.target[results.propertyKey](); return await results.target[results.propertyKey]();
} }

View File

@ -4,7 +4,7 @@ import Input from '../input';
import { CloudRunnerStatics } from './cloud-runner-statics'; import { CloudRunnerStatics } from './cloud-runner-statics';
import { TaskParameterSerializer } from './services/task-parameter-serializer'; import { TaskParameterSerializer } from './services/task-parameter-serializer';
import UnityVersioning from '../unity-versioning'; 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';
function guid() { function guid() {
@ -24,7 +24,7 @@ describe('Cloud Runner', () => {
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
CLI.options = { Cli.options = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
unityVersion: UnityVersioning.read('test-project'), unityVersion: UnityVersioning.read('test-project'),
@ -66,10 +66,10 @@ describe('Cloud Runner', () => {
expect(newLinePurgedFile).toContain(`${element.name}=${element.value}`); expect(newLinePurgedFile).toContain(`${element.name}=${element.value}`);
} }
} }
delete CLI.options; delete Cli.options;
}, 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.determineUnityVersion('test-project', UnityVersioning.read('test-project')), unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
@ -92,12 +92,12 @@ describe('Cloud Runner', () => {
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; Input.githubInputEnabled = true;
delete CLI.options; delete Cli.options;
}, 1000000); }, 1000000);
} }
it('Local cloud runner returns commands', async () => { it('Local cloud runner returns commands', async () => {
// build parameters // build parameters
CLI.options = { Cli.options = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
unityVersion: UnityVersioning.read('test-project'), unityVersion: UnityVersioning.read('test-project'),
@ -119,11 +119,11 @@ 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; Input.githubInputEnabled = true;
delete CLI.options; delete Cli.options;
}, 1000000); }, 1000000);
it('Test cloud runner returns commands', async () => { it('Test cloud runner returns commands', async () => {
// build parameters // build parameters
CLI.options = { Cli.options = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
unityVersion: UnityVersioning.read('test-project'), unityVersion: UnityVersioning.read('test-project'),
@ -137,6 +137,6 @@ 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; Input.githubInputEnabled = true;
delete CLI.options; delete Cli.options;
}, 1000000); }, 1000000);
}); });

View File

@ -1,6 +1,6 @@
import AWSBuildPlatform from './cloud-runner-providers/aws'; import AwsBuildPlatform from './providers/aws';
import { BuildParameters, Input } from '..'; import { BuildParameters, Input } from '..';
import Kubernetes from './cloud-runner-providers/k8s'; import Kubernetes from './providers/k8s';
import CloudRunnerLogger from './services/cloud-runner-logger'; import CloudRunnerLogger from './services/cloud-runner-logger';
import { CloudRunnerStepState } from './cloud-runner-step-state'; import { CloudRunnerStepState } from './cloud-runner-step-state';
import { WorkflowCompositionRoot } from './workflows/workflow-composition-root'; import { WorkflowCompositionRoot } from './workflows/workflow-composition-root';
@ -8,14 +8,14 @@ import { CloudRunnerError } from './error/cloud-runner-error';
import { TaskParameterSerializer } from './services/task-parameter-serializer'; import { TaskParameterSerializer } from './services/task-parameter-serializer';
import * as core from '@actions/core'; import * as core from '@actions/core';
import CloudRunnerSecret from './services/cloud-runner-secret'; import CloudRunnerSecret from './services/cloud-runner-secret';
import { CloudRunnerProviderInterface } from './cloud-runner-providers/cloud-runner-provider-interface'; import { ProviderInterface } from './providers/provider-interface';
import CloudRunnerEnvironmentVariable from './services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from './services/cloud-runner-environment-variable';
import TestCloudRunner from './cloud-runner-providers/test'; import TestCloudRunner from './providers/test';
import LocalCloudRunner from './cloud-runner-providers/local'; import LocalCloudRunner from './providers/local';
import LocalDockerCloudRunner from './cloud-runner-providers/local-docker'; import LocalDockerCloudRunner from './providers/local-docker';
class CloudRunner { class CloudRunner {
public static CloudRunnerProviderPlatform: CloudRunnerProviderInterface; public static Provider: ProviderInterface;
static buildParameters: BuildParameters; static buildParameters: BuildParameters;
public static defaultSecrets: CloudRunnerSecret[]; public static defaultSecrets: CloudRunnerSecret[];
public static cloudRunnerEnvironmentVariables: CloudRunnerEnvironmentVariable[]; public static cloudRunnerEnvironmentVariables: CloudRunnerEnvironmentVariable[];
@ -25,7 +25,7 @@ class CloudRunner {
CloudRunner.setupBuildPlatform(); CloudRunner.setupBuildPlatform();
CloudRunner.defaultSecrets = TaskParameterSerializer.readDefaultSecrets(); CloudRunner.defaultSecrets = TaskParameterSerializer.readDefaultSecrets();
CloudRunner.cloudRunnerEnvironmentVariables = TaskParameterSerializer.readBuildEnvironmentVariables(); CloudRunner.cloudRunnerEnvironmentVariables = TaskParameterSerializer.readBuildEnvironmentVariables();
if (!buildParameters.cliMode) { if (!buildParameters.isCliMode) {
const buildParameterPropertyNames = Object.getOwnPropertyNames(buildParameters); const buildParameterPropertyNames = Object.getOwnPropertyNames(buildParameters);
for (const element of CloudRunner.cloudRunnerEnvironmentVariables) { for (const element of CloudRunner.cloudRunnerEnvironmentVariables) {
core.setOutput(Input.ToEnvVarFormat(element.name), element.value); core.setOutput(Input.ToEnvVarFormat(element.name), element.value);
@ -40,19 +40,19 @@ class CloudRunner {
CloudRunnerLogger.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.cloudRunnerCluster}`); CloudRunnerLogger.log(`Cloud Runner platform selected ${CloudRunner.buildParameters.cloudRunnerCluster}`);
switch (CloudRunner.buildParameters.cloudRunnerCluster) { switch (CloudRunner.buildParameters.cloudRunnerCluster) {
case 'k8s': case 'k8s':
CloudRunner.CloudRunnerProviderPlatform = new Kubernetes(CloudRunner.buildParameters); CloudRunner.Provider = new Kubernetes(CloudRunner.buildParameters);
break; break;
case 'aws': case 'aws':
CloudRunner.CloudRunnerProviderPlatform = new AWSBuildPlatform(CloudRunner.buildParameters); CloudRunner.Provider = new AwsBuildPlatform(CloudRunner.buildParameters);
break; break;
case 'test': case 'test':
CloudRunner.CloudRunnerProviderPlatform = new TestCloudRunner(); CloudRunner.Provider = new TestCloudRunner();
break; break;
case 'local-system': case 'local-system':
CloudRunner.CloudRunnerProviderPlatform = new LocalCloudRunner(); CloudRunner.Provider = new LocalCloudRunner();
break; break;
case 'local-docker': case 'local-docker':
CloudRunner.CloudRunnerProviderPlatform = new LocalDockerCloudRunner(); CloudRunner.Provider = new LocalDockerCloudRunner();
break; break;
} }
} }
@ -60,29 +60,29 @@ class CloudRunner {
static async run(buildParameters: BuildParameters, baseImage: string) { static async run(buildParameters: BuildParameters, baseImage: string) {
CloudRunner.setup(buildParameters); CloudRunner.setup(buildParameters);
try { try {
if (!CloudRunner.buildParameters.cliMode) core.startGroup('Setup shared cloud runner resources'); if (!CloudRunner.buildParameters.isCliMode) core.startGroup('Setup shared cloud runner resources');
await CloudRunner.CloudRunnerProviderPlatform.setupSharedResources( await CloudRunner.Provider.setup(
CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters.buildGuid,
CloudRunner.buildParameters, CloudRunner.buildParameters,
CloudRunner.buildParameters.branch, CloudRunner.buildParameters.branch,
CloudRunner.defaultSecrets, CloudRunner.defaultSecrets,
); );
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
const output = await new WorkflowCompositionRoot().run( const output = await new WorkflowCompositionRoot().run(
new CloudRunnerStepState(baseImage, CloudRunner.cloudRunnerEnvironmentVariables, CloudRunner.defaultSecrets), new CloudRunnerStepState(baseImage, CloudRunner.cloudRunnerEnvironmentVariables, CloudRunner.defaultSecrets),
); );
if (!CloudRunner.buildParameters.cliMode) core.startGroup('Cleanup shared cloud runner resources'); if (!CloudRunner.buildParameters.isCliMode) core.startGroup('Cleanup shared cloud runner resources');
await CloudRunner.CloudRunnerProviderPlatform.cleanupSharedResources( await CloudRunner.Provider.cleanup(
CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters.buildGuid,
CloudRunner.buildParameters, CloudRunner.buildParameters,
CloudRunner.buildParameters.branch, CloudRunner.buildParameters.branch,
CloudRunner.defaultSecrets, CloudRunner.defaultSecrets,
); );
CloudRunnerLogger.log(`Cleanup complete`); CloudRunnerLogger.log(`Cleanup complete`);
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
return output; return output;
} catch (error) { } catch (error) {
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
await CloudRunnerError.handleException(error); await CloudRunnerError.handleException(error);
throw error; throw error;
} }

View File

@ -6,7 +6,7 @@ export class CloudRunnerError {
public static async handleException(error: unknown) { public static async handleException(error: unknown) {
CloudRunnerLogger.error(JSON.stringify(error, undefined, 4)); CloudRunnerLogger.error(JSON.stringify(error, undefined, 4));
core.setFailed('Cloud Runner failed'); core.setFailed('Cloud Runner failed');
await CloudRunner.CloudRunnerProviderPlatform.cleanupSharedResources( await CloudRunner.Provider.cleanup(
CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters.buildGuid,
CloudRunner.buildParameters, CloudRunner.buildParameters,
CloudRunner.buildParameters.branch, CloudRunner.buildParameters.branch,

View File

@ -3,7 +3,7 @@ import { CliFunction } from '../../../../cli/cli-functions-repository';
import Input from '../../../../input'; import Input from '../../../../input';
import CloudRunnerLogger from '../../../services/cloud-runner-logger'; import CloudRunnerLogger from '../../../services/cloud-runner-logger';
export class AWSCLICommands { export class AwsCliCommands {
@CliFunction(`aws-garbage-collect`, `garbage collect aws`) @CliFunction(`aws-garbage-collect`, `garbage collect aws`)
static async garbageCollectAws() { static async garbageCollectAws() {
process.env.AWS_REGION = Input.region; process.env.AWS_REGION = Input.region;

View File

@ -3,20 +3,20 @@ import CloudRunnerSecret from '../../services/cloud-runner-secret';
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def'; import CloudRunnerAWSTaskDef from './cloud-runner-aws-task-def';
import AWSTaskRunner from './aws-task-runner'; import AWSTaskRunner from './aws-task-runner';
import { CloudRunnerProviderInterface } from '../cloud-runner-provider-interface'; import { ProviderInterface } from '../provider-interface';
import BuildParameters from '../../../build-parameters'; import BuildParameters from '../../../build-parameters';
import CloudRunnerLogger from '../../services/cloud-runner-logger'; import CloudRunnerLogger from '../../services/cloud-runner-logger';
import { AWSJobStack } from './aws-job-stack'; import { AWSJobStack } from './aws-job-stack';
import { AWSBaseStack } from './aws-base-stack'; import { AWSBaseStack } from './aws-base-stack';
import { Input } from '../../..'; import { Input } from '../../..';
class AWSBuildEnvironment implements CloudRunnerProviderInterface { class AWSBuildEnvironment implements ProviderInterface {
private baseStackName: string; private baseStackName: string;
constructor(buildParameters: BuildParameters) { constructor(buildParameters: BuildParameters) {
this.baseStackName = buildParameters.awsBaseStackName; this.baseStackName = buildParameters.awsBaseStackName;
} }
async cleanupSharedResources( async cleanup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -26,7 +26,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {} ) {}
async setupSharedResources( async setup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -1,7 +1,7 @@
import * as k8s from '@kubernetes/client-node'; import * as k8s from '@kubernetes/client-node';
import { BuildParameters, Output } from '../../..'; import { BuildParameters, Output } from '../../..';
import * as core from '@actions/core'; import * as core from '@actions/core';
import { CloudRunnerProviderInterface } from '../cloud-runner-provider-interface'; import { ProviderInterface } from '../provider-interface';
import CloudRunnerSecret from '../../services/cloud-runner-secret'; import CloudRunnerSecret from '../../services/cloud-runner-secret';
import KubernetesStorage from './kubernetes-storage'; import KubernetesStorage from './kubernetes-storage';
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
@ -14,7 +14,7 @@ import CloudRunnerLogger from '../../services/cloud-runner-logger';
import { CoreV1Api } from '@kubernetes/client-node'; import { CoreV1Api } from '@kubernetes/client-node';
import DependencyOverrideService from '../../services/depdency-override-service'; import DependencyOverrideService from '../../services/depdency-override-service';
class Kubernetes implements CloudRunnerProviderInterface { class Kubernetes implements ProviderInterface {
private kubeConfig: k8s.KubeConfig; private kubeConfig: k8s.KubeConfig;
private kubeClient: k8s.CoreV1Api; private kubeClient: k8s.CoreV1Api;
private kubeClientBatch: k8s.BatchV1Api; private kubeClientBatch: k8s.BatchV1Api;
@ -39,7 +39,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
this.namespace = 'default'; this.namespace = 'default';
this.buildParameters = buildParameters; this.buildParameters = buildParameters;
} }
public async setupSharedResources( public async setup(
buildGuid: string, buildGuid: string,
buildParameters: BuildParameters, buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -174,7 +174,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
} catch {} } catch {}
} }
async cleanupSharedResources( async cleanup(
buildGuid: string, buildGuid: string,
buildParameters: BuildParameters, buildParameters: BuildParameters,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -24,7 +24,7 @@ class KubernetesStorage {
CloudRunnerLogger.log(JSON.stringify(pvcList, undefined, 4)); CloudRunnerLogger.log(JSON.stringify(pvcList, undefined, 4));
if (pvcList.includes(pvcName)) { if (pvcList.includes(pvcName)) {
CloudRunnerLogger.log(`pvc ${pvcName} already exists`); CloudRunnerLogger.log(`pvc ${pvcName} already exists`);
if (!buildParameters.cliMode) { if (!buildParameters.isCliMode) {
core.setOutput('volume', pvcName); core.setOutput('volume', pvcName);
} }
return; return;

View File

@ -2,11 +2,11 @@ import BuildParameters from '../../../build-parameters';
import { CloudRunnerSystem } from '../../services/cloud-runner-system'; import { CloudRunnerSystem } from '../../services/cloud-runner-system';
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
import CloudRunnerLogger from '../../services/cloud-runner-logger'; import CloudRunnerLogger from '../../services/cloud-runner-logger';
import { CloudRunnerProviderInterface } from '../cloud-runner-provider-interface'; import { ProviderInterface } from '../provider-interface';
import CloudRunnerSecret from '../../services/cloud-runner-secret'; import CloudRunnerSecret from '../../services/cloud-runner-secret';
class LocalDockerCloudRunner implements CloudRunnerProviderInterface { class LocalDockerCloudRunner implements ProviderInterface {
cleanupSharedResources( cleanup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -16,7 +16,7 @@ class LocalDockerCloudRunner implements CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {} ) {}
setupSharedResources( setup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -2,11 +2,11 @@ import BuildParameters from '../../../build-parameters';
import { CloudRunnerSystem } from '../../services/cloud-runner-system'; import { CloudRunnerSystem } from '../../services/cloud-runner-system';
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
import CloudRunnerLogger from '../../services/cloud-runner-logger'; import CloudRunnerLogger from '../../services/cloud-runner-logger';
import { CloudRunnerProviderInterface } from '../cloud-runner-provider-interface'; import { ProviderInterface } from '../provider-interface';
import CloudRunnerSecret from '../../services/cloud-runner-secret'; import CloudRunnerSecret from '../../services/cloud-runner-secret';
class LocalCloudRunner implements CloudRunnerProviderInterface { class LocalCloudRunner implements ProviderInterface {
cleanupSharedResources( cleanup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -16,7 +16,7 @@ class LocalCloudRunner implements CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {} ) {}
public setupSharedResources( public setup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -2,8 +2,8 @@ import BuildParameters from '../../build-parameters';
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
import CloudRunnerSecret from '../services/cloud-runner-secret'; import CloudRunnerSecret from '../services/cloud-runner-secret';
export interface CloudRunnerProviderInterface { export interface ProviderInterface {
cleanupSharedResources( cleanup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -13,7 +13,7 @@ export interface CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
); );
setupSharedResources( setup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -1,11 +1,11 @@
import BuildParameters from '../../../build-parameters'; import BuildParameters from '../../../build-parameters';
import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable'; import CloudRunnerEnvironmentVariable from '../../services/cloud-runner-environment-variable';
import CloudRunnerLogger from '../../services/cloud-runner-logger'; import CloudRunnerLogger from '../../services/cloud-runner-logger';
import { CloudRunnerProviderInterface } from '../cloud-runner-provider-interface'; import { ProviderInterface } from '../provider-interface';
import CloudRunnerSecret from '../../services/cloud-runner-secret'; import CloudRunnerSecret from '../../services/cloud-runner-secret';
class TestCloudRunner implements CloudRunnerProviderInterface { class TestCloudRunner implements ProviderInterface {
cleanupSharedResources( cleanup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
@ -15,7 +15,7 @@ class TestCloudRunner implements CloudRunnerProviderInterface {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) {} ) {}
setupSharedResources( setup(
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
buildGuid: string, buildGuid: string,
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars

View File

@ -1,7 +1,7 @@
import fs from 'fs'; 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 Input from '../../input';
import UnityVersioning from '../../unity-versioning'; import UnityVersioning from '../../unity-versioning';
import CloudRunner from '../cloud-runner'; import CloudRunner from '../cloud-runner';
@ -22,7 +22,7 @@ describe('Cloud Runner Caching', () => {
describe('Cloud Runner Caching', () => { describe('Cloud Runner Caching', () => {
if (process.platform === 'linux') { if (process.platform === 'linux') {
it('Simple caching works', async () => { it('Simple caching works', 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'),
@ -32,34 +32,39 @@ describe('Cloud Runner Caching', () => {
Input.githubInputEnabled = false; Input.githubInputEnabled = false;
const buildParameter = await BuildParameters.create(); const buildParameter = await BuildParameters.create();
CloudRunner.buildParameters = buildParameter; CloudRunner.buildParameters = buildParameter;
// create test folder // create test folder
const testFolder = path.resolve(__dirname, CLI.options.cacheKey); const testFolder = path.resolve(__dirname, Cli.options.cacheKey);
fs.mkdirSync(testFolder); fs.mkdirSync(testFolder);
// crate cache folder // crate cache folder
const cacheFolder = path.resolve(__dirname, `cache-${CLI.options.cacheKey}`); const cacheFolder = path.resolve(__dirname, `cache-${Cli.options.cacheKey}`);
fs.mkdirSync(cacheFolder); fs.mkdirSync(cacheFolder);
// add test has file to test folders // add test has file to test folders
fs.writeFileSync(path.resolve(testFolder, 'test.txt'), CLI.options.cacheKey); fs.writeFileSync(path.resolve(testFolder, 'test.txt'), Cli.options.cacheKey);
await Caching.PushToCache(cacheFolder, testFolder, `${CLI.options.cacheKey}`); await Caching.PushToCache(cacheFolder, testFolder, `${Cli.options.cacheKey}`);
// delete test folder // delete test folder
fs.rmdirSync(testFolder, { recursive: true }); fs.rmdirSync(testFolder, { recursive: true });
await Caching.PullFromCache( await Caching.PullFromCache(
cacheFolder.replace(/\\/g, `/`), cacheFolder.replace(/\\/g, `/`),
testFolder.replace(/\\/g, `/`), testFolder.replace(/\\/g, `/`),
`${CLI.options.cacheKey}`, `${Cli.options.cacheKey}`,
); );
await CloudRunnerSystem.Run(`du -h ${__dirname}`); await CloudRunnerSystem.Run(`du -h ${__dirname}`);
await CloudRunnerSystem.Run(`tree ${testFolder}`); await CloudRunnerSystem.Run(`tree ${testFolder}`);
await CloudRunnerSystem.Run(`tree ${cacheFolder}`); await CloudRunnerSystem.Run(`tree ${cacheFolder}`);
// compare validity to original hash // compare validity to original hash
expect(fs.readFileSync(path.resolve(testFolder, 'test.txt'), { encoding: 'utf8' }).toString()).toContain( expect(fs.readFileSync(path.resolve(testFolder, 'test.txt'), { encoding: 'utf8' }).toString()).toContain(
CLI.options.cacheKey, Cli.options.cacheKey,
); );
fs.rmdirSync(testFolder, { recursive: true }); fs.rmdirSync(testFolder, { recursive: true });
fs.rmdirSync(cacheFolder, { recursive: true }); fs.rmdirSync(cacheFolder, { recursive: true });
Input.githubInputEnabled = true; Input.githubInputEnabled = true;
delete CLI.options; delete Cli.options;
}, 1000000); }, 1000000);
} }
}); });

View File

@ -5,9 +5,9 @@ import CloudRunner from '../cloud-runner';
import CloudRunnerLogger from '../services/cloud-runner-logger'; import CloudRunnerLogger from '../services/cloud-runner-logger';
import { CloudRunnerFolders } from '../services/cloud-runner-folders'; import { CloudRunnerFolders } from '../services/cloud-runner-folders';
import { CloudRunnerSystem } from '../services/cloud-runner-system'; import { CloudRunnerSystem } from '../services/cloud-runner-system';
import { LFSHashing } from '../services/lfs-hashing'; import { LfsHashing } from '../services/lfs-hashing';
import { RemoteClientLogger } from './remote-client-logger'; import { RemoteClientLogger } from './remote-client-logger';
import { CLI } from '../../cli/cli'; import { Cli } from '../../cli/cli';
import { CliFunction } from '../../cli/cli-functions-repository'; import { CliFunction } from '../../cli/cli-functions-repository';
export class Caching { export class Caching {
@ -17,9 +17,9 @@ export class Caching {
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}'); const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
CloudRunner.buildParameters = buildParameter; CloudRunner.buildParameters = buildParameter;
await Caching.PushToCache( await Caching.PushToCache(
CLI.options['cachePushTo'], Cli.options['cachePushTo'],
CLI.options['cachePushFrom'], Cli.options['cachePushFrom'],
CLI.options['artifactName'] || '', Cli.options['artifactName'] || '',
); );
} catch (error: any) { } catch (error: any) {
CloudRunnerLogger.log(`${error}`); CloudRunnerLogger.log(`${error}`);
@ -32,9 +32,9 @@ export class Caching {
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}'); const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
CloudRunner.buildParameters = buildParameter; CloudRunner.buildParameters = buildParameter;
await Caching.PullFromCache( await Caching.PullFromCache(
CLI.options['cachePushFrom'], Cli.options['cachePushFrom'],
CLI.options['cachePushTo'], Cli.options['cachePushTo'],
CLI.options['artifactName'] || '', Cli.options['artifactName'] || '',
); );
} catch (error: any) { } catch (error: any) {
CloudRunnerLogger.log(`${error}`); CloudRunnerLogger.log(`${error}`);
@ -45,14 +45,15 @@ export class Caching {
cacheArtifactName = cacheArtifactName.replace(' ', ''); cacheArtifactName = cacheArtifactName.replace(' ', '');
const startPath = process.cwd(); const startPath = process.cwd();
try { try {
if (!fs.existsSync(cacheFolder)) { const cacheFolderStat = await fs.promises.stat(cacheFolder);
if (!cacheFolderStat.isDirectory()) {
await CloudRunnerSystem.Run(`mkdir -p ${cacheFolder}`); await CloudRunnerSystem.Run(`mkdir -p ${cacheFolder}`);
} }
process.chdir(path.resolve(sourceFolder, '..')); process.chdir(path.resolve(sourceFolder, '..'));
if (CloudRunner.buildParameters.cloudRunnerIntegrationTests) { if (CloudRunner.buildParameters.cloudRunnerIntegrationTests) {
CloudRunnerLogger.log( CloudRunnerLogger.log(
`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)} ${sourceFolder} ${path.basename( `Hashed cache folder ${await LfsHashing.hashAllFiles(sourceFolder)} ${sourceFolder} ${path.basename(
sourceFolder, sourceFolder,
)}`, )}`,
); );
@ -68,14 +69,17 @@ export class Caching {
}); });
}; };
await CloudRunnerSystem.Run(`zip -q -r ${cacheArtifactName}.zip ${path.basename(sourceFolder)}`); await CloudRunnerSystem.Run(`zip -q -r ${cacheArtifactName}.zip ${path.basename(sourceFolder)}`);
assert(fs.existsSync(`${cacheArtifactName}.zip`), 'cache zip exists'); const cacheArtifactStatPreMove = await fs.promises.stat(`${cacheArtifactName}.zip`);
assert(fs.existsSync(path.basename(sourceFolder)), 'source folder exists'); assert(cacheArtifactStatPreMove.isFile(), 'cache zip exists');
const sourceFolderStat = await fs.promises.stat(path.basename(sourceFolder));
assert(sourceFolderStat.isDirectory(), 'source folder exists');
if (CloudRunner.buildParameters.cachePushOverrideCommand) { if (CloudRunner.buildParameters.cachePushOverrideCommand) {
await CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePushOverrideCommand)); await CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePushOverrideCommand));
} }
await CloudRunnerSystem.Run(`mv ${cacheArtifactName}.zip ${cacheFolder}`); await CloudRunnerSystem.Run(`mv ${cacheArtifactName}.zip ${cacheFolder}`);
RemoteClientLogger.log(`moved ${cacheArtifactName}.zip to ${cacheFolder}`); RemoteClientLogger.log(`moved ${cacheArtifactName}.zip to ${cacheFolder}`);
assert(fs.existsSync(`${path.join(cacheFolder, cacheArtifactName)}.zip`), 'cache zip exists inside cache folder'); const cacheArtifactStat = await fs.promises.stat(`${path.join(cacheFolder, cacheArtifactName)}.zip`);
assert(cacheArtifactStat.isFile(), 'cache zip exists inside cache folder');
} catch (error) { } catch (error) {
process.chdir(`${startPath}`); process.chdir(`${startPath}`);
throw error; throw error;
@ -87,12 +91,15 @@ export class Caching {
const startPath = process.cwd(); const startPath = process.cwd();
RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`); RemoteClientLogger.log(`Caching for ${path.basename(destinationFolder)}`);
try { try {
if (!fs.existsSync(cacheFolder)) { const cacheFolderStat = await fs.promises.stat(cacheFolder);
fs.mkdirSync(cacheFolder); if (!cacheFolderStat.isDirectory()) {
await fs.promises.mkdir(cacheFolder);
} }
if (!fs.existsSync(destinationFolder)) { const destinationStat = await fs.promises.stat(destinationFolder);
fs.mkdirSync(destinationFolder);
if (!destinationStat.isDirectory()) {
await fs.promises.mkdir(destinationFolder);
} }
const latestInBranch = await (await CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`)) const latestInBranch = await (await CloudRunnerSystem.Run(`ls -t "${cacheFolder}" | grep .zip$ | head -1`))
@ -100,9 +107,10 @@ export class Caching {
.replace('.zip', ''); .replace('.zip', '');
process.chdir(cacheFolder); process.chdir(cacheFolder);
const cacheArtifactStat = await fs.promises.stat(`${cacheArtifactName}.zip`);
const cacheSelection = const cacheSelection =
cacheArtifactName !== `` && fs.existsSync(`${cacheArtifactName}.zip`) ? cacheArtifactName : latestInBranch; cacheArtifactName !== `` && cacheArtifactStat.isFile() ? cacheArtifactName : latestInBranch;
await CloudRunnerLogger.log(`cache key ${cacheArtifactName} selection ${cacheSelection}`); await CloudRunnerLogger.log(`cache key ${cacheArtifactName} selection ${cacheSelection}`);
// eslint-disable-next-line func-style // eslint-disable-next-line func-style
@ -120,24 +128,29 @@ export class Caching {
await CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePullOverrideCommand)); await CloudRunnerSystem.Run(formatFunction(CloudRunner.buildParameters.cachePullOverrideCommand));
} }
if (fs.existsSync(`${cacheSelection}.zip`)) { const cacheSelectionExistsStat = await fs.promises.stat(`${cacheSelection}.zip`);
if (cacheSelectionExistsStat.isFile()) {
const resultsFolder = `results${CloudRunner.buildParameters.buildGuid}`; const resultsFolder = `results${CloudRunner.buildParameters.buildGuid}`;
await CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`); await CloudRunnerSystem.Run(`mkdir -p ${resultsFolder}`);
RemoteClientLogger.log(`cache item exists ${cacheFolder}/${cacheSelection}.zip`); RemoteClientLogger.log(`cache item exists ${cacheFolder}/${cacheSelection}.zip`);
assert(`${fs.existsSync(destinationFolder)}`, `destination folder to pull into exists`);
const fullResultsFolder = path.join(cacheFolder, resultsFolder); const fullResultsFolder = path.join(cacheFolder, resultsFolder);
await CloudRunnerSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path.basename(resultsFolder)}`); await CloudRunnerSystem.Run(`unzip -q ${cacheSelection}.zip -d ${path.basename(resultsFolder)}`);
RemoteClientLogger.log(`cache item extracted to ${fullResultsFolder}`); RemoteClientLogger.log(`cache item extracted to ${fullResultsFolder}`);
assert(`${fs.existsSync(fullResultsFolder)}`, `cache extraction results folder exists`); const fullResultsFolderStat = await fs.promises.stat(fullResultsFolder);
assert(fullResultsFolderStat.isDirectory(), `cache extraction results folder exists`);
const destinationParentFolder = path.resolve(destinationFolder, '..'); const destinationParentFolder = path.resolve(destinationFolder, '..');
if (fs.existsSync(destinationFolder)) {
fs.rmdirSync(destinationFolder, { recursive: true }); const destinationFolderStat = await fs.promises.stat(destinationFolder);
if (destinationFolderStat.isDirectory()) {
await fs.promises.rmdir(destinationFolder, { recursive: true });
} }
await CloudRunnerSystem.Run( await CloudRunnerSystem.Run(
`mv "${path.join(fullResultsFolder, path.basename(destinationFolder))}" "${destinationParentFolder}"`, `mv "${path.join(fullResultsFolder, path.basename(destinationFolder))}" "${destinationParentFolder}"`,
); );
await CloudRunnerSystem.Run(`du -sh ${path.join(destinationParentFolder, path.basename(destinationFolder))}`); await CloudRunnerSystem.Run(`du -sh ${path.join(destinationParentFolder, path.basename(destinationFolder))}`);
const contents = fs.readdirSync(path.join(destinationParentFolder, path.basename(destinationFolder))); const contents = await fs.promises.readdir(
path.join(destinationParentFolder, path.basename(destinationFolder)),
);
CloudRunnerLogger.log( CloudRunnerLogger.log(
`There is ${contents.length} files/dir in the cache pulled contents for ${path.basename(destinationFolder)}`, `There is ${contents.length} files/dir in the cache pulled contents for ${path.basename(destinationFolder)}`,
); );
@ -155,10 +168,10 @@ export class Caching {
process.chdir(`${startPath}`); process.chdir(`${startPath}`);
} }
public static handleCachePurging() { public static async handleCachePurging() {
if (process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined) { if (process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined) {
RemoteClientLogger.log(`purging ${CloudRunnerFolders.purgeRemoteCaching}`); RemoteClientLogger.log(`purging ${CloudRunnerFolders.purgeRemoteCaching}`);
fs.rmdirSync(CloudRunnerFolders.cacheFolder, { recursive: true }); fs.promises.rmdir(CloudRunnerFolders.cacheFolder, { recursive: true });
} }
} }
} }

View File

@ -2,7 +2,7 @@ import fs from 'fs';
import CloudRunner from '../cloud-runner'; import CloudRunner from '../cloud-runner';
import { CloudRunnerFolders } from '../services/cloud-runner-folders'; import { CloudRunnerFolders } from '../services/cloud-runner-folders';
import { Caching } from './caching'; import { Caching } from './caching';
import { LFSHashing } from '../services/lfs-hashing'; import { LfsHashing } from '../services/lfs-hashing';
import { RemoteClientLogger } from './remote-client-logger'; import { RemoteClientLogger } from './remote-client-logger';
import path from 'path'; import path from 'path';
import { assert } from 'console'; import { assert } from 'console';
@ -10,35 +10,35 @@ import CloudRunnerLogger from '../services/cloud-runner-logger';
import { CliFunction } from '../../cli/cli-functions-repository'; import { CliFunction } from '../../cli/cli-functions-repository';
import { CloudRunnerSystem } from '../services/cloud-runner-system'; import { CloudRunnerSystem } from '../services/cloud-runner-system';
export class SetupCloudRunnerRepository { export class RemoteClient {
public static async run() { public static async bootstrapRepository() {
try { try {
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.uniqueCloudRunnerJobFolderFull}`); await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute}`);
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.repoPathFull}`); await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.repoPathAbsolute}`);
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.cacheFolderFull}`); await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.cacheFolderFull}`);
process.chdir(CloudRunnerFolders.repoPathFull); process.chdir(CloudRunnerFolders.repoPathAbsolute);
await SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles(); await RemoteClient.cloneRepoWithoutLFSFiles();
await SetupCloudRunnerRepository.sizeOfFolder('repo before lfs cache pull', CloudRunnerFolders.repoPathFull); await RemoteClient.sizeOfFolder('repo before lfs cache pull', CloudRunnerFolders.repoPathAbsolute);
const lfsHashes = await LFSHashing.createLFSHashFiles(); const lfsHashes = await LfsHashing.createLFSHashFiles();
if (fs.existsSync(CloudRunnerFolders.libraryFolderFull)) { if (fs.existsSync(CloudRunnerFolders.libraryFolderAbsolute)) {
RemoteClientLogger.logWarning(`!Warning!: The Unity library was included in the git repository`); RemoteClientLogger.logWarning(`!Warning!: The Unity library was included in the git repository`);
} }
await Caching.PullFromCache( await Caching.PullFromCache(
CloudRunnerFolders.lfsCacheFolderFull, CloudRunnerFolders.lfsCacheFolderFull,
CloudRunnerFolders.lfsDirectoryFull, CloudRunnerFolders.lfsFolderAbsolute,
`${lfsHashes.lfsGuidSum}`, `${lfsHashes.lfsGuidSum}`,
); );
await SetupCloudRunnerRepository.sizeOfFolder('repo after lfs cache pull', CloudRunnerFolders.repoPathFull); await RemoteClient.sizeOfFolder('repo after lfs cache pull', CloudRunnerFolders.repoPathAbsolute);
await SetupCloudRunnerRepository.pullLatestLFS(); await RemoteClient.pullLatestLFS();
await SetupCloudRunnerRepository.sizeOfFolder('repo before lfs git pull', CloudRunnerFolders.repoPathFull); await RemoteClient.sizeOfFolder('repo before lfs git pull', CloudRunnerFolders.repoPathAbsolute);
await Caching.PushToCache( await Caching.PushToCache(
CloudRunnerFolders.lfsCacheFolderFull, CloudRunnerFolders.lfsCacheFolderFull,
CloudRunnerFolders.lfsDirectoryFull, CloudRunnerFolders.lfsFolderAbsolute,
`${lfsHashes.lfsGuidSum}`, `${lfsHashes.lfsGuidSum}`,
); );
await Caching.PullFromCache(CloudRunnerFolders.libraryCacheFolderFull, CloudRunnerFolders.libraryFolderFull); await Caching.PullFromCache(CloudRunnerFolders.libraryCacheFolderFull, CloudRunnerFolders.libraryFolderAbsolute);
await SetupCloudRunnerRepository.sizeOfFolder('repo after library cache pull', CloudRunnerFolders.repoPathFull); await RemoteClient.sizeOfFolder('repo after library cache pull', CloudRunnerFolders.repoPathAbsolute);
Caching.handleCachePurging(); await Caching.handleCachePurging();
} catch (error) { } catch (error) {
throw error; throw error;
} }
@ -51,7 +51,7 @@ export class SetupCloudRunnerRepository {
private static async cloneRepoWithoutLFSFiles() { private static async cloneRepoWithoutLFSFiles() {
try { try {
process.chdir(`${CloudRunnerFolders.repoPathFull}`); process.chdir(`${CloudRunnerFolders.repoPathAbsolute}`);
RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`); RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
await CloudRunnerSystem.Run(`git config --global advice.detachedHead false`); await CloudRunnerSystem.Run(`git config --global advice.detachedHead false`);
RemoteClientLogger.log(`Cloning the repository being built:`); RemoteClientLogger.log(`Cloning the repository being built:`);
@ -60,7 +60,7 @@ export class SetupCloudRunnerRepository {
await CloudRunnerSystem.Run( await CloudRunnerSystem.Run(
`git clone -q ${CloudRunnerFolders.targetBuildRepoUrl} ${path.resolve( `git clone -q ${CloudRunnerFolders.targetBuildRepoUrl} ${path.resolve(
`..`, `..`,
path.basename(CloudRunnerFolders.repoPathFull), path.basename(CloudRunnerFolders.repoPathAbsolute),
)}`, )}`,
); );
await CloudRunnerSystem.Run(`git lfs install`); await CloudRunnerSystem.Run(`git lfs install`);
@ -75,12 +75,12 @@ export class SetupCloudRunnerRepository {
} }
private static async pullLatestLFS() { private static async pullLatestLFS() {
process.chdir(CloudRunnerFolders.repoPathFull); process.chdir(CloudRunnerFolders.repoPathAbsolute);
await CloudRunnerSystem.Run(`git config --global filter.lfs.smudge "git-lfs smudge -- %f"`); await CloudRunnerSystem.Run(`git config --global filter.lfs.smudge "git-lfs smudge -- %f"`);
await CloudRunnerSystem.Run(`git config --global filter.lfs.process "git-lfs filter-process"`); await CloudRunnerSystem.Run(`git config --global filter.lfs.process "git-lfs filter-process"`);
await CloudRunnerSystem.Run(`git lfs pull`); await CloudRunnerSystem.Run(`git lfs pull`);
RemoteClientLogger.log(`pulled latest LFS files`); RemoteClientLogger.log(`pulled latest LFS files`);
assert(fs.existsSync(CloudRunnerFolders.lfsDirectoryFull)); assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
} }
@CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`) @CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`)
@ -90,6 +90,6 @@ export class SetupCloudRunnerRepository {
${JSON.stringify(buildParameter, undefined, 4)} ${JSON.stringify(buildParameter, undefined, 4)}
`); `);
CloudRunner.buildParameters = buildParameter; CloudRunner.buildParameters = buildParameter;
await SetupCloudRunnerRepository.run(); await RemoteClient.bootstrapRepository();
} }
} }

View File

@ -6,7 +6,7 @@ export class CloudRunnerFolders {
// only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute / // only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute /
public static get uniqueCloudRunnerJobFolderFull(): string { public static get uniqueCloudRunnerJobFolderAbsolute(): string {
return path.join(`/`, CloudRunnerFolders.buildVolumeFolder, CloudRunner.buildParameters.buildGuid); return path.join(`/`, CloudRunnerFolders.buildVolumeFolder, CloudRunner.buildParameters.buildGuid);
} }
@ -19,28 +19,28 @@ export class CloudRunnerFolders {
); );
} }
public static get builderPathFull(): string { public static get builderPathAbsolute(): string {
return path.join(CloudRunnerFolders.uniqueCloudRunnerJobFolderFull, `builder`); return path.join(CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute, `builder`);
} }
public static get repoPathFull(): string { public static get repoPathAbsolute(): string {
return path.join(CloudRunnerFolders.uniqueCloudRunnerJobFolderFull, CloudRunnerFolders.repositoryFolder); return path.join(CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute, CloudRunnerFolders.repositoryFolder);
} }
public static get projectPathFull(): string { public static get projectPathAbsolute(): string {
return path.join(CloudRunnerFolders.repoPathFull, CloudRunner.buildParameters.projectPath); return path.join(CloudRunnerFolders.repoPathAbsolute, CloudRunner.buildParameters.projectPath);
} }
public static get libraryFolderFull(): string { public static get libraryFolderAbsolute(): string {
return path.join(CloudRunnerFolders.projectPathFull, `Library`); return path.join(CloudRunnerFolders.projectPathAbsolute, `Library`);
} }
public static get projectBuildFolderFull(): string { public static get projectBuildFolderAbsolute(): string {
return path.join(CloudRunnerFolders.repoPathFull, CloudRunner.buildParameters.buildPath); return path.join(CloudRunnerFolders.repoPathAbsolute, CloudRunner.buildParameters.buildPath);
} }
public static get lfsDirectoryFull(): string { public static get lfsFolderAbsolute(): string {
return path.join(CloudRunnerFolders.repoPathFull, `.git`, `lfs`); return path.join(CloudRunnerFolders.repoPathAbsolute, `.git`, `lfs`);
} }
public static get purgeRemoteCaching(): boolean { public static get purgeRemoteCaching(): boolean {

View File

@ -1,5 +1,6 @@
import { exec } from 'child_process'; import { exec } from 'child_process';
import { RemoteClientLogger } from '../remote-client/remote-client-logger'; import { RemoteClientLogger } from '../remote-client/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`)) {

View File

@ -3,10 +3,10 @@ import { CloudRunnerFolders } from './cloud-runner-folders';
import { CloudRunnerSystem } from './cloud-runner-system'; import { CloudRunnerSystem } from './cloud-runner-system';
import fs from 'fs'; import fs from 'fs';
import { assert } from 'console'; import { assert } from 'console';
import { CLI } from '../../cli/cli'; import { Cli } from '../../cli/cli';
import { CliFunction } from '../../cli/cli-functions-repository'; import { CliFunction } from '../../cli/cli-functions-repository';
export class LFSHashing { export class LfsHashing {
public static async createLFSHashFiles() { public static async createLFSHashFiles() {
try { try {
await CloudRunnerSystem.Run(`git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid`); await CloudRunnerSystem.Run(`git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid`);
@ -15,10 +15,10 @@ export class LFSHashing {
assert(fs.existsSync(`.lfs-assets-guid`)); assert(fs.existsSync(`.lfs-assets-guid`));
const lfsHashes = { const lfsHashes = {
lfsGuid: fs lfsGuid: fs
.readFileSync(`${path.join(CloudRunnerFolders.repoPathFull, `.lfs-assets-guid`)}`, 'utf8') .readFileSync(`${path.join(CloudRunnerFolders.repoPathAbsolute, `.lfs-assets-guid`)}`, 'utf8')
.replace(/\n/g, ``), .replace(/\n/g, ``),
lfsGuidSum: fs lfsGuidSum: fs
.readFileSync(`${path.join(CloudRunnerFolders.repoPathFull, `.lfs-assets-guid-sum`)}`, 'utf8') .readFileSync(`${path.join(CloudRunnerFolders.repoPathAbsolute, `.lfs-assets-guid-sum`)}`, 'utf8')
.replace(' .lfs-assets-guid', '') .replace(' .lfs-assets-guid', '')
.replace(/\n/g, ``), .replace(/\n/g, ``),
}; };
@ -39,7 +39,7 @@ export class LFSHashing {
@CliFunction(`hash`, `hash all folder contents`) @CliFunction(`hash`, `hash all folder contents`)
static async hash() { static async hash() {
const folder = CLI.options['cachePushFrom']; const folder = Cli.options['cachePushFrom'];
LFSHashing.hashAllFiles(folder); LfsHashing.hashAllFiles(folder);
} }
} }

View File

@ -21,36 +21,36 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
try { try {
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`); CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
if (!CloudRunner.buildParameters.cliMode) core.startGroup('pre build steps'); if (!CloudRunner.buildParameters.isCliMode) core.startGroup('pre build steps');
let output = ''; let output = '';
if (CloudRunner.buildParameters.preBuildSteps !== '') { if (CloudRunner.buildParameters.preBuildSteps !== '') {
output += await CustomWorkflow.runCustomJob(CloudRunner.buildParameters.preBuildSteps); output += await CustomWorkflow.runCustomJob(CloudRunner.buildParameters.preBuildSteps);
} }
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
CloudRunnerLogger.logWithTime('Configurable pre build step(s) time'); CloudRunnerLogger.logWithTime('Configurable pre build step(s) time');
if (!CloudRunner.buildParameters.cliMode) core.startGroup('build'); if (!CloudRunner.buildParameters.isCliMode) core.startGroup('build');
CloudRunnerLogger.log(baseImage.toString()); CloudRunnerLogger.log(baseImage.toString());
CloudRunnerLogger.logLine(` `); CloudRunnerLogger.logLine(` `);
CloudRunnerLogger.logLine('Starting build automation job'); CloudRunnerLogger.logLine('Starting build automation job');
output += await CloudRunner.CloudRunnerProviderPlatform.runTask( output += await CloudRunner.Provider.runTask(
CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters.buildGuid,
baseImage.toString(), baseImage.toString(),
BuildAutomationWorkflow.FullWorkflow, BuildAutomationWorkflow.BuildWorkflow,
`/${CloudRunnerFolders.buildVolumeFolder}`, `/${CloudRunnerFolders.buildVolumeFolder}`,
`/${CloudRunnerFolders.buildVolumeFolder}/`, `/${CloudRunnerFolders.buildVolumeFolder}/`,
CloudRunner.cloudRunnerEnvironmentVariables, CloudRunner.cloudRunnerEnvironmentVariables,
CloudRunner.defaultSecrets, CloudRunner.defaultSecrets,
); );
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
CloudRunnerLogger.logWithTime('Build time'); CloudRunnerLogger.logWithTime('Build time');
if (!CloudRunner.buildParameters.cliMode) core.startGroup('post build steps'); if (!CloudRunner.buildParameters.isCliMode) core.startGroup('post build steps');
if (CloudRunner.buildParameters.postBuildSteps !== '') { if (CloudRunner.buildParameters.postBuildSteps !== '') {
output += await CustomWorkflow.runCustomJob(CloudRunner.buildParameters.postBuildSteps); output += await CustomWorkflow.runCustomJob(CloudRunner.buildParameters.postBuildSteps);
} }
if (!CloudRunner.buildParameters.cliMode) core.endGroup(); if (!CloudRunner.buildParameters.isCliMode) core.endGroup();
CloudRunnerLogger.logWithTime('Configurable post build step(s) time'); CloudRunnerLogger.logWithTime('Configurable post build step(s) time');
CloudRunnerLogger.log(`Cloud Runner finished running standard build automation`); CloudRunnerLogger.log(`Cloud Runner finished running standard build automation`);
@ -61,34 +61,34 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
} }
} }
private static get FullWorkflow() { private static get BuildWorkflow() {
const setupHooks = CloudRunnerBuildCommandProcessor.getHooks(CloudRunner.buildParameters.customJobHooks).filter( const setupHooks = CloudRunnerBuildCommandProcessor.getHooks(CloudRunner.buildParameters.customJobHooks).filter(
(x) => x.step.includes(`setup`), (x) => x.step.includes(`setup`),
); );
const buildHooks = CloudRunnerBuildCommandProcessor.getHooks(CloudRunner.buildParameters.customJobHooks).filter( const buildHooks = CloudRunnerBuildCommandProcessor.getHooks(CloudRunner.buildParameters.customJobHooks).filter(
(x) => x.step.includes(`build`), (x) => x.step.includes(`build`),
); );
const builderPath = path.join(CloudRunnerFolders.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`); const builderPath = path.join(CloudRunnerFolders.builderPathAbsolute, 'dist', `index.js`).replace(/\\/g, `/`);
return `apt-get update > /dev/null return `apt-get update > /dev/null
apt-get install -y zip tree npm git-lfs jq unzip git > /dev/null apt-get install -y zip tree npm git-lfs jq unzip git > /dev/null
npm install -g n > /dev/null npm install -g n > /dev/null
n stable > /dev/null n stable > /dev/null
${setupHooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '} ${setupHooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
export GITHUB_WORKSPACE="${CloudRunnerFolders.repoPathFull.replace(/\\/g, `/`)}" export GITHUB_WORKSPACE="${CloudRunnerFolders.repoPathAbsolute.replace(/\\/g, `/`)}"
${BuildAutomationWorkflow.SetupCommands(builderPath)} ${BuildAutomationWorkflow.setupCommands(builderPath)}
${setupHooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '} ${setupHooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
${buildHooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '} ${buildHooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
${BuildAutomationWorkflow.BuildCommands(builderPath, CloudRunner.buildParameters.buildGuid)} ${BuildAutomationWorkflow.BuildCommands(builderPath, CloudRunner.buildParameters.buildGuid)}
${buildHooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}`; ${buildHooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}`;
} }
private static SetupCommands(builderPath) { private static setupCommands(builderPath) {
return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1 return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
echo "game ci cloud runner clone" echo "game ci cloud runner clone"
mkdir -p ${CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)} mkdir -p ${CloudRunnerFolders.builderPathAbsolute.replace(/\\/g, `/`)}
git clone -q -b ${CloudRunner.buildParameters.cloudRunnerBranch} ${ git clone -q -b ${CloudRunner.buildParameters.cloudRunnerBranch} ${
CloudRunnerFolders.unityBuilderRepoUrl CloudRunnerFolders.unityBuilderRepoUrl
} "${CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}" } "${CloudRunnerFolders.builderPathAbsolute.replace(/\\/g, `/`)}"
chmod +x ${builderPath} chmod +x ${builderPath}
echo "game ci cloud runner bootstrap" echo "game ci cloud runner bootstrap"
node ${builderPath} -m remote-cli`; node ${builderPath} -m remote-cli`;
@ -96,11 +96,11 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
private static BuildCommands(builderPath, guid) { private static BuildCommands(builderPath, guid) {
const linuxCacheFolder = CloudRunnerFolders.cacheFolderFull.replace(/\\/g, `/`); const linuxCacheFolder = CloudRunnerFolders.cacheFolderFull.replace(/\\/g, `/`);
const distFolder = path.join(CloudRunnerFolders.builderPathFull, 'dist'); const distFolder = path.join(CloudRunnerFolders.builderPathAbsolute, 'dist');
const ubuntuPlatformsFolder = path.join(CloudRunnerFolders.builderPathFull, 'dist', 'platforms', 'ubuntu'); const ubuntuPlatformsFolder = path.join(CloudRunnerFolders.builderPathAbsolute, 'dist', 'platforms', 'ubuntu');
return `echo "game ci cloud runner init" return `echo "game ci cloud runner init"
mkdir -p ${`${CloudRunnerFolders.projectBuildFolderFull}/build`.replace(/\\/g, `/`)} mkdir -p ${`${CloudRunnerFolders.projectBuildFolderAbsolute}/build`.replace(/\\/g, `/`)}
cd ${CloudRunnerFolders.projectPathFull} cd ${CloudRunnerFolders.projectPathAbsolute}
cp -r "${path.join(distFolder, 'default-build-script').replace(/\\/g, `/`)}" "/UnityBuilderAction" cp -r "${path.join(distFolder, 'default-build-script').replace(/\\/g, `/`)}" "/UnityBuilderAction"
cp -r "${path.join(ubuntuPlatformsFolder, 'entrypoint.sh').replace(/\\/g, `/`)}" "/entrypoint.sh" cp -r "${path.join(ubuntuPlatformsFolder, 'entrypoint.sh').replace(/\\/g, `/`)}" "/entrypoint.sh"
cp -r "${path.join(ubuntuPlatformsFolder, 'steps').replace(/\\/g, `/`)}" "/steps" cp -r "${path.join(ubuntuPlatformsFolder, 'steps').replace(/\\/g, `/`)}" "/steps"
@ -111,11 +111,11 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
echo "game ci cloud runner push library to cache" echo "game ci cloud runner push library to cache"
chmod +x ${builderPath} chmod +x ${builderPath}
node ${builderPath} -m cache-push --cachePushFrom ${ node ${builderPath} -m cache-push --cachePushFrom ${
CloudRunnerFolders.libraryFolderFull CloudRunnerFolders.libraryFolderAbsolute
} --artifactName lib-${guid} --cachePushTo ${linuxCacheFolder}/Library } --artifactName lib-${guid} --cachePushTo ${linuxCacheFolder}/Library
echo "game ci cloud runner push build to cache" echo "game ci cloud runner push build to cache"
node ${builderPath} -m cache-push --cachePushFrom ${ node ${builderPath} -m cache-push --cachePushFrom ${
CloudRunnerFolders.projectBuildFolderFull CloudRunnerFolders.projectBuildFolderAbsolute
} --artifactName build-${guid} --cachePushTo ${`${linuxCacheFolder}/build`.replace(/\\/g, `/`)}`; } --artifactName build-${guid} --cachePushTo ${`${linuxCacheFolder}/build`.replace(/\\/g, `/`)}`;
} }
} }

View File

@ -27,7 +27,7 @@ export class CustomWorkflow {
}; };
return secret; return secret;
}); });
output += await CloudRunner.CloudRunnerProviderPlatform.runTask( output += await CloudRunner.Provider.runTask(
CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters.buildGuid,
step['image'], step['image'],
step['commands'], step['commands'],

View File

@ -1,6 +1,6 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; 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';
@ -26,15 +26,18 @@ class Input {
const alternativeQuery = Input.ToEnvVarFormat(query); const alternativeQuery = Input.ToEnvVarFormat(query);
// query input sources // query input sources
if (CLI.query(query, alternativeQuery)) { if (Cli.query(query, alternativeQuery)) {
return CLI.query(query, alternativeQuery); return Cli.query(query, alternativeQuery);
} }
if (CloudRunnerQueryOverride.query(query, alternativeQuery)) { if (CloudRunnerQueryOverride.query(query, alternativeQuery)) {
return 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 (alternativeQuery !== query && process.env[alternativeQuery] !== undefined) {
return process.env[alternativeQuery]; return process.env[alternativeQuery];
} }
@ -222,7 +225,7 @@ class Input {
} }
static get cloudRunnerCluster() { static get cloudRunnerCluster() {
if (CLI.cliMode) { if (Cli.isCliMode) {
return Input.getInput('cloudRunnerCluster') || 'aws'; return Input.getInput('cloudRunnerCluster') || 'aws';
} }
return Input.getInput('cloudRunnerCluster') || 'local'; return Input.getInput('cloudRunnerCluster') || 'local';