async workflow test
parent
83fb0b89da
commit
2f36b29ba6
|
|
@ -862,7 +862,7 @@ class CloudRunnerOptions {
|
||||||
return CloudRunnerOptions.getInput(`cloudRunnerDebugEnv`) || false;
|
return CloudRunnerOptions.getInput(`cloudRunnerDebugEnv`) || false;
|
||||||
}
|
}
|
||||||
static get watchCloudRunnerToEnd() {
|
static get watchCloudRunnerToEnd() {
|
||||||
return (CloudRunnerOptions.getInput(`watchToEnd`) || true) !== 'false';
|
return (CloudRunnerOptions.getInput(`watchToEnd`) || CloudRunnerOptions.asyncCloudRunner() || true) !== 'false';
|
||||||
}
|
}
|
||||||
static get asyncCloudRunner() {
|
static get asyncCloudRunner() {
|
||||||
return CloudRunnerOptions.getInput('asyncCloudRunner') || false;
|
return CloudRunnerOptions.getInput('asyncCloudRunner') || false;
|
||||||
|
|
@ -1609,7 +1609,7 @@ class AWSTaskRunner {
|
||||||
cloud_runner_logger_1.default.log('Cloud runner job is starting');
|
cloud_runner_logger_1.default.log('Cloud runner job is starting');
|
||||||
yield AWSTaskRunner.waitUntilTaskRunning(taskArn, cluster);
|
yield AWSTaskRunner.waitUntilTaskRunning(taskArn, cluster);
|
||||||
cloud_runner_logger_1.default.log(`Cloud runner job status is running ${(_p = (yield AWSTaskRunner.describeTasks(cluster, taskArn))) === null || _p === void 0 ? void 0 : _p.lastStatus}`);
|
cloud_runner_logger_1.default.log(`Cloud runner job status is running ${(_p = (yield AWSTaskRunner.describeTasks(cluster, taskArn))) === null || _p === void 0 ? void 0 : _p.lastStatus}`);
|
||||||
if (!cloud_runner_options_1.default.watchCloudRunnerToEnd || cloud_runner_options_1.default.asyncCloudRunner) {
|
if (!cloud_runner_options_1.default.watchCloudRunnerToEnd) {
|
||||||
const shouldCleanup = false;
|
const shouldCleanup = false;
|
||||||
const output = '';
|
const output = '';
|
||||||
cloud_runner_logger_1.default.log(`Watch Cloud Runner To End: false`);
|
cloud_runner_logger_1.default.log(`Watch Cloud Runner To End: false`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -235,7 +235,7 @@ class CloudRunnerOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
static get watchCloudRunnerToEnd(): boolean {
|
static get watchCloudRunnerToEnd(): boolean {
|
||||||
return (CloudRunnerOptions.getInput(`watchToEnd`) || true) !== 'false';
|
return (CloudRunnerOptions.getInput(`watchToEnd`) || CloudRunnerOptions.asyncCloudRunner() || true) !== 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
static get asyncCloudRunner() {
|
static get asyncCloudRunner() {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class AWSTaskRunner {
|
||||||
CloudRunnerLogger.log(
|
CloudRunnerLogger.log(
|
||||||
`Cloud runner job status is running ${(await AWSTaskRunner.describeTasks(cluster, taskArn))?.lastStatus}`,
|
`Cloud runner job status is running ${(await AWSTaskRunner.describeTasks(cluster, taskArn))?.lastStatus}`,
|
||||||
);
|
);
|
||||||
if (!CloudRunnerOptions.watchCloudRunnerToEnd || CloudRunnerOptions.asyncCloudRunner) {
|
if (!CloudRunnerOptions.watchCloudRunnerToEnd) {
|
||||||
const shouldCleanup: boolean = false;
|
const shouldCleanup: boolean = false;
|
||||||
const output: string = '';
|
const output: string = '';
|
||||||
CloudRunnerLogger.log(`Watch Cloud Runner To End: false`);
|
CloudRunnerLogger.log(`Watch Cloud Runner To End: false`);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import { BuildParameters, ImageTag } from '../..';
|
||||||
|
import CloudRunner from '../cloud-runner';
|
||||||
|
import Input from '../../input';
|
||||||
|
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
||||||
|
import { TaskParameterSerializer } from '../services/task-parameter-serializer';
|
||||||
|
import UnityVersioning from '../../unity-versioning';
|
||||||
|
import { Cli } from '../../cli/cli';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
import CloudRunnerOptions from '../cloud-runner-options';
|
||||||
|
import setups from './cloud-runner-suite.test';
|
||||||
|
|
||||||
|
async function CreateParameters(overrides) {
|
||||||
|
if (overrides) Cli.options = overrides;
|
||||||
|
|
||||||
|
return BuildParameters.create();
|
||||||
|
}
|
||||||
|
describe('Cloud Runner Async Workflows', () => {
|
||||||
|
setups();
|
||||||
|
const testSecretName = 'testSecretName';
|
||||||
|
const testSecretValue = 'testSecretValue';
|
||||||
|
it('Responds', () => {});
|
||||||
|
|
||||||
|
if (CloudRunnerOptions.cloudRunnerDebug && CloudRunnerOptions.cloudRunnerCluster !== `k8s`) {
|
||||||
|
it('All build parameters sent to cloud runner as env vars', async () => {
|
||||||
|
// Setup parameters
|
||||||
|
const buildParameter = await CreateParameters({
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.read('test-project'),
|
||||||
|
asyncCloudRunner: true,
|
||||||
|
customJob: `
|
||||||
|
- name: 'step 1'
|
||||||
|
image: 'ubuntu'
|
||||||
|
commands: 'printenv'
|
||||||
|
secrets:
|
||||||
|
- name: '${testSecretName}'
|
||||||
|
value: '${testSecretValue}'
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
const baseImage = new ImageTag(buildParameter);
|
||||||
|
|
||||||
|
// Run the job
|
||||||
|
const file = await CloudRunner.run(buildParameter, baseImage.toString());
|
||||||
|
|
||||||
|
// Assert results
|
||||||
|
// expect(file).toContain(JSON.stringify(buildParameter));
|
||||||
|
expect(file).toContain(`${Input.ToEnvVarFormat(testSecretName)}=${testSecretValue}`);
|
||||||
|
const environmentVariables = TaskParameterSerializer.createCloudRunnerEnvironmentVariables(buildParameter);
|
||||||
|
const secrets = TaskParameterSerializer.readDefaultSecrets().map((x) => {
|
||||||
|
return {
|
||||||
|
name: x.EnvironmentVariable,
|
||||||
|
value: x.ParameterValue,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const combined = [...environmentVariables, ...secrets]
|
||||||
|
.filter((element) => element.value !== undefined && element.value !== '' && typeof element.value !== 'function')
|
||||||
|
.map((x) => {
|
||||||
|
if (typeof x.value === `string`) {
|
||||||
|
x.value = x.value.replace(/\s+/g, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return x;
|
||||||
|
})
|
||||||
|
.filter((element) => {
|
||||||
|
return !['UNITY_LICENSE', 'CUSTOM_JOB'].includes(element.name);
|
||||||
|
});
|
||||||
|
const newLinePurgedFile = file
|
||||||
|
.replace(/\s+/g, '')
|
||||||
|
.replace(new RegExp(`\\[${CloudRunnerStatics.logPrefix}\\]`, 'g'), '');
|
||||||
|
for (const element of combined) {
|
||||||
|
expect(newLinePurgedFile).toContain(`${element.name}`);
|
||||||
|
CloudRunnerLogger.log(`Contains ${element.name}`);
|
||||||
|
const fullNameEqualValue = `${element.name}=${element.value}`;
|
||||||
|
expect(newLinePurgedFile).toContain(fullNameEqualValue);
|
||||||
|
}
|
||||||
|
}, 1_000_000_000);
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue