2022-11-07 20:41:00 +00:00
|
|
|
import CloudRunner from '../cloud-runner';
|
|
|
|
|
import { BuildParameters, ImageTag } from '../..';
|
|
|
|
|
import UnityVersioning from '../../unity-versioning';
|
|
|
|
|
import { Cli } from '../../cli/cli';
|
|
|
|
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
|
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
|
import CloudRunnerOptions from '../cloud-runner-options';
|
|
|
|
|
import setups from './cloud-runner-suite.test';
|
|
|
|
|
import { CloudRunnerCustomSteps } from '../services/cloud-runner-custom-steps';
|
2023-02-12 13:22:47 +00:00
|
|
|
import { CloudRunnerCustomHooks } from '../services/cloud-runner-custom-hooks';
|
2022-11-07 20:41:00 +00:00
|
|
|
|
2023-03-07 16:42:34 +00:00
|
|
|
async function CreateParameters(overrides: any) {
|
2022-11-07 20:41:00 +00:00
|
|
|
if (overrides) {
|
|
|
|
|
Cli.options = overrides;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await BuildParameters.create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('Cloud Runner Custom Hooks And Steps', () => {
|
|
|
|
|
it('Responds', () => {});
|
|
|
|
|
setups();
|
|
|
|
|
it('Check parsing and reading of steps', async () => {
|
|
|
|
|
const yamlString = `hook: before
|
|
|
|
|
commands: echo "test"`;
|
|
|
|
|
const yamlString2 = `- hook: before
|
|
|
|
|
commands: echo "test"`;
|
Cloud runner develop - better parameterization of s3 usage, improved async workflow and GC, github checks early integration (#479)
* custom steps may leave value undefined, will be pulled from env vars
* custom steps may leave value undefined, will be pulled from env vars
* custom steps may leave value undefined, will be pulled from env vars
* add 3 new premade steps, steam-deploy-client, steam-deploy-project, aws-s3-pull-build
* fix
* fix
* fix
* continue building async-workflow support
* test checks
* test checks
* test checks
* move github checks within build workflow
* async workflow test
* async workflow test
* async workflow test
* async workflow test
* async workflow test
* async workflow test
* async workflow test
* async workflow test for aws only
* async workflow test for aws only
* async workflow test for aws only
* async workflow test for aws only
* cleanup logging
* disable lz4 compression by default
* disable lz4 compression by default
* AWS BASE STACK for tests
* AWS BASE STACK for tests
* AWS BASE STACK for tests
* AWS BASE STACK for tests
* AWS BASE STACK for tests
* AWS BASE STACK for tests
* disable lz4 compression by default
* disable lz4 compression by default
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* Update github check with aws log
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* kinesis and subscription filter for logs creation skipped when watchToEnd false
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* cleanup local pipeline, log aws formation
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* async pipeline
* workflow
* workflow
* workflow
* workflow
* workflow
* workflow
* workflow
* workflow
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
* parameterize s3
2023-01-20 17:40:57 +00:00
|
|
|
const overrides = {
|
|
|
|
|
versioning: 'None',
|
|
|
|
|
projectPath: 'test-project',
|
|
|
|
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
|
|
|
|
targetPlatform: 'StandaloneLinux64',
|
|
|
|
|
cacheKey: `test-case-${uuidv4()}`,
|
|
|
|
|
};
|
|
|
|
|
CloudRunner.setup(await CreateParameters(overrides));
|
2022-11-07 20:41:00 +00:00
|
|
|
const stringObject = CloudRunnerCustomSteps.ParseSteps(yamlString);
|
|
|
|
|
const stringObject2 = CloudRunnerCustomSteps.ParseSteps(yamlString2);
|
|
|
|
|
|
|
|
|
|
CloudRunnerLogger.log(yamlString);
|
|
|
|
|
CloudRunnerLogger.log(JSON.stringify(stringObject, undefined, 4));
|
|
|
|
|
|
|
|
|
|
expect(stringObject.length).toBe(1);
|
|
|
|
|
expect(stringObject[0].hook).toBe(`before`);
|
|
|
|
|
expect(stringObject2.length).toBe(1);
|
|
|
|
|
expect(stringObject2[0].hook).toBe(`before`);
|
|
|
|
|
|
|
|
|
|
const getCustomStepsFromFiles = CloudRunnerCustomSteps.GetCustomStepsFromFiles(`before`);
|
|
|
|
|
CloudRunnerLogger.log(JSON.stringify(getCustomStepsFromFiles, undefined, 4));
|
|
|
|
|
});
|
2023-03-19 11:08:42 +00:00
|
|
|
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.providerStrategy !== `k8s`) {
|
2023-02-12 13:22:47 +00:00
|
|
|
it('Should be 1 before and 1 after hook', async () => {
|
2023-02-12 14:23:16 +00:00
|
|
|
const overrides = {
|
|
|
|
|
versioning: 'None',
|
|
|
|
|
projectPath: 'test-project',
|
|
|
|
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
|
|
|
|
targetPlatform: 'StandaloneLinux64',
|
|
|
|
|
cacheKey: `test-case-${uuidv4()}`,
|
|
|
|
|
customStepFiles: `my-test-step-pre-build,my-test-step-post-build`,
|
|
|
|
|
customHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
|
|
|
|
|
};
|
|
|
|
|
const buildParameter2 = await CreateParameters(overrides);
|
|
|
|
|
await CloudRunner.setup(buildParameter2);
|
2023-02-12 13:22:47 +00:00
|
|
|
const beforeHooks = CloudRunnerCustomHooks.GetCustomHooksFromFiles(`before`);
|
|
|
|
|
const afterHooks = CloudRunnerCustomHooks.GetCustomHooksFromFiles(`after`);
|
|
|
|
|
expect(beforeHooks).toHaveLength(1);
|
|
|
|
|
expect(afterHooks).toHaveLength(1);
|
|
|
|
|
});
|
2023-02-12 13:24:55 +00:00
|
|
|
it('Should be 1 before and 1 after step', async () => {
|
2023-02-12 14:23:16 +00:00
|
|
|
const overrides = {
|
|
|
|
|
versioning: 'None',
|
|
|
|
|
projectPath: 'test-project',
|
|
|
|
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
|
|
|
|
targetPlatform: 'StandaloneLinux64',
|
|
|
|
|
cacheKey: `test-case-${uuidv4()}`,
|
|
|
|
|
customStepFiles: `my-test-step-pre-build,my-test-step-post-build`,
|
|
|
|
|
customHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
|
|
|
|
|
};
|
|
|
|
|
const buildParameter2 = await CreateParameters(overrides);
|
|
|
|
|
await CloudRunner.setup(buildParameter2);
|
2023-02-12 13:24:55 +00:00
|
|
|
const beforeSteps = CloudRunnerCustomSteps.GetCustomStepsFromFiles(`before`);
|
|
|
|
|
const afterSteps = CloudRunnerCustomSteps.GetCustomStepsFromFiles(`after`);
|
|
|
|
|
expect(beforeSteps).toHaveLength(1);
|
|
|
|
|
expect(afterSteps).toHaveLength(1);
|
|
|
|
|
});
|
2022-11-07 20:41:00 +00:00
|
|
|
it('Run build once - check for pre and post custom hooks run contents', async () => {
|
|
|
|
|
const overrides = {
|
|
|
|
|
versioning: 'None',
|
|
|
|
|
projectPath: 'test-project',
|
|
|
|
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
|
|
|
|
targetPlatform: 'StandaloneLinux64',
|
|
|
|
|
cacheKey: `test-case-${uuidv4()}`,
|
|
|
|
|
customStepFiles: `my-test-step-pre-build,my-test-step-post-build`,
|
2023-02-12 12:27:37 +00:00
|
|
|
customHookFiles: `my-test-hook-pre-build,my-test-hook-post-build`,
|
2022-11-07 20:41:00 +00:00
|
|
|
};
|
|
|
|
|
const buildParameter2 = await CreateParameters(overrides);
|
|
|
|
|
const baseImage2 = new ImageTag(buildParameter2);
|
|
|
|
|
const results2 = await CloudRunner.run(buildParameter2, baseImage2.toString());
|
|
|
|
|
CloudRunnerLogger.log(`run 2 succeeded`);
|
|
|
|
|
|
2023-02-12 03:47:59 +00:00
|
|
|
const buildContainsBuildSucceeded = results2.includes('Build succeeded');
|
|
|
|
|
const buildContainsPreBuildHookRunMessage = results2.includes('before-build hook test!');
|
|
|
|
|
const buildContainsPostBuildHookRunMessage = results2.includes('after-build hook test!');
|
2022-11-07 20:41:00 +00:00
|
|
|
|
2023-02-12 03:47:59 +00:00
|
|
|
const buildContainsPreBuildStepMessage = results2.includes('before-build step test!');
|
|
|
|
|
const buildContainsPostBuildStepMessage = results2.includes('after-build step test!');
|
2022-11-07 20:41:00 +00:00
|
|
|
|
2023-02-12 03:47:59 +00:00
|
|
|
expect(buildContainsBuildSucceeded).toBeTruthy();
|
|
|
|
|
expect(buildContainsPreBuildHookRunMessage).toBeTruthy();
|
|
|
|
|
expect(buildContainsPostBuildHookRunMessage).toBeTruthy();
|
|
|
|
|
expect(buildContainsPreBuildStepMessage).toBeTruthy();
|
|
|
|
|
expect(buildContainsPostBuildStepMessage).toBeTruthy();
|
2022-11-07 20:41:00 +00:00
|
|
|
}, 1_000_000_000);
|
|
|
|
|
}
|
|
|
|
|
});
|