mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00

* feat: streamline code styles * feat: spacing for comments and return statements * chore: enforce camelcase * fix: remove npm lock file * fix: add integrity test * fix: remove logfile * chore: update node in test workflow
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { BuildParameters } from '../..';
|
|
import YAML from 'yaml';
|
|
import CloudRunnerSecret from './cloud-runner-secret';
|
|
import CloudRunner from '../cloud-runner';
|
|
|
|
export class CloudRunnerBuildCommandProcessor {
|
|
public static ProcessCommands(commands: string, buildParameters: BuildParameters): string {
|
|
const hooks = CloudRunnerBuildCommandProcessor.getHooks(buildParameters.customJobHooks).filter((x) =>
|
|
x.step.includes(`all`),
|
|
);
|
|
|
|
return `echo "---"
|
|
echo "start cloud runner init"
|
|
${CloudRunner.buildParameters.cloudRunnerIntegrationTests ? '' : '#'} printenv
|
|
echo "start of cloud runner job"
|
|
${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
|
|
${commands}
|
|
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
|
|
echo "end of cloud runner job"
|
|
echo "---${buildParameters.logId}"`;
|
|
}
|
|
|
|
public static getHooks(customJobHooks): Hook[] {
|
|
const experimentHooks = customJobHooks;
|
|
let output = new Array<Hook>();
|
|
if (experimentHooks && experimentHooks !== '') {
|
|
try {
|
|
output = YAML.parse(experimentHooks);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0);
|
|
}
|
|
}
|
|
export class Hook {
|
|
public commands;
|
|
public secrets: CloudRunnerSecret[] = new Array<CloudRunnerSecret>();
|
|
public name;
|
|
public hook!: string[];
|
|
public step!: string[];
|
|
}
|