pull/289/head
Frostebite 2021-09-08 21:29:02 +01:00
parent 36d9f69c9e
commit 675b40c1fb
2 changed files with 78 additions and 78 deletions

154
dist/index.js vendored
View File

@ -300,10 +300,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.
`); `);
} }
} }
@ -402,25 +402,25 @@ class AWSBuildEnvironment {
}); });
} }
getParameterTemplate(p1) { getParameterTemplate(p1) {
return ` return `
${p1}: ${p1}:
Type: String Type: String
Default: '' Default: ''
`; `;
} }
getSecretTemplate(p1) { getSecretTemplate(p1) {
return ` return `
${p1}Secret: ${p1}Secret:
Type: AWS::SecretsManager::Secret Type: AWS::SecretsManager::Secret
Properties: Properties:
Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ] Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ]
SecretString: !Ref ${p1} SecretString: !Ref ${p1}
`; `;
} }
getSecretDefinitionTemplate(p1, p2) { getSecretDefinitionTemplate(p1, p2) {
return ` return `
- Name: '${p1}' - Name: '${p1}'
ValueFrom: !Ref ${p2}Secret ValueFrom: !Ref ${p2}Secret
`; `;
} }
insertAtTemplate(template, insertionKey, insertion) { insertAtTemplate(template, insertionKey, insertion) {
@ -431,8 +431,8 @@ class AWSBuildEnvironment {
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) { setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)(); const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)();
commands[1] += ` commands[1] += `
echo "${logGuid}" echo "${logGuid}"
`; `;
yield this.setupBaseStack(CF); yield this.setupBaseStack(CF);
const taskDefStackName = `${this.baseStackName}-${buildGuid}`; const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
@ -1207,32 +1207,32 @@ class CloudRunner {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info('Starting step 1/4 clone and restore cache)'); core.info('Starting step 1/4 clone and restore cache)');
yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, 'alpine/git', [ yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, 'alpine/git', [
` printenv ` printenv
apk update -q apk update -q
apk add unzip zip git-lfs jq tree -q apk add unzip zip git-lfs jq tree -q
mkdir -p ${this.buildPathFull} mkdir -p ${this.buildPathFull}
mkdir -p ${this.builderPathFull} mkdir -p ${this.builderPathFull}
mkdir -p ${this.repoPathFull} mkdir -p ${this.repoPathFull}
${this.getCloneBuilder()} ${this.getCloneBuilder()}
echo ' ' echo ' '
echo 'Initializing source repository for cloning with caching of LFS files' echo 'Initializing source repository for cloning with caching of LFS files'
${this.getCloneNoLFSCommand()} ${this.getCloneNoLFSCommand()}
echo 'Source repository initialized' echo 'Source repository initialized'
echo ' ' echo ' '
${process.env.DEBUG ? '' : '#'}echo $LFS_ASSETS_HASH ${process.env.DEBUG ? '' : '#'}echo $LFS_ASSETS_HASH
${process.env.DEBUG ? '' : '#'}echo 'Large File before LFS caching and pull' ${process.env.DEBUG ? '' : '#'}echo 'Large File before LFS caching and pull'
${process.env.DEBUG ? '' : '#'}ls -alh "${this.lfsDirectory}" ${process.env.DEBUG ? '' : '#'}ls -alh "${this.lfsDirectory}"
${process.env.DEBUG ? '' : '#'}echo ' ' ${process.env.DEBUG ? '' : '#'}echo ' '
echo 'Starting checks of cache for the Unity project Library and git LFS files' echo 'Starting checks of cache for the Unity project Library and git LFS files'
${this.getHandleCachingCommand()} ${this.getHandleCachingCommand()}
${process.env.DEBUG ? '' : '#'}echo 'Caching complete' ${process.env.DEBUG ? '' : '#'}echo 'Caching complete'
${process.env.DEBUG ? '' : '#'}echo ' ' ${process.env.DEBUG ? '' : '#'}echo ' '
${process.env.DEBUG ? '' : '#'}echo 'Large File after LFS caching and pull' ${process.env.DEBUG ? '' : '#'}echo 'Large File after LFS caching and pull'
${process.env.DEBUG ? '' : '#'}ls -alh "${this.lfsDirectory}" ${process.env.DEBUG ? '' : '#'}ls -alh "${this.lfsDirectory}"
${process.env.DEBUG ? '' : '#'}echo ' ' ${process.env.DEBUG ? '' : '#'}echo ' '
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}" ${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}" ${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
${process.env.DEBUG ? '' : '#'}echo ' ' ${process.env.DEBUG ? '' : '#'}echo ' '
`, `,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, CloudRunner.defaultGitShaEnvironmentVariable, this.defaultSecrets); ], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, CloudRunner.defaultGitShaEnvironmentVariable, this.defaultSecrets);
}); });
@ -1241,17 +1241,17 @@ class CloudRunner {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
core.info('Starting part 2/4 (build unity project)'); core.info('Starting part 2/4 (build unity project)');
yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, baseImage.toString(), [ yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, baseImage.toString(), [
` `
printenv printenv
export GITHUB_WORKSPACE="${this.repoPathFull}" export GITHUB_WORKSPACE="${this.repoPathFull}"
cp -r "${this.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction" cp -r "${this.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
cp -r "${this.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh" cp -r "${this.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
cp -r "${this.builderPathFull}/dist/steps/" "/steps" cp -r "${this.builderPathFull}/dist/steps/" "/steps"
chmod -R +x "/entrypoint.sh" chmod -R +x "/entrypoint.sh"
chmod -R +x "/steps" chmod -R +x "/steps"
/entrypoint.sh /entrypoint.sh
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}" ${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}" ${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
`, `,
], `/${buildVolumeFolder}`, `/${this.projectPathFull}`, CloudRunner.readBuildEnvironmentVariables(), this.defaultSecrets); ], `/${buildVolumeFolder}`, `/${this.projectPathFull}`, CloudRunner.readBuildEnvironmentVariables(), this.defaultSecrets);
}); });
@ -1261,23 +1261,23 @@ class CloudRunner {
core.info('Starting step 3/4 build compression'); core.info('Starting step 3/4 build compression');
// Cleanup // Cleanup
yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, 'alpine', [ yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, 'alpine', [
` `
printenv printenv
apk update -q apk update -q
apk add zip tree -q apk add zip tree -q
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull" ${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull" ${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
cd "$libraryFolderFull/.." cd "$libraryFolderFull/.."
zip -r "lib-$BUILDID.zip" "./Library" zip -r "lib-$BUILDID.zip" "./Library"
mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib" mv "lib-$BUILDID.zip" "/$cacheFolderFull/lib"
cd "$repoPathFull" cd "$repoPathFull"
ls -lh "$repoPathFull" ls -lh "$repoPathFull"
zip -r "build-$BUILDID.zip" "./${CloudRunner.buildParams.buildPath}" zip -r "build-$BUILDID.zip" "./${CloudRunner.buildParams.buildPath}"
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip" mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
${process.env.DEBUG ? '' : '#'}tree -L 4 "/$cacheFolderFull" ${process.env.DEBUG ? '' : '#'}tree -L 4 "/$cacheFolderFull"
${process.env.DEBUG ? '' : '#'}tree -L 4 "/$cacheFolderFull/.." ${process.env.DEBUG ? '' : '#'}tree -L 4 "/$cacheFolderFull/.."
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull" ${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull" ${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
`, `,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [ ], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
...CloudRunner.defaultGitShaEnvironmentVariable, ...CloudRunner.defaultGitShaEnvironmentVariable,
@ -1388,7 +1388,7 @@ class Kubernetes {
defaultSecretsArray) { defaultSecretsArray) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
this.pvcName = `unity-builder-pvc`; this.pvcName = `unity-builder-pvc-${buildGuid}`;
this.cleanupCronJobName = `unity-builder-cronjob-${buildGuid}`; this.cleanupCronJobName = `unity-builder-cronjob-${buildGuid}`;
this.serviceAccountName = `service-account-${buildGuid}`; this.serviceAccountName = `service-account-${buildGuid}`;
yield kubernetes_storage_1.default.createPersistentVolumeClaim(buildParameters, this.pvcName, this.kubeClient, this.namespace); yield kubernetes_storage_1.default.createPersistentVolumeClaim(buildParameters, this.pvcName, this.kubeClient, this.namespace);
@ -2012,7 +2012,7 @@ class KubernetesStorage {
name: pvcName, name: pvcName,
}; };
pvc.spec = { pvc.spec = {
accessModes: ['ReadWriteMany'], accessModes: ['ReadWriteOnce'],
storageClassName: process.env.K8s_STORAGE_CLASS || 'fileserver', storageClassName: process.env.K8s_STORAGE_CLASS || 'fileserver',
resources: { resources: {
requests: { requests: {
@ -2426,8 +2426,8 @@ class ImageTag {
case platform_1.default.types.Test: case platform_1.default.types.Test:
return generic; return generic;
default: default:
throw new Error(` throw new Error(`
Platform must be one of the ones described in the documentation. Platform must be one of the ones described in the documentation.
"${platform}" is currently not supported.`); "${platform}" is currently not supported.`);
} }
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long