group all build steps

pull/310/head
Frostebite 2022-01-06 21:24:19 +00:00
parent 8705f428be
commit d6799e3dac
4 changed files with 77 additions and 68 deletions

136
dist/index.js vendored
View File

@ -339,10 +339,10 @@ class Cache {
if (action_1.default.isRunningLocally) { if (action_1.default.isRunningLocally) {
return; return;
} }
core.warning(` core.warning(`
Library folder does not exist. Library folder does not exist.
Consider setting up caching to speed up your workflow, Consider setting up caching to speed up your workflow,
if this is not your first build. if this is not your first build.
`); `);
} }
} }
@ -488,8 +488,8 @@ class CLI {
static runRemoteClientJob() { static runRemoteClientJob() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}'); const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
remote_client_logger_1.RemoteClientLogger.log(`Build Params: remote_client_logger_1.RemoteClientLogger.log(`Build Params:
${JSON.stringify(buildParameter, undefined, 4)} ${JSON.stringify(buildParameter, undefined, 4)}
`); `);
cloud_runner_state_1.CloudRunnerState.setup(buildParameter); cloud_runner_state_1.CloudRunnerState.setup(buildParameter);
yield setup_cloud_runner_repository_1.SetupCloudRunnerRepository.run(); yield setup_cloud_runner_repository_1.SetupCloudRunnerRepository.run();
@ -545,7 +545,7 @@ class Caching {
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
yield Caching.printFullCacheHierarchySize(); yield Caching.printFullCacheHierarchySize();
} }
process.chdir(path_1.default.join(sourceFolder, `..`, `..`)); process.chdir(path_1.default.join(sourceFolder, `/`, `..`));
if (__1.Input.cloudRunnerTests) { if (__1.Input.cloudRunnerTests) {
cloud_runner_logger_1.default.log(`Hashed cache folder ${yield lfs_hashing_1.LFSHashing.hashAllFiles(sourceFolder)}`); cloud_runner_logger_1.default.log(`Hashed cache folder ${yield lfs_hashing_1.LFSHashing.hashAllFiles(sourceFolder)}`);
} }
@ -1500,25 +1500,25 @@ exports.AWSTemplates = void 0;
const fs = __importStar(__webpack_require__(35747)); const fs = __importStar(__webpack_require__(35747));
class AWSTemplates { class AWSTemplates {
static getParameterTemplate(p1) { static getParameterTemplate(p1) {
return ` return `
${p1}: ${p1}:
Type: String Type: String
Default: '' Default: ''
`; `;
} }
static getSecretTemplate(p1) { static getSecretTemplate(p1) {
return ` return `
${p1}Secret: ${p1}Secret:
Type: AWS::SecretsManager::Secret Type: AWS::SecretsManager::Secret
Properties: Properties:
Name: '${p1}' Name: '${p1}'
SecretString: !Ref ${p1} SecretString: !Ref ${p1}
`; `;
} }
static getSecretDefinitionTemplate(p1, p2) { static getSecretDefinitionTemplate(p1, p2) {
return ` return `
- Name: '${p1}' - Name: '${p1}'
ValueFrom: !Ref ${p2}Secret ValueFrom: !Ref ${p2}Secret
`; `;
} }
static insertAtTemplate(template, insertionKey, insertion) { static insertAtTemplate(template, insertionKey, insertion) {
@ -2132,8 +2132,8 @@ class KubernetesJobSpecFactory {
command: [ command: [
'bin/bash', 'bin/bash',
'-c', '-c',
`cd /data/builder/action/steps; `cd /data/builder/action/steps;
chmod +x /return_license.sh; chmod +x /return_license.sh;
/return_license.sh;`, /return_license.sh;`,
], ],
}, },
@ -2551,15 +2551,15 @@ const yaml_1 = __importDefault(__webpack_require__(13552));
class CloudRunnerBuildCommandProcessor { class CloudRunnerBuildCommandProcessor {
static ProcessCommands(commands, buildParameters) { static ProcessCommands(commands, buildParameters) {
const hooks = CloudRunnerBuildCommandProcessor.getHooks().filter((x) => x.step.includes(`all`)); const hooks = CloudRunnerBuildCommandProcessor.getHooks().filter((x) => x.step.includes(`all`));
return `echo "---" return `echo "---"
echo "start cloud runner init" echo "start cloud runner init"
${__1.Input.cloudRunnerTests ? '' : '#'} printenv ${__1.Input.cloudRunnerTests ? '' : '#'} printenv
echo "start cloud runner job" echo "start cloud runner job"
${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
${commands} ${commands}
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
echo "end of cloud runner job echo "end of cloud runner job
---${buildParameters.logId}" ---${buildParameters.logId}"
`; `;
} }
static getHooks() { static getHooks() {
@ -2942,32 +2942,32 @@ class BuildStep {
cloud_runner_logger_1.default.logLine(` `); cloud_runner_logger_1.default.logLine(` `);
cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)'); cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)');
const hooks = cloud_runner_build_command_process_1.CloudRunnerBuildCommandProcessor.getHooks().filter((x) => x.step.includes(`setup`)); const hooks = cloud_runner_build_command_process_1.CloudRunnerBuildCommandProcessor.getHooks().filter((x) => x.step.includes(`setup`));
return yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid, image, ` return yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid, image, `
${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`before`)).map((x) => x.commands) || ' '}
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}" export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
cp -r "${path_1.default cp -r "${path_1.default
.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'default-build-script') .join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'default-build-script')
.replace(/\\/g, `/`)}" "/UnityBuilderAction" .replace(/\\/g, `/`)}" "/UnityBuilderAction"
cp -r "${path_1.default cp -r "${path_1.default
.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'entrypoint.sh') .join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'entrypoint.sh')
.replace(/\\/g, `/`)}" "/entrypoint.sh" .replace(/\\/g, `/`)}" "/entrypoint.sh"
cp -r "${path_1.default.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'steps').replace(/\\/g, `/`)}" "/steps" cp -r "${path_1.default.join(cloud_runner_state_1.CloudRunnerState.builderPathFull, 'dist', 'steps').replace(/\\/g, `/`)}" "/steps"
chmod -R +x "/entrypoint.sh" chmod -R +x "/entrypoint.sh"
chmod -R +x "/steps" chmod -R +x "/steps"
/entrypoint.sh /entrypoint.sh
apt-get update apt-get update
apt-get install -y -q zip tree apt-get install -y -q zip tree
cd "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull.replace(/\\/g, `/`)}/.." cd "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull.replace(/\\/g, `/`)}/.."
zip -r "lib-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "Library" zip -r "lib-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "Library"
mv "lib-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}/lib" mv "lib-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}/lib"
cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull.replace(/\\/g, `/`)}" cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull.replace(/\\/g, `/`)}"
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh
zip -r "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "build" zip -r "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "build"
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}" ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}"
mv "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}" mv "build-${cloud_runner_state_1.CloudRunnerState.buildParams.buildGuid}.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull.replace(/\\/g, `/`)}"
${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}" ${__1.Input.cloudRunnerTests ? '' : '#'} tree -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}"
${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '} ${hooks.filter((x) => x.hook.includes(`after`)).map((x) => x.commands) || ' '}
`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets); `, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
}); });
} }
@ -3105,10 +3105,12 @@ class BuildAutomationWorkflow {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
cloud_runner_logger_1.default.log(`Cloud Runner is running standard build automation`); cloud_runner_logger_1.default.log(`Cloud Runner is running standard build automation`);
core.startGroup('pre build steps');
let output = ''; let output = '';
if (cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps !== '') { if (cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps !== '') {
output += yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps); output += yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.preBuildSteps);
} }
core.endGroup();
cloud_runner_logger_1.default.logWithTime('Configurable pre build step(s) time'); cloud_runner_logger_1.default.logWithTime('Configurable pre build step(s) time');
core.startGroup('setup'); core.startGroup('setup');
output += yield new setup_step_1.SetupStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets)); output += yield new setup_step_1.SetupStep().run(new cloud_runner_step_state_1.CloudRunnerStepState('alpine/git', task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
@ -3118,9 +3120,11 @@ class BuildAutomationWorkflow {
output += yield new build_step_1.BuildStep().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets)); output += yield new build_step_1.BuildStep().run(new cloud_runner_step_state_1.CloudRunnerStepState(baseImage, task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(), cloud_runner_state_1.CloudRunnerState.defaultSecrets));
core.endGroup(); core.endGroup();
cloud_runner_logger_1.default.logWithTime('Build time'); cloud_runner_logger_1.default.logWithTime('Build time');
core.startGroup('post build steps');
if (cloud_runner_state_1.CloudRunnerState.buildParams.postBuildSteps !== '') { if (cloud_runner_state_1.CloudRunnerState.buildParams.postBuildSteps !== '') {
output += yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.postBuildSteps); output += yield custom_workflow_1.CustomWorkflow.runCustomJob(cloud_runner_state_1.CloudRunnerState.buildParams.postBuildSteps);
} }
core.endGroup();
cloud_runner_logger_1.default.logWithTime('Configurable post build step(s) time'); cloud_runner_logger_1.default.logWithTime('Configurable post build step(s) time');
cloud_runner_logger_1.default.log(`Cloud Runner finished running standard build automation`); cloud_runner_logger_1.default.log(`Cloud Runner finished running standard build automation`);
return output; return output;
@ -3278,9 +3282,9 @@ class Docker {
const { path, dockerfile, baseImage } = buildParameters; const { path, dockerfile, baseImage } = buildParameters;
const { version, platform } = baseImage; const { version, platform } = baseImage;
const tag = new image_tag_1.default({ repository: '', name: 'unity-builder', version, platform }); const tag = new image_tag_1.default({ repository: '', name: 'unity-builder', version, platform });
const command = `docker build ${path} \ const command = `docker build ${path} \
--file ${dockerfile} \ --file ${dockerfile} \
--build-arg IMAGE=${baseImage} \ --build-arg IMAGE=${baseImage} \
--tag ${tag}`; --tag ${tag}`;
yield exec_1.exec(command, undefined, { silent }); yield exec_1.exec(command, undefined, { silent });
return tag; return tag;
@ -3289,16 +3293,16 @@ class Docker {
static run(image, parameters, silent = false) { static run(image, parameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { workspace, runnerTempPath, sshAgent } = parameters; const { workspace, runnerTempPath, sshAgent } = parameters;
const command = `docker run \ const command = `docker run \
--workdir /github/workspace \ --workdir /github/workspace \
--rm \ --rm \
${image_environment_factory_1.default.getEnvVarString(parameters)} \ ${image_environment_factory_1.default.getEnvVarString(parameters)} \
--volume "/var/run/docker.sock":"/var/run/docker.sock" \ --volume "/var/run/docker.sock":"/var/run/docker.sock" \
--volume "${runnerTempPath}/_github_home":"/root" \ --volume "${runnerTempPath}/_github_home":"/root" \
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \ --volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \ --volume "${workspace}":"/github/workspace" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \ ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${image}`; ${image}`;
yield exec_1.exec(command, undefined, { silent }); yield exec_1.exec(command, undefined, { silent });
}); });

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ export class Caching {
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
await Caching.printFullCacheHierarchySize(); await Caching.printFullCacheHierarchySize();
} }
process.chdir(path.join(sourceFolder, `..`, `..`)); process.chdir(path.join(sourceFolder, `/`, `..`));
if (Input.cloudRunnerTests) { if (Input.cloudRunnerTests) {
CloudRunnerLogger.log(`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)}`); CloudRunnerLogger.log(`Hashed cache folder ${await LFSHashing.hashAllFiles(sourceFolder)}`);

View File

@ -20,10 +20,13 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
private static async standardBuildAutomation(baseImage: any) { private static async standardBuildAutomation(baseImage: any) {
try { try {
CloudRunnerLogger.log(`Cloud Runner is running standard build automation`); CloudRunnerLogger.log(`Cloud Runner is running standard build automation`);
core.startGroup('pre build steps');
let output = ''; let output = '';
if (CloudRunnerState.buildParams.preBuildSteps !== '') { if (CloudRunnerState.buildParams.preBuildSteps !== '') {
output += await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.preBuildSteps); output += await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.preBuildSteps);
} }
core.endGroup();
CloudRunnerLogger.logWithTime('Configurable pre build step(s) time'); CloudRunnerLogger.logWithTime('Configurable pre build step(s) time');
core.startGroup('setup'); core.startGroup('setup');
@ -48,9 +51,11 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
core.endGroup(); core.endGroup();
CloudRunnerLogger.logWithTime('Build time'); CloudRunnerLogger.logWithTime('Build time');
core.startGroup('post build steps');
if (CloudRunnerState.buildParams.postBuildSteps !== '') { if (CloudRunnerState.buildParams.postBuildSteps !== '') {
output += await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.postBuildSteps); output += await CustomWorkflow.runCustomJob(CloudRunnerState.buildParams.postBuildSteps);
} }
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`);