pull/496/head
Frostebite 2023-03-07 16:42:34 +00:00
parent e075f22e5c
commit a5eb0488aa
17 changed files with 65270 additions and 144580 deletions

205261
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -44,7 +44,7 @@
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"semver": "^7.3.5", "semver": "^7.3.5",
"unity-changeset": "^2.0.0", "unity-changeset": "^2.0.0",
"uuid": "^8.3.2", "uuid": "^9.0.0",
"yaml": "^1.10.2" "yaml": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {

View File

@ -7,7 +7,7 @@ class CloudRunnerOptions {
// ### ### ### // ### ### ###
// Input Handling // Input Handling
// ### ### ### // ### ### ###
public static getInput(query) { public static getInput(query: any) {
if (GitHub.githubInputEnabled) { if (GitHub.githubInputEnabled) {
const coreInput = core.getInput(query); const coreInput = core.getInput(query);
if (coreInput && coreInput !== '') { if (coreInput && coreInput !== '') {

View File

@ -92,7 +92,7 @@ class AWSTaskRunner {
return { output, shouldCleanup }; return { output, shouldCleanup };
} }
if (taskData.stoppedReason === 'Essential container in task exited' && exitCode === 1) { if (taskData?.stoppedReason === 'Essential container in task exited' && exitCode === 1) {
throw new Error('Container exited with code 1'); throw new Error('Container exited with code 1');
} }

View File

@ -137,13 +137,13 @@ class Kubernetes implements ProviderInterface {
let existsAlready = false; let existsAlready = false;
let status; let status;
try { try {
status = await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace); status = (await this.kubeClient.readNamespacedPodStatus(this.podName, this.namespace)).body.status;
CloudRunnerLogger.log(JSON.stringify(status.body.status?.containerStatuses, undefined, 4)); CloudRunnerLogger.log(JSON.stringify(status?.containerStatuses, undefined, 4));
existsAlready = true; existsAlready = true;
} catch { } catch {
// empty // empty
} }
if (!existsAlready || status.state?.terminated !== undefined) { if (!existsAlready) {
CloudRunnerLogger.log('Job does not exist'); CloudRunnerLogger.log('Job does not exist');
await this.createJob(commands, image, mountdir, workingdir, environment, secrets); await this.createJob(commands, image, mountdir, workingdir, environment, secrets);
CloudRunnerLogger.log('Watching pod until running'); CloudRunnerLogger.log('Watching pod until running');
@ -160,10 +160,10 @@ class Kubernetes implements ProviderInterface {
this.namespace, this.namespace,
running, running,
); );
status = await KubernetesPods.GetPodStatus(this.podName, this.namespace, this.kubeClient); let podStatus = await KubernetesPods.GetPodStatus(this.podName, this.namespace, this.kubeClient);
if (!running) { if (!running) {
if (!FollowLogStreamService.DidReceiveEndOfTransmission && status === `Succeeded`) { if (!FollowLogStreamService.DidReceiveEndOfTransmission && podStatus === `Succeeded`) {
output += await KubernetesTaskRunner.runTask( output += await KubernetesTaskRunner.runTask(
this.kubeConfig, this.kubeConfig,
this.kubeClient, this.kubeClient,
@ -204,8 +204,8 @@ class Kubernetes implements ProviderInterface {
break; break;
} }
} }
status = await KubernetesPods.GetPodStatus(this.podName, this.namespace, this.kubeClient); podStatus = await KubernetesPods.GetPodStatus(this.podName, this.namespace, this.kubeClient);
CloudRunnerLogger.log(`Pod status ${status}, retrying log stream...`); CloudRunnerLogger.log(`Pod status ${podStatus}, retrying log stream...`);
} catch (error: any) { } catch (error: any) {
let errorParsed; let errorParsed;
try { try {
@ -258,7 +258,7 @@ class Kubernetes implements ProviderInterface {
this.setPodNameAndContainerName(find); this.setPodNameAndContainerName(find);
} }
private async doesJobExist(name) { private async doesJobExist(name: string) {
const jobs = await this.kubeClientBatch.listNamespacedJob(this.namespace); const jobs = await this.kubeClientBatch.listNamespacedJob(this.namespace);
return jobs.body.items.some((x) => x.metadata?.name === name); return jobs.body.items.some((x) => x.metadata?.name === name);

View File

@ -25,7 +25,7 @@ echo "end of cloud runner job"
echo "---${buildParameters.logId}"`; echo "---${buildParameters.logId}"`;
} }
public static getHooks(customJobHooks): Hook[] { public static getHooks(customJobHooks: any): Hook[] {
const experimentHooks = customJobHooks; const experimentHooks = customJobHooks;
let output = new Array<Hook>(); let output = new Array<Hook>();
if (experimentHooks && experimentHooks !== '') { if (experimentHooks && experimentHooks !== '') {
@ -69,13 +69,13 @@ echo "---${buildParameters.logId}"`;
return results; return results;
} }
private static ConvertYamlSecrets(object) { private static ConvertYamlSecrets(object: Hook) {
if (object.secrets === undefined) { if (object.secrets === undefined) {
object.secrets = []; object.secrets = [];
return; return;
} }
object.secrets = object.secrets.map((x) => { object.secrets = object.secrets.map((x: any) => {
return { return {
ParameterKey: x.name, ParameterKey: x.name,
EnvironmentVariable: Input.ToEnvVarFormat(x.name), EnvironmentVariable: Input.ToEnvVarFormat(x.name),
@ -109,15 +109,15 @@ echo "---${buildParameters.logId}"`;
return object; return object;
} }
public static getSecrets(hooks) { public static getSecrets(hooks: any) {
const secrets = hooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0); const secrets = hooks.map((x: any) => x.secrets).filter((x: any) => x !== undefined && x.length > 0);
// eslint-disable-next-line unicorn/no-array-reduce // eslint-disable-next-line unicorn/no-array-reduce
return secrets.length > 0 ? secrets.reduce((x, y) => [...x, ...y]) : []; return secrets.length > 0 ? secrets.reduce((x: any, y: any) => [...x, ...y]) : [];
} }
} }
export class Hook { export class Hook {
public commands; public commands: any;
public secrets: CloudRunnerSecret[] = new Array<CloudRunnerSecret>(); public secrets: CloudRunnerSecret[] = new Array<CloudRunnerSecret>();
public name!: string; public name!: string;
public hook!: string[]; public hook!: string[];

View File

@ -7,7 +7,7 @@ import GitHub from '../../github';
export class FollowLogStreamService { export class FollowLogStreamService {
static errors = ``; static errors = ``;
public static DidReceiveEndOfTransmission = false; public static DidReceiveEndOfTransmission = false;
public static handleIteration(message, shouldReadLogs, shouldCleanup, output) { public static handleIteration(message: string, shouldReadLogs: boolean, shouldCleanup: boolean, output: string) {
if (message.includes(`---${CloudRunner.buildParameters.logId}`)) { if (message.includes(`---${CloudRunner.buildParameters.logId}`)) {
CloudRunnerLogger.log('End of log transmission received'); CloudRunnerLogger.log('End of log transmission received');
FollowLogStreamService.DidReceiveEndOfTransmission = true; FollowLogStreamService.DidReceiveEndOfTransmission = true;

View File

@ -34,6 +34,9 @@ export class LfsHashing {
@CliFunction(`hash`, `hash all folder contents`) @CliFunction(`hash`, `hash all folder contents`)
static async hash() { static async hash() {
if (!Cli.options) {
return;
}
const folder = Cli.options['cachePushFrom']; const folder = Cli.options['cachePushFrom'];
LfsHashing.hashAllFiles(folder); LfsHashing.hashAllFiles(folder);
} }

View File

@ -8,7 +8,7 @@ import { CloudRunnerStatics } from '../cloud-runner-statics';
import CloudRunnerOptions from '../cloud-runner-options'; import CloudRunnerOptions from '../cloud-runner-options';
import CloudRunnerLogger from '../services/cloud-runner-logger'; import CloudRunnerLogger from '../services/cloud-runner-logger';
async function CreateParameters(overrides) { async function CreateParameters(overrides: any) {
if (overrides) { if (overrides) {
Cli.options = overrides; Cli.options = overrides;
} }

View File

@ -9,7 +9,7 @@ import setups from './cloud-runner-suite.test';
import { CloudRunnerCustomSteps } from '../services/cloud-runner-custom-steps'; import { CloudRunnerCustomSteps } from '../services/cloud-runner-custom-steps';
import { CloudRunnerCustomHooks } from '../services/cloud-runner-custom-hooks'; import { CloudRunnerCustomHooks } from '../services/cloud-runner-custom-hooks';
async function CreateParameters(overrides) { async function CreateParameters(overrides: any) {
if (overrides) { if (overrides) {
Cli.options = overrides; Cli.options = overrides;
} }

View File

@ -8,7 +8,7 @@ import UnityVersioning from '../../unity-versioning';
import BuildParameters from '../../build-parameters'; import BuildParameters from '../../build-parameters';
import CloudRunner from '../cloud-runner'; import CloudRunner from '../cloud-runner';
async function CreateParameters(overrides) { async function CreateParameters(overrides: any) {
if (overrides) { if (overrides) {
Cli.options = overrides; Cli.options = overrides;
} }
@ -21,7 +21,6 @@ describe('Cloud Runner Locking', () => {
it('Responds', () => {}); it('Responds', () => {});
if (CloudRunnerOptions.cloudRunnerDebug) { if (CloudRunnerOptions.cloudRunnerDebug) {
it(`Create Workspace`, async () => { it(`Create Workspace`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -36,7 +35,6 @@ describe('Cloud Runner Locking', () => {
expect(await SharedWorkspaceLocking.CreateWorkspace(newWorkspaceName, buildParameters)).toBeTruthy(); expect(await SharedWorkspaceLocking.CreateWorkspace(newWorkspaceName, buildParameters)).toBeTruthy();
}, 150000); }, 150000);
it(`Create Workspace And Lock Workspace`, async () => { it(`Create Workspace And Lock Workspace`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -53,7 +51,6 @@ describe('Cloud Runner Locking', () => {
expect(await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy(); expect(await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
}, 150000); }, 150000);
it(`Get Or Create From No Workspace`, async () => { it(`Get Or Create From No Workspace`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -72,7 +69,6 @@ describe('Cloud Runner Locking', () => {
).toBeTruthy(); ).toBeTruthy();
}, 150000); }, 150000);
it(`Get Or Create From Unlocked`, async () => { it(`Get Or Create From Unlocked`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -93,7 +89,6 @@ describe('Cloud Runner Locking', () => {
expect(CloudRunner.lockedWorkspace).toMatch(newWorkspaceName); expect(CloudRunner.lockedWorkspace).toMatch(newWorkspaceName);
}, 150000); }, 150000);
it(`Get Or Create From Locked`, async () => { it(`Get Or Create From Locked`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -120,7 +115,6 @@ describe('Cloud Runner Locking', () => {
expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName); expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName);
}, 150000); }, 150000);
it(`Get Or Create After Double Lock And One Unlock`, async () => { it(`Get Or Create After Double Lock And One Unlock`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -150,7 +144,6 @@ describe('Cloud Runner Locking', () => {
expect(CloudRunner.lockedWorkspace).not.toContain(newWorkspaceName); expect(CloudRunner.lockedWorkspace).not.toContain(newWorkspaceName);
}, 150000); }, 150000);
it(`Get Or Create After Double Lock And Unlock`, async () => { it(`Get Or Create After Double Lock And Unlock`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -181,7 +174,6 @@ describe('Cloud Runner Locking', () => {
expect(CloudRunner.lockedWorkspace).toContain(newWorkspaceName); expect(CloudRunner.lockedWorkspace).toContain(newWorkspaceName);
}, 150000); }, 150000);
it(`0 free workspaces after locking`, async () => { it(`0 free workspaces after locking`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',
@ -243,7 +235,6 @@ describe('Cloud Runner Locking', () => {
expect(await SharedWorkspaceLocking.GetFreeWorkspaces(buildParameters)).toHaveLength(0); expect(await SharedWorkspaceLocking.GetFreeWorkspaces(buildParameters)).toHaveLength(0);
}, 150000); }, 150000);
it(`Get Or Create From Unlocked Was Locked`, async () => { it(`Get Or Create From Unlocked Was Locked`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',

View File

@ -1,7 +1,7 @@
import BuildParameters from '../../build-parameters'; import BuildParameters from '../../build-parameters';
import { Cli } from '../../cli/cli'; import { Cli } from '../../cli/cli';
export async function CreateParameters(overrides) { export async function CreateParameters(overrides: any) {
if (overrides) Cli.options = overrides; if (overrides) Cli.options = overrides;
return BuildParameters.create(); return BuildParameters.create();

View File

@ -9,7 +9,7 @@ import setups from '../cloud-runner-suite.test';
import * as fs from 'fs'; import * as fs from 'fs';
import { CloudRunnerSystem } from '../../services/cloud-runner-system'; import { CloudRunnerSystem } from '../../services/cloud-runner-system';
async function CreateParameters(overrides) { async function CreateParameters(overrides: any) {
if (overrides) { if (overrides) {
Cli.options = overrides; Cli.options = overrides;
} }

View File

@ -8,7 +8,7 @@ import CloudRunnerOptions from '../../cloud-runner-options';
import setups from '../cloud-runner-suite.test'; import setups from '../cloud-runner-suite.test';
import SharedWorkspaceLocking from '../../services/shared-workspace-locking'; import SharedWorkspaceLocking from '../../services/shared-workspace-locking';
async function CreateParameters(overrides) { async function CreateParameters(overrides: any) {
if (overrides) { if (overrides) {
Cli.options = overrides; Cli.options = overrides;
} }
@ -21,7 +21,6 @@ describe('Cloud Runner Locking', () => {
it('Responds', () => {}); it('Responds', () => {});
if (CloudRunnerOptions.cloudRunnerDebug) { if (CloudRunnerOptions.cloudRunnerDebug) {
it(`Simple Locking End2End Flow`, async () => { it(`Simple Locking End2End Flow`, async () => {
Cli.options.retainWorkspaces = true;
const overrides: any = { const overrides: any = {
versioning: 'None', versioning: 'None',
projectPath: 'test-project', projectPath: 'test-project',

View File

@ -81,7 +81,12 @@ class GitHub {
return result.data.id.toString(); return result.data.id.toString();
} }
public static async updateGitHubCheck(longDescription, summary, result = `neutral`, status = `in_progress`) { public static async updateGitHubCheck(
longDescription: string,
summary: string,
result = `neutral`,
status = `in_progress`,
) {
if (!CloudRunnerOptions.githubChecks) { if (!CloudRunnerOptions.githubChecks) {
return; return;
} }

View File

@ -5946,6 +5946,11 @@ uuid@^8.3.0, uuid@^8.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==
v8-compile-cache@^2.0.3: v8-compile-cache@^2.0.3:
version "2.3.0" version "2.3.0"
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz" resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz"