Refmoving deploy to steam and upload to s3 as remote builder step

pull/289/head
Frostebite 2021-08-15 22:59:07 +00:00 committed by GitHub
parent c80b47473b
commit adc14cfd72
5 changed files with 23 additions and 97 deletions

51
dist/index.js vendored
View File

@ -921,12 +921,21 @@ class AWSBuildEnvironment {
const ECS = new SDK.ECS(); const ECS = new SDK.ECS();
const CF = new SDK.CloudFormation(); const CF = new SDK.CloudFormation();
const entrypoint = ['/bin/sh']; const entrypoint = ['/bin/sh'];
const t0 = Date.now();
const taskDef = yield this.setupCloudFormations(CF, buildId, image, entrypoint, commands, mountdir, workingdir, secrets); const taskDef = yield this.setupCloudFormations(CF, buildId, image, entrypoint, commands, mountdir, workingdir, secrets);
let t2;
try { try {
const t1 = Date.now();
core.info(`Setup job time: ${Math.floor((t0 - t1) / 1000)}`);
yield aws_build_runner_1.default.runTask(taskDef, ECS, CF, environment, buildId, commands); yield aws_build_runner_1.default.runTask(taskDef, ECS, CF, environment, buildId, commands);
t2 = Date.now();
core.info(`Run job time: ${Math.floor((t1 - t2) / 1000)}`);
} }
finally { finally {
yield this.cleanupResources(CF, taskDef); yield this.cleanupResources(CF, taskDef);
const t3 = Date.now();
if (t2 !== undefined)
core.info(`Cleanup job time: ${Math.floor((t2 - t3) / 1000)}`);
} }
}); });
} }
@ -1428,7 +1437,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-${buildGuid}`; this.pvcName = `unity-builder-pvc`;
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);
@ -2231,6 +2240,7 @@ class RemoteBuilder {
yield RemoteBuilder.BuildStep(baseImage); yield RemoteBuilder.BuildStep(baseImage);
const t3 = Date.now(); const t3 = Date.now();
core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}`); core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}`);
yield RemoteBuilder.CompressionStep();
core.info(`Post build steps ${this.buildParams.postBuildSteps}`); core.info(`Post build steps ${this.buildParams.postBuildSteps}`);
this.buildParams.postBuildSteps = yaml_1.default.parse(this.buildParams.postBuildSteps); this.buildParams.postBuildSteps = yaml_1.default.parse(this.buildParams.postBuildSteps);
core.info(`Post build steps ${JSON.stringify(this.buildParams.postBuildSteps, undefined, 4)}`); core.info(`Post build steps ${JSON.stringify(this.buildParams.postBuildSteps, undefined, 4)}`);
@ -2250,10 +2260,6 @@ class RemoteBuilder {
}, },
], [...this.defaultSecrets, ...stepSecrets]); ], [...this.defaultSecrets, ...stepSecrets]);
} }
yield RemoteBuilder.CompressionStep();
yield RemoteBuilder.UploadArtifacts();
if (this.SteamDeploy)
yield RemoteBuilder.DeployToSteam();
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets); yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
} }
catch (error) { catch (error) {
@ -2371,41 +2377,6 @@ class RemoteBuilder {
core.info('compression step complete'); core.info('compression step complete');
}); });
} }
static UploadArtifacts() {
return __awaiter(this, void 0, void 0, function* () {
core.info('Starting step 4/4 upload build to s3');
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'amazon/aws-cli', [
`
aws s3 cp ${this.buildGuid}/build-${this.buildGuid}.zip "s3://${this.buildParams.awsBaseStackName}-storage/"
# no need to upload Library cache for now
# aws s3 cp "/${buildVolumeFolder}/${cacheFolder}/$branch/lib-${this.buildGuid}.zip" "s3://${this.buildParams.awsBaseStackName}-storage/"
${this.SteamDeploy ? '#' : ''} rm -r ${this.buildGuid}
`,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, RemoteBuilder.readUploadArtifactEnvironmentVariables(), RemoteBuilder.readUploadArtifactsSecrets());
});
}
static DeployToSteam() {
return __awaiter(this, void 0, void 0, function* () {
core.info('Starting steam deployment');
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'cm2network/steamcmd:root', [
`
ls
ls /
cp -r /${buildVolumeFolder}/${this.buildGuid}/steam/action/entrypoint.sh /entrypoint.sh;
cp -r /${buildVolumeFolder}/${this.buildGuid}/steam/action/steps/ /steps;
chmod -R +x /entrypoint.sh;
chmod -R +x /steps;
/entrypoint.sh;
rm -r /${buildVolumeFolder}/${this.buildGuid}
`,
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/${this.buildGuid}/steam/action/`, [
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
], RemoteBuilder.readDeployToSteamSecrets());
});
}
static setupBuildPlatform() { static setupBuildPlatform() {
switch (this.buildParams.remoteBuildCluster) { switch (this.buildParams.remoteBuildCluster) {
case 'aws': case 'aws':

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -50,7 +50,7 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
const ECS = new SDK.ECS(); const ECS = new SDK.ECS();
const CF = new SDK.CloudFormation(); const CF = new SDK.CloudFormation();
const entrypoint = ['/bin/sh']; const entrypoint = ['/bin/sh'];
const t0 = Date.now();
const taskDef = await this.setupCloudFormations( const taskDef = await this.setupCloudFormations(
CF, CF,
buildId, buildId,
@ -61,10 +61,18 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
workingdir, workingdir,
secrets, secrets,
); );
let t2;
try { try {
const t1 = Date.now();
core.info(`Setup job time: ${Math.floor((t0 - t1) / 1000)}`);
await AWSBuildRunner.runTask(taskDef, ECS, CF, environment, buildId, commands); await AWSBuildRunner.runTask(taskDef, ECS, CF, environment, buildId, commands);
t2 = Date.now();
core.info(`Run job time: ${Math.floor((t1 - t2) / 1000)}`);
} finally { } finally {
await this.cleanupResources(CF, taskDef); await this.cleanupResources(CF, taskDef);
const t3 = Date.now();
if (t2 !== undefined) core.info(`Cleanup job time: ${Math.floor((t2 - t3) / 1000)}`);
} }
} }

View File

@ -49,7 +49,7 @@ class Kubernetes implements RemoteBuilderProviderInterface {
defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[],
) { ) {
try { try {
this.pvcName = `unity-builder-pvc-${buildGuid}`; this.pvcName = `unity-builder-pvc`;
this.cleanupCronJobName = `unity-builder-cronjob-${buildGuid}`; this.cleanupCronJobName = `unity-builder-cronjob-${buildGuid}`;
this.serviceAccountName = `service-account-${buildGuid}`; this.serviceAccountName = `service-account-${buildGuid}`;
await KubernetesStorage.createPersistentVolumeClaim( await KubernetesStorage.createPersistentVolumeClaim(

View File

@ -57,6 +57,7 @@ class RemoteBuilder {
await RemoteBuilder.BuildStep(baseImage); await RemoteBuilder.BuildStep(baseImage);
const t3 = Date.now(); const t3 = Date.now();
core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}`); core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}`);
await RemoteBuilder.CompressionStep();
core.info(`Post build steps ${this.buildParams.postBuildSteps}`); core.info(`Post build steps ${this.buildParams.postBuildSteps}`);
this.buildParams.postBuildSteps = YAML.parse(this.buildParams.postBuildSteps); this.buildParams.postBuildSteps = YAML.parse(this.buildParams.postBuildSteps);
core.info(`Post build steps ${JSON.stringify(this.buildParams.postBuildSteps, undefined, 4)}`); core.info(`Post build steps ${JSON.stringify(this.buildParams.postBuildSteps, undefined, 4)}`);
@ -84,9 +85,6 @@ class RemoteBuilder {
[...this.defaultSecrets, ...stepSecrets], [...this.defaultSecrets, ...stepSecrets],
); );
} }
await RemoteBuilder.CompressionStep();
await RemoteBuilder.UploadArtifacts();
if (this.SteamDeploy) await RemoteBuilder.DeployToSteam();
await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources( await this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(
this.buildGuid, this.buildGuid,
this.buildParams, this.buildParams,
@ -233,57 +231,6 @@ class RemoteBuilder {
core.info('compression step complete'); core.info('compression step complete');
} }
private static async UploadArtifacts() {
core.info('Starting step 4/4 upload build to s3');
await this.RemoteBuilderProviderPlatform.runBuildTask(
this.buildGuid,
'amazon/aws-cli',
[
`
aws s3 cp ${this.buildGuid}/build-${this.buildGuid}.zip "s3://${this.buildParams.awsBaseStackName}-storage/"
# no need to upload Library cache for now
# aws s3 cp "/${buildVolumeFolder}/${cacheFolder}/$branch/lib-${this.buildGuid}.zip" "s3://${
this.buildParams.awsBaseStackName
}-storage/"
${this.SteamDeploy ? '#' : ''} rm -r ${this.buildGuid}
`,
],
`/${buildVolumeFolder}`,
`/${buildVolumeFolder}/`,
RemoteBuilder.readUploadArtifactEnvironmentVariables(),
RemoteBuilder.readUploadArtifactsSecrets(),
);
}
private static async DeployToSteam() {
core.info('Starting steam deployment');
await this.RemoteBuilderProviderPlatform.runBuildTask(
this.buildGuid,
'cm2network/steamcmd:root',
[
`
ls
ls /
cp -r /${buildVolumeFolder}/${this.buildGuid}/steam/action/entrypoint.sh /entrypoint.sh;
cp -r /${buildVolumeFolder}/${this.buildGuid}/steam/action/steps/ /steps;
chmod -R +x /entrypoint.sh;
chmod -R +x /steps;
/entrypoint.sh;
rm -r /${buildVolumeFolder}/${this.buildGuid}
`,
],
`/${buildVolumeFolder}`,
`/${buildVolumeFolder}/${this.buildGuid}/steam/action/`,
[
{
name: 'GITHUB_SHA',
value: process.env.GITHUB_SHA || '',
},
],
RemoteBuilder.readDeployToSteamSecrets(),
);
}
private static setupBuildPlatform() { private static setupBuildPlatform() {
switch (this.buildParams.remoteBuildCluster) { switch (this.buildParams.remoteBuildCluster) {
case 'aws': case 'aws':