Fix
parent
dd22d28e75
commit
0d9c2bf1d8
|
|
@ -616,8 +616,8 @@ const unity_1 = __importDefault(__webpack_require__(70498));
|
|||
exports.Unity = unity_1.default;
|
||||
const versioning_1 = __importDefault(__webpack_require__(88729));
|
||||
exports.Versioning = versioning_1.default;
|
||||
const remote_builder_1 = __importDefault(__webpack_require__(49358));
|
||||
exports.RemoteBuilder = remote_builder_1.default;
|
||||
const cloud_runner_1 = __importDefault(__webpack_require__(84875));
|
||||
exports.RemoteBuilder = cloud_runner_1.default;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -891,7 +891,7 @@ const SDK = __importStar(__webpack_require__(71786));
|
|||
const nanoid_1 = __webpack_require__(39140);
|
||||
const fs = __importStar(__webpack_require__(35747));
|
||||
const core = __importStar(__webpack_require__(42186));
|
||||
const remote_builder_constants_1 = __importDefault(__webpack_require__(92560));
|
||||
const cloud_runner_constants_1 = __importDefault(__webpack_require__(74094));
|
||||
const aws_build_runner_1 = __importDefault(__webpack_require__(11201));
|
||||
const crypto = __webpack_require__(33373);
|
||||
class AWSBuildEnvironment {
|
||||
|
|
@ -968,7 +968,7 @@ class AWSBuildEnvironment {
|
|||
}
|
||||
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const logGuid = nanoid_1.customAlphabet(remote_builder_constants_1.default.alphabet, 9)();
|
||||
const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)();
|
||||
commands[1] += `
|
||||
echo "${logGuid}"
|
||||
`;
|
||||
|
|
@ -1362,6 +1362,404 @@ class AWSBuildRunner {
|
|||
exports.default = AWSBuildRunner;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 74094:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
class CloudRunnerConstants {
|
||||
}
|
||||
CloudRunnerConstants.alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
exports.default = CloudRunnerConstants;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 27557:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const nanoid_1 = __webpack_require__(39140);
|
||||
const cloud_runner_constants_1 = __importDefault(__webpack_require__(74094));
|
||||
class CloudRunnerNamespace {
|
||||
static generateBuildName(runNumber, platform) {
|
||||
const nanoid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 4);
|
||||
return `${runNumber}-${platform.toLowerCase().replace('standalone', '')}-${nanoid()}`;
|
||||
}
|
||||
}
|
||||
exports.default = CloudRunnerNamespace;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 84875:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const aws_build_platform_1 = __importDefault(__webpack_require__(70187));
|
||||
const core = __importStar(__webpack_require__(42186));
|
||||
const cloud_runner_namespace_1 = __importDefault(__webpack_require__(27557));
|
||||
const kubernetes_build_platform_1 = __importDefault(__webpack_require__(81730));
|
||||
const image_environment_factory_1 = __importDefault(__webpack_require__(25145));
|
||||
const yaml_1 = __importDefault(__webpack_require__(13552));
|
||||
const repositoryFolder = 'repo';
|
||||
const buildVolumeFolder = 'data';
|
||||
const cacheFolder = 'cache';
|
||||
class CloudRunner {
|
||||
static build(buildParameters, baseImage) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const t = Date.now();
|
||||
CloudRunner.buildGuid = cloud_runner_namespace_1.default.generateBuildName(CloudRunner.readRunNumber(), buildParameters.platform);
|
||||
CloudRunner.buildParams = buildParameters;
|
||||
CloudRunner.setupBranchName();
|
||||
CloudRunner.setupFolderVariables();
|
||||
CloudRunner.setupDefaultSecrets();
|
||||
try {
|
||||
CloudRunner.setupBuildPlatform();
|
||||
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
yield CloudRunner.SetupStep();
|
||||
const t2 = Date.now();
|
||||
core.info(`Setup time: ${Math.floor((t2 - t) / 1000)}s`);
|
||||
yield CloudRunner.BuildStep(baseImage);
|
||||
const t3 = Date.now();
|
||||
core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}s`);
|
||||
yield CloudRunner.CompressionStep();
|
||||
core.info(`Post build steps ${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)}`);
|
||||
for (const step of this.buildParams.postBuildSteps) {
|
||||
const stepSecrets = step.secrets.map((x) => {
|
||||
const secret = {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: x.name,
|
||||
ParameterValue: x.value,
|
||||
};
|
||||
return secret;
|
||||
});
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, step['image'], step['commands'], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], [...this.defaultSecrets, ...stepSecrets]);
|
||||
}
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
}
|
||||
catch (error) {
|
||||
yield CloudRunner.handleException(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
static setupFolderVariables() {
|
||||
this.buildPathFull = `/${buildVolumeFolder}/${this.buildGuid}`;
|
||||
this.builderPathFull = `${this.buildPathFull}/builder`;
|
||||
this.steamPathFull = `${this.buildPathFull}/steam`;
|
||||
this.repoPathFull = `${this.buildPathFull}/${repositoryFolder}`;
|
||||
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
|
||||
this.libraryFolderFull = `${this.projectPathFull}/Library`;
|
||||
this.cacheFolderFull = `/${buildVolumeFolder}/${cacheFolder}/${this.branchName}`;
|
||||
}
|
||||
static SetupStep() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
const lfsDirectory = `${this.repoPathFull}/.git/lfs`;
|
||||
const testLFSFile = `${this.projectPathFull}/Assets/LFS_Test_File.jpg`;
|
||||
const unityBuilderRepoUrl = `https://${this.buildParams.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const targetBuildRepoUrl = `https://${this.buildParams.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
const purgeRemoteCache = process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined;
|
||||
const initializeSourceRepoForCaching = `${this.builderPathFull}/dist/remote-builder/cloneNoLFS.sh "${this.repoPathFull}" "${targetBuildRepoUrl}" "${testLFSFile}"`;
|
||||
const handleCaching = `${this.builderPathFull}/dist/remote-builder/handleCaching.sh "${this.cacheFolderFull}" "${this.libraryFolderFull}" "${lfsDirectory}" "${purgeRemoteCache}"`;
|
||||
const remoteBuilderBranch = process.env.remoteBuilderBranch ? `--branch "${process.env.remoteBuilderBranch}"` : '';
|
||||
const cloneRemoteBuilder = `git clone -q ${remoteBuilderBranch} ${unityBuilderRepoUrl} ${this.builderPathFull}`;
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'alpine/git', [
|
||||
` printenv
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree -q
|
||||
mkdir -p ${this.buildPathFull}
|
||||
mkdir -p ${this.builderPathFull}
|
||||
mkdir -p ${this.repoPathFull}
|
||||
${cloneRemoteBuilder}
|
||||
echo ' '
|
||||
echo 'Initializing source repository for cloning with caching of LFS files'
|
||||
${initializeSourceRepoForCaching}
|
||||
export LFS_ASSETS_HASH="$(cat ${this.repoPathFull}/.lfs-assets-guid)"
|
||||
echo 'Source repository initialized'
|
||||
echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}echo $LFS_ASSETS_HASH
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Large File before LFS caching and pull'
|
||||
${process.env.DEBUG ? '' : '#'}ls -alh "${lfsDirectory}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
echo 'Starting checks of cache for the Unity project Library and git LFS files'
|
||||
${handleCaching}
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Caching complete'
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Large File after LFS caching and pull'
|
||||
${process.env.DEBUG ? '' : '#'}ls -alh "${lfsDirectory}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, CloudRunner.defaultGitShaEnvironmentVariable, this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
static BuildStep(baseImage) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, baseImage.toString(), [
|
||||
`
|
||||
printenv
|
||||
export GITHUB_WORKSPACE="${this.repoPathFull}"
|
||||
cp -r "${this.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${this.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${this.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${this.projectPathFull}`, CloudRunner.readBuildEnvironmentVariables(), this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
static CompressionStep() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'alpine', [
|
||||
`
|
||||
printenv
|
||||
apk update -q
|
||||
apk add zip tree -q
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
|
||||
cd "$libraryFolderFull"
|
||||
zip -r "lib-$BUILDID.zip" "$libraryFolderFull"
|
||||
mv "lib-$BUILDID.zip" "$cacheFolderFull/lib"
|
||||
cd "$repoPathFull"
|
||||
ls -lh "$repoPathFull"
|
||||
zip -r "build-$BUILDID.zip" "$repoPathFull/${CloudRunner.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], this.defaultSecrets);
|
||||
core.info('compression step complete');
|
||||
});
|
||||
}
|
||||
static setupBuildPlatform() {
|
||||
switch (this.buildParams.remoteBuildCluster) {
|
||||
case 'aws':
|
||||
core.info('Building with AWS');
|
||||
this.RemoteBuilderProviderPlatform = new aws_build_platform_1.default(this.buildParams);
|
||||
break;
|
||||
default:
|
||||
case 'k8s':
|
||||
core.info('Building with Kubernetes');
|
||||
this.RemoteBuilderProviderPlatform = new kubernetes_build_platform_1.default(this.buildParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static readRunNumber() {
|
||||
const runNumber = process.env.GITHUB_RUN_NUMBER;
|
||||
if (!runNumber || runNumber === '') {
|
||||
throw new Error('no run number found, exiting');
|
||||
}
|
||||
return runNumber;
|
||||
}
|
||||
static setupBranchName() {
|
||||
var _a;
|
||||
const defaultBranchName = ((_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').filter((x) => {
|
||||
x = x[0].toUpperCase() + x.slice(1);
|
||||
return x;
|
||||
}).join('')) || '';
|
||||
this.branchName =
|
||||
process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
|
||||
}
|
||||
static setupDefaultSecrets() {
|
||||
this.defaultSecrets = [
|
||||
{
|
||||
ParameterKey: 'GithubToken',
|
||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||
ParameterValue: this.buildParams.githubToken,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'branch',
|
||||
EnvironmentVariable: 'branch',
|
||||
ParameterValue: this.branchName,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'buildPathFull',
|
||||
EnvironmentVariable: 'buildPathFull',
|
||||
ParameterValue: this.buildPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'projectPathFull',
|
||||
EnvironmentVariable: 'projectPathFull',
|
||||
ParameterValue: this.projectPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'libraryFolderFull',
|
||||
EnvironmentVariable: 'libraryFolderFull',
|
||||
ParameterValue: this.libraryFolderFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'builderPathFull',
|
||||
EnvironmentVariable: 'builderPathFull',
|
||||
ParameterValue: this.builderPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'repoPathFull',
|
||||
EnvironmentVariable: 'repoPathFull',
|
||||
ParameterValue: this.repoPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'steamPathFull',
|
||||
EnvironmentVariable: 'steamPathFull',
|
||||
ParameterValue: this.steamPathFull,
|
||||
},
|
||||
];
|
||||
this.defaultSecrets.push(...image_environment_factory_1.default.getEnvironmentVariables(this.buildParams).map((x) => {
|
||||
return {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: x.name,
|
||||
ParameterValue: x.value,
|
||||
};
|
||||
}));
|
||||
}
|
||||
static readBuildEnvironmentVariables() {
|
||||
return [
|
||||
{
|
||||
name: 'ContainerMemory',
|
||||
value: this.buildParams.remoteBuildMemory,
|
||||
},
|
||||
{
|
||||
name: 'ContainerCpu',
|
||||
value: this.buildParams.remoteBuildCpu,
|
||||
},
|
||||
{
|
||||
name: 'GITHUB_WORKSPACE',
|
||||
value: `/${buildVolumeFolder}/${this.buildGuid}/${repositoryFolder}/`,
|
||||
},
|
||||
{
|
||||
name: 'PROJECT_PATH',
|
||||
value: this.buildParams.projectPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_PATH',
|
||||
value: this.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_FILE',
|
||||
value: this.buildParams.buildFile,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_NAME',
|
||||
value: this.buildParams.buildName,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_METHOD',
|
||||
value: this.buildParams.buildMethod,
|
||||
},
|
||||
{
|
||||
name: 'CUSTOM_PARAMETERS',
|
||||
value: this.buildParams.customParameters,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: this.buildParams.platform,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_VERSION_CODE',
|
||||
value: this.buildParams.androidVersionCode.toString(),
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYSTORE_NAME',
|
||||
value: this.buildParams.androidKeystoreName,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYALIAS_NAME',
|
||||
value: this.buildParams.androidKeyaliasName,
|
||||
},
|
||||
];
|
||||
}
|
||||
static readUploadArtifactEnvironmentVariables() {
|
||||
return [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
{
|
||||
name: 'AWS_DEFAULT_REGION',
|
||||
value: process.env.AWS_DEFAULT_REGION || '',
|
||||
},
|
||||
];
|
||||
}
|
||||
static handleException(error) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.error(JSON.stringify(error, undefined, 4));
|
||||
core.setFailed('Remote Builder failed');
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
}
|
||||
CloudRunner.SteamDeploy = process.env.STEAM_DEPLOY !== undefined || false;
|
||||
CloudRunner.defaultGitShaEnvironmentVariable = [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
];
|
||||
exports.default = CloudRunner;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 81730:
|
||||
|
|
@ -2143,404 +2541,6 @@ class KubernetesUtilities {
|
|||
exports.default = KubernetesUtilities;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 92560:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
class RemoteBuilderConstants {
|
||||
}
|
||||
RemoteBuilderConstants.alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
exports.default = RemoteBuilderConstants;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 96003:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const nanoid_1 = __webpack_require__(39140);
|
||||
const remote_builder_constants_1 = __importDefault(__webpack_require__(92560));
|
||||
class RemoteBuilderNamespace {
|
||||
static generateBuildName(runNumber, platform) {
|
||||
const nanoid = nanoid_1.customAlphabet(remote_builder_constants_1.default.alphabet, 4);
|
||||
return `${runNumber}-${platform.toLowerCase().replace('standalone', '')}-${nanoid()}`;
|
||||
}
|
||||
}
|
||||
exports.default = RemoteBuilderNamespace;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 49358:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const aws_build_platform_1 = __importDefault(__webpack_require__(70187));
|
||||
const core = __importStar(__webpack_require__(42186));
|
||||
const remote_builder_namespace_1 = __importDefault(__webpack_require__(96003));
|
||||
const kubernetes_build_platform_1 = __importDefault(__webpack_require__(81730));
|
||||
const image_environment_factory_1 = __importDefault(__webpack_require__(25145));
|
||||
const yaml_1 = __importDefault(__webpack_require__(13552));
|
||||
const repositoryFolder = 'repo';
|
||||
const buildVolumeFolder = 'data';
|
||||
const cacheFolder = 'cache';
|
||||
class RemoteBuilder {
|
||||
static build(buildParameters, baseImage) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const t = Date.now();
|
||||
RemoteBuilder.buildGuid = remote_builder_namespace_1.default.generateBuildName(RemoteBuilder.readRunNumber(), buildParameters.platform);
|
||||
RemoteBuilder.buildParams = buildParameters;
|
||||
RemoteBuilder.setupBranchName();
|
||||
RemoteBuilder.setupFolderVariables();
|
||||
RemoteBuilder.setupDefaultSecrets();
|
||||
try {
|
||||
RemoteBuilder.setupBuildPlatform();
|
||||
yield this.RemoteBuilderProviderPlatform.setupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
yield RemoteBuilder.SetupStep();
|
||||
const t2 = Date.now();
|
||||
core.info(`Setup time: ${Math.floor((t2 - t) / 1000)}s`);
|
||||
yield RemoteBuilder.BuildStep(baseImage);
|
||||
const t3 = Date.now();
|
||||
core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}s`);
|
||||
yield RemoteBuilder.CompressionStep();
|
||||
core.info(`Post build steps ${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)}`);
|
||||
for (const step of this.buildParams.postBuildSteps) {
|
||||
const stepSecrets = step.secrets.map((x) => {
|
||||
const secret = {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: x.name,
|
||||
ParameterValue: x.value,
|
||||
};
|
||||
return secret;
|
||||
});
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, step['image'], step['commands'], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], [...this.defaultSecrets, ...stepSecrets]);
|
||||
}
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
}
|
||||
catch (error) {
|
||||
yield RemoteBuilder.handleException(error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
static setupFolderVariables() {
|
||||
this.buildPathFull = `/${buildVolumeFolder}/${this.buildGuid}`;
|
||||
this.builderPathFull = `${this.buildPathFull}/builder`;
|
||||
this.steamPathFull = `${this.buildPathFull}/steam`;
|
||||
this.repoPathFull = `${this.buildPathFull}/${repositoryFolder}`;
|
||||
this.projectPathFull = `${this.repoPathFull}/${this.buildParams.projectPath}`;
|
||||
this.libraryFolderFull = `${this.projectPathFull}/Library`;
|
||||
this.cacheFolderFull = `/${buildVolumeFolder}/${cacheFolder}/${this.branchName}`;
|
||||
}
|
||||
static SetupStep() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 1/4 clone and restore cache)');
|
||||
const lfsDirectory = `${this.repoPathFull}/.git/lfs`;
|
||||
const testLFSFile = `${this.projectPathFull}/Assets/LFS_Test_File.jpg`;
|
||||
const unityBuilderRepoUrl = `https://${this.buildParams.githubToken}@github.com/game-ci/unity-builder.git`;
|
||||
const targetBuildRepoUrl = `https://${this.buildParams.githubToken}@github.com/${process.env.GITHUB_REPOSITORY}.git`;
|
||||
const purgeRemoteCache = process.env.PURGE_REMOTE_BUILDER_CACHE !== undefined;
|
||||
const initializeSourceRepoForCaching = `${this.builderPathFull}/dist/remote-builder/cloneNoLFS.sh "${this.repoPathFull}" "${targetBuildRepoUrl}" "${testLFSFile}"`;
|
||||
const handleCaching = `${this.builderPathFull}/dist/remote-builder/handleCaching.sh "${this.cacheFolderFull}" "${this.libraryFolderFull}" "${lfsDirectory}" "${purgeRemoteCache}"`;
|
||||
const remoteBuilderBranch = process.env.remoteBuilderBranch ? `--branch "${process.env.remoteBuilderBranch}"` : '';
|
||||
const cloneRemoteBuilder = `git clone -q ${remoteBuilderBranch} ${unityBuilderRepoUrl} ${this.builderPathFull}`;
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'alpine/git', [
|
||||
` printenv
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree -q
|
||||
mkdir -p ${this.buildPathFull}
|
||||
mkdir -p ${this.builderPathFull}
|
||||
mkdir -p ${this.repoPathFull}
|
||||
${cloneRemoteBuilder}
|
||||
echo ' '
|
||||
echo 'Initializing source repository for cloning with caching of LFS files'
|
||||
${initializeSourceRepoForCaching}
|
||||
export LFS_ASSETS_HASH="$(cat ${this.repoPathFull}/.lfs-assets-guid)"
|
||||
echo 'Source repository initialized'
|
||||
echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}echo $LFS_ASSETS_HASH
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Large File before LFS caching and pull'
|
||||
${process.env.DEBUG ? '' : '#'}ls -alh "${lfsDirectory}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
echo 'Starting checks of cache for the Unity project Library and git LFS files'
|
||||
${handleCaching}
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Caching complete'
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}echo 'Large File after LFS caching and pull'
|
||||
${process.env.DEBUG ? '' : '#'}ls -alh "${lfsDirectory}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
|
||||
${process.env.DEBUG ? '' : '#'}echo ' '
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}/`, RemoteBuilder.defaultGitShaEnvironmentVariable, this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
static BuildStep(baseImage) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting part 2/4 (build unity project)');
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, baseImage.toString(), [
|
||||
`
|
||||
printenv
|
||||
export GITHUB_WORKSPACE="${this.repoPathFull}"
|
||||
cp -r "${this.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${this.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${this.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "${this.buildPathFull}"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "/${buildVolumeFolder}"
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${this.projectPathFull}`, RemoteBuilder.readBuildEnvironmentVariables(), this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
static CompressionStep() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info('Starting step 3/4 build compression');
|
||||
// Cleanup
|
||||
yield this.RemoteBuilderProviderPlatform.runBuildTask(this.buildGuid, 'alpine', [
|
||||
`
|
||||
printenv
|
||||
apk update -q
|
||||
apk add zip tree -q
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
|
||||
cd "$libraryFolderFull"
|
||||
zip -r "lib-$BUILDID.zip" "$libraryFolderFull"
|
||||
mv "lib-$BUILDID.zip" "$cacheFolderFull/lib"
|
||||
cd "$repoPathFull"
|
||||
ls -lh "$repoPathFull"
|
||||
zip -r "build-$BUILDID.zip" "$repoPathFull/${RemoteBuilder.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
|
||||
`,
|
||||
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
], this.defaultSecrets);
|
||||
core.info('compression step complete');
|
||||
});
|
||||
}
|
||||
static setupBuildPlatform() {
|
||||
switch (this.buildParams.remoteBuildCluster) {
|
||||
case 'aws':
|
||||
core.info('Building with AWS');
|
||||
this.RemoteBuilderProviderPlatform = new aws_build_platform_1.default(this.buildParams);
|
||||
break;
|
||||
default:
|
||||
case 'k8s':
|
||||
core.info('Building with Kubernetes');
|
||||
this.RemoteBuilderProviderPlatform = new kubernetes_build_platform_1.default(this.buildParams);
|
||||
break;
|
||||
}
|
||||
}
|
||||
static readRunNumber() {
|
||||
const runNumber = process.env.GITHUB_RUN_NUMBER;
|
||||
if (!runNumber || runNumber === '') {
|
||||
throw new Error('no run number found, exiting');
|
||||
}
|
||||
return runNumber;
|
||||
}
|
||||
static setupBranchName() {
|
||||
var _a;
|
||||
const defaultBranchName = ((_a = process.env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.split('/').filter((x) => {
|
||||
x = x[0].toUpperCase() + x.slice(1);
|
||||
return x;
|
||||
}).join('')) || '';
|
||||
this.branchName =
|
||||
process.env.REMOTE_BUILDER_CACHE !== undefined ? process.env.REMOTE_BUILDER_CACHE : defaultBranchName;
|
||||
}
|
||||
static setupDefaultSecrets() {
|
||||
this.defaultSecrets = [
|
||||
{
|
||||
ParameterKey: 'GithubToken',
|
||||
EnvironmentVariable: 'GITHUB_TOKEN',
|
||||
ParameterValue: this.buildParams.githubToken,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'branch',
|
||||
EnvironmentVariable: 'branch',
|
||||
ParameterValue: this.branchName,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'buildPathFull',
|
||||
EnvironmentVariable: 'buildPathFull',
|
||||
ParameterValue: this.buildPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'projectPathFull',
|
||||
EnvironmentVariable: 'projectPathFull',
|
||||
ParameterValue: this.projectPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'libraryFolderFull',
|
||||
EnvironmentVariable: 'libraryFolderFull',
|
||||
ParameterValue: this.libraryFolderFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'builderPathFull',
|
||||
EnvironmentVariable: 'builderPathFull',
|
||||
ParameterValue: this.builderPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'repoPathFull',
|
||||
EnvironmentVariable: 'repoPathFull',
|
||||
ParameterValue: this.repoPathFull,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'steamPathFull',
|
||||
EnvironmentVariable: 'steamPathFull',
|
||||
ParameterValue: this.steamPathFull,
|
||||
},
|
||||
];
|
||||
this.defaultSecrets.push(...image_environment_factory_1.default.getEnvironmentVariables(this.buildParams).map((x) => {
|
||||
return {
|
||||
ParameterKey: x.name,
|
||||
EnvironmentVariable: x.name,
|
||||
ParameterValue: x.value,
|
||||
};
|
||||
}));
|
||||
}
|
||||
static readBuildEnvironmentVariables() {
|
||||
return [
|
||||
{
|
||||
name: 'ContainerMemory',
|
||||
value: this.buildParams.remoteBuildMemory,
|
||||
},
|
||||
{
|
||||
name: 'ContainerCpu',
|
||||
value: this.buildParams.remoteBuildCpu,
|
||||
},
|
||||
{
|
||||
name: 'GITHUB_WORKSPACE',
|
||||
value: `/${buildVolumeFolder}/${this.buildGuid}/${repositoryFolder}/`,
|
||||
},
|
||||
{
|
||||
name: 'PROJECT_PATH',
|
||||
value: this.buildParams.projectPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_PATH',
|
||||
value: this.buildParams.buildPath,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_FILE',
|
||||
value: this.buildParams.buildFile,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_NAME',
|
||||
value: this.buildParams.buildName,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_METHOD',
|
||||
value: this.buildParams.buildMethod,
|
||||
},
|
||||
{
|
||||
name: 'CUSTOM_PARAMETERS',
|
||||
value: this.buildParams.customParameters,
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: this.buildParams.platform,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_VERSION_CODE',
|
||||
value: this.buildParams.androidVersionCode.toString(),
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYSTORE_NAME',
|
||||
value: this.buildParams.androidKeystoreName,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_KEYALIAS_NAME',
|
||||
value: this.buildParams.androidKeyaliasName,
|
||||
},
|
||||
];
|
||||
}
|
||||
static readUploadArtifactEnvironmentVariables() {
|
||||
return [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
{
|
||||
name: 'AWS_DEFAULT_REGION',
|
||||
value: process.env.AWS_DEFAULT_REGION || '',
|
||||
},
|
||||
];
|
||||
}
|
||||
static handleException(error) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.error(JSON.stringify(error, undefined, 4));
|
||||
core.setFailed('Remote Builder failed');
|
||||
yield this.RemoteBuilderProviderPlatform.cleanupSharedBuildResources(this.buildGuid, this.buildParams, this.branchName, this.defaultSecrets);
|
||||
});
|
||||
}
|
||||
}
|
||||
RemoteBuilder.SteamDeploy = process.env.STEAM_DEPLOY !== undefined || false;
|
||||
RemoteBuilder.defaultGitShaEnvironmentVariable = [
|
||||
{
|
||||
name: 'GITHUB_SHA',
|
||||
value: process.env.GITHUB_SHA || '',
|
||||
},
|
||||
];
|
||||
exports.default = RemoteBuilder;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 62177:
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -9,7 +9,7 @@ import Platform from './platform';
|
|||
import Project from './project';
|
||||
import Unity from './unity';
|
||||
import Versioning from './versioning';
|
||||
import RemoteBuilder from './remote-builder/remote-builder';
|
||||
import CloudRunner from './remote-builder/cloud-runner';
|
||||
|
||||
export {
|
||||
Action,
|
||||
|
|
@ -23,5 +23,5 @@ export {
|
|||
Project,
|
||||
Unity,
|
||||
Versioning,
|
||||
RemoteBuilder,
|
||||
CloudRunner as RemoteBuilder,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import * as SDK from 'aws-sdk';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderSecret from './cloud-runner-secret';
|
||||
import RemoteBuilderEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
import * as fs from 'fs';
|
||||
import * as core from '@actions/core';
|
||||
import RemoteBuilderTaskDef from './remote-builder-task-def';
|
||||
import RemoteBuilderConstants from './remote-builder-constants';
|
||||
import CloudRunnerTaskDef from './cloud-runner-task-def';
|
||||
import RemoteBuilderConstants from './cloud-runner-constants';
|
||||
import AWSBuildRunner from './aws-build-runner';
|
||||
import { RemoteBuilderProviderInterface } from './remote-builder-provider-interface';
|
||||
import { CloudRunnerProviderInterface } from './cloud-runner-provider-interface';
|
||||
import BuildParameters from '../build-parameters';
|
||||
const crypto = require('crypto');
|
||||
|
||||
class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||
class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
||||
private baseStackName: string;
|
||||
|
||||
constructor(buildParameters: BuildParameters) {
|
||||
|
|
@ -116,7 +116,7 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
|||
mountdir: string,
|
||||
workingdir: string,
|
||||
secrets: RemoteBuilderSecret[],
|
||||
): Promise<RemoteBuilderTaskDef> {
|
||||
): Promise<CloudRunnerTaskDef> {
|
||||
const logGuid = customAlphabet(RemoteBuilderConstants.alphabet, 9)();
|
||||
commands[1] += `
|
||||
echo "${logGuid}"
|
||||
|
|
@ -339,7 +339,7 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
|||
return fs.readFileSync(`${__dirname}/cloud-formations/task-def-formation.yml`, 'utf8');
|
||||
}
|
||||
|
||||
async cleanupResources(CF: SDK.CloudFormation, taskDef: RemoteBuilderTaskDef) {
|
||||
async cleanupResources(CF: SDK.CloudFormation, taskDef: CloudRunnerTaskDef) {
|
||||
core.info('Cleanup starting');
|
||||
await CF.deleteStack({
|
||||
StackName: taskDef.taskDefStackName,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import * as AWS from 'aws-sdk';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
import * as core from '@actions/core';
|
||||
import RemoteBuilderTaskDef from './remote-builder-task-def';
|
||||
import CloudRunnerTaskDef from './cloud-runner-task-def';
|
||||
import * as zlib from 'zlib';
|
||||
|
||||
class AWSBuildRunner {
|
||||
static async runTask(
|
||||
taskDef: RemoteBuilderTaskDef,
|
||||
taskDef: CloudRunnerTaskDef,
|
||||
ECS: AWS.ECS,
|
||||
CF: AWS.CloudFormation,
|
||||
environment: RemoteBuilderEnvironmentVariable[],
|
||||
|
|
@ -92,7 +92,7 @@ class AWSBuildRunner {
|
|||
static async streamLogsUntilTaskStops(
|
||||
ECS: AWS.ECS,
|
||||
CF: AWS.CloudFormation,
|
||||
taskDef: RemoteBuilderTaskDef,
|
||||
taskDef: CloudRunnerTaskDef,
|
||||
clusterName: string,
|
||||
taskArn: string,
|
||||
kinesisStreamName: string,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
class CloudRunnerConstants {
|
||||
static alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
}
|
||||
export default CloudRunnerConstants;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class CloudRunnerEnvironmentVariable {
|
||||
public name!: string;
|
||||
public value!: string;
|
||||
}
|
||||
export default CloudRunnerEnvironmentVariable;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import { customAlphabet } from 'nanoid';
|
||||
import RemoteBuilderConstants from './remote-builder-constants';
|
||||
import CloudRunnerConstants from './cloud-runner-constants';
|
||||
|
||||
class RemoteBuilderNamespace {
|
||||
class CloudRunnerNamespace {
|
||||
static generateBuildName(runNumber: string | number, platform: string) {
|
||||
const nanoid = customAlphabet(RemoteBuilderConstants.alphabet, 4);
|
||||
const nanoid = customAlphabet(CloudRunnerConstants.alphabet, 4);
|
||||
return `${runNumber}-${platform.toLowerCase().replace('standalone', '')}-${nanoid()}`;
|
||||
}
|
||||
}
|
||||
export default RemoteBuilderNamespace;
|
||||
export default CloudRunnerNamespace;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import BuildParameters from '../build-parameters';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
import CloudRunnerEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
import CloudRunnerSecret from './cloud-runner-secret';
|
||||
|
||||
export interface RemoteBuilderProviderInterface {
|
||||
export interface CloudRunnerProviderInterface {
|
||||
cleanupSharedBuildResources(
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
buildGuid: string,
|
||||
|
|
@ -35,8 +35,8 @@ export interface RemoteBuilderProviderInterface {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
workingdir: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
environment: RemoteBuilderEnvironmentVariable[],
|
||||
environment: CloudRunnerEnvironmentVariable[],
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
secrets: RemoteBuilderSecret[],
|
||||
secrets: CloudRunnerSecret[],
|
||||
): Promise<void>;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
class RemoteBuilderSecret {
|
||||
class CloudRunnerSecret {
|
||||
public ParameterKey!: string;
|
||||
public EnvironmentVariable!: string;
|
||||
public ParameterValue!: string;
|
||||
}
|
||||
export default RemoteBuilderSecret;
|
||||
export default CloudRunnerSecret;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import * as AWS from 'aws-sdk';
|
||||
|
||||
class RemoteBuilderTaskDef {
|
||||
class CloudRunnerTaskDef {
|
||||
public taskDefStackName!: string;
|
||||
public taskDefCloudFormation!: string;
|
||||
public taskDefStackNameTTL!: string;
|
||||
|
|
@ -9,4 +9,4 @@ class RemoteBuilderTaskDef {
|
|||
public baseResources: AWS.CloudFormation.StackResources | undefined;
|
||||
public logid!: string;
|
||||
}
|
||||
export default RemoteBuilderTaskDef;
|
||||
export default CloudRunnerTaskDef;
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
import AWSBuildPlatform from './aws-build-platform';
|
||||
import * as core from '@actions/core';
|
||||
import { BuildParameters } from '..';
|
||||
import RemoteBuilderNamespace from './remote-builder-namespace';
|
||||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
import { RemoteBuilderProviderInterface } from './remote-builder-provider-interface';
|
||||
import RemoteBuilderNamespace from './cloud-runner-namespace';
|
||||
import RemoteBuilderSecret from './cloud-runner-secret';
|
||||
import { CloudRunnerProviderInterface } from './cloud-runner-provider-interface';
|
||||
import Kubernetes from './kubernetes-build-platform';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
import ImageEnvironmentFactory from '../image-environment-factory';
|
||||
import YAML from 'yaml';
|
||||
const repositoryFolder = 'repo';
|
||||
const buildVolumeFolder = 'data';
|
||||
const cacheFolder = 'cache';
|
||||
|
||||
class RemoteBuilder {
|
||||
static RemoteBuilderProviderPlatform: RemoteBuilderProviderInterface;
|
||||
class CloudRunner {
|
||||
static RemoteBuilderProviderPlatform: CloudRunnerProviderInterface;
|
||||
private static buildParams: BuildParameters;
|
||||
private static defaultSecrets: RemoteBuilderSecret[];
|
||||
private static buildGuid: string;
|
||||
|
|
@ -35,29 +35,29 @@ class RemoteBuilder {
|
|||
|
||||
static async build(buildParameters: BuildParameters, baseImage) {
|
||||
const t = Date.now();
|
||||
RemoteBuilder.buildGuid = RemoteBuilderNamespace.generateBuildName(
|
||||
RemoteBuilder.readRunNumber(),
|
||||
CloudRunner.buildGuid = RemoteBuilderNamespace.generateBuildName(
|
||||
CloudRunner.readRunNumber(),
|
||||
buildParameters.platform,
|
||||
);
|
||||
RemoteBuilder.buildParams = buildParameters;
|
||||
RemoteBuilder.setupBranchName();
|
||||
RemoteBuilder.setupFolderVariables();
|
||||
RemoteBuilder.setupDefaultSecrets();
|
||||
CloudRunner.buildParams = buildParameters;
|
||||
CloudRunner.setupBranchName();
|
||||
CloudRunner.setupFolderVariables();
|
||||
CloudRunner.setupDefaultSecrets();
|
||||
try {
|
||||
RemoteBuilder.setupBuildPlatform();
|
||||
CloudRunner.setupBuildPlatform();
|
||||
await this.RemoteBuilderProviderPlatform.setupSharedBuildResources(
|
||||
this.buildGuid,
|
||||
this.buildParams,
|
||||
this.branchName,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
await RemoteBuilder.SetupStep();
|
||||
await CloudRunner.SetupStep();
|
||||
const t2 = Date.now();
|
||||
core.info(`Setup time: ${Math.floor((t2 - t) / 1000)}s`);
|
||||
await RemoteBuilder.BuildStep(baseImage);
|
||||
await CloudRunner.BuildStep(baseImage);
|
||||
const t3 = Date.now();
|
||||
core.info(`Build time: ${Math.floor((t3 - t2) / 1000)}s`);
|
||||
await RemoteBuilder.CompressionStep();
|
||||
await CloudRunner.CompressionStep();
|
||||
core.info(`Post build steps ${this.buildParams.postBuildSteps}`);
|
||||
this.buildParams.postBuildSteps = YAML.parse(this.buildParams.postBuildSteps);
|
||||
core.info(`Post build steps ${JSON.stringify(this.buildParams.postBuildSteps, undefined, 4)}`);
|
||||
|
|
@ -92,7 +92,7 @@ class RemoteBuilder {
|
|||
this.defaultSecrets,
|
||||
);
|
||||
} catch (error) {
|
||||
await RemoteBuilder.handleException(error);
|
||||
await CloudRunner.handleException(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
@ -156,7 +156,7 @@ class RemoteBuilder {
|
|||
],
|
||||
`/${buildVolumeFolder}`,
|
||||
`/${buildVolumeFolder}/`,
|
||||
RemoteBuilder.defaultGitShaEnvironmentVariable,
|
||||
CloudRunner.defaultGitShaEnvironmentVariable,
|
||||
this.defaultSecrets,
|
||||
);
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ class RemoteBuilder {
|
|||
],
|
||||
`/${buildVolumeFolder}`,
|
||||
`/${this.projectPathFull}`,
|
||||
RemoteBuilder.readBuildEnvironmentVariables(),
|
||||
CloudRunner.readBuildEnvironmentVariables(),
|
||||
this.defaultSecrets,
|
||||
);
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ class RemoteBuilder {
|
|||
mv "lib-$BUILDID.zip" "$cacheFolderFull/lib"
|
||||
cd "$repoPathFull"
|
||||
ls -lh "$repoPathFull"
|
||||
zip -r "build-$BUILDID.zip" "$repoPathFull/${RemoteBuilder.buildParams.buildPath}"
|
||||
zip -r "build-$BUILDID.zip" "$repoPathFull/${CloudRunner.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "/$cacheFolderFull/build-$BUILDID.zip"
|
||||
${process.env.DEBUG ? '' : '#'}tree -L 4 "$repoPathFull"
|
||||
${process.env.DEBUG ? '' : '#'}ls -lh "$repoPathFull"
|
||||
|
|
@ -393,4 +393,4 @@ class RemoteBuilder {
|
|||
);
|
||||
}
|
||||
}
|
||||
export default RemoteBuilder;
|
||||
export default CloudRunner;
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import * as k8s from '@kubernetes/client-node';
|
||||
import { BuildParameters } from '..';
|
||||
import * as core from '@actions/core';
|
||||
import { RemoteBuilderProviderInterface } from './remote-builder-provider-interface';
|
||||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
import { CloudRunnerProviderInterface } from './cloud-runner-provider-interface';
|
||||
import RemoteBuilderSecret from './cloud-runner-secret';
|
||||
import KubernetesStorage from './kubernetes-storage';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
import KubernetesLogging from './kubernetes-logging';
|
||||
import KubernetesSecret from './kubernetes-secret';
|
||||
import KubernetesUtilities from './kubernetes-utils';
|
||||
|
|
@ -13,7 +13,7 @@ import KubernetesJobSpecFactory from './kubernetes-job-spec-factory';
|
|||
import KubernetesCleanupCronJob from './kubernetes-cleanup-cronjob';
|
||||
import KubernetesServiceAccount from './kubernetes-service-account';
|
||||
|
||||
class Kubernetes implements RemoteBuilderProviderInterface {
|
||||
class Kubernetes implements CloudRunnerProviderInterface {
|
||||
private kubeConfig: k8s.KubeConfig;
|
||||
private kubeClient: k8s.CoreV1Api;
|
||||
private kubeClientBatch: k8s.BatchV1Api;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import BuildParameters from '../build-parameters';
|
||||
import RemoteBuilderEnvironmentVariable from './remote-builder-environment-variable';
|
||||
import RemoteBuilderEnvironmentVariable from './cloud-runner-environment-variable';
|
||||
|
||||
class KubernetesJobSpecFactory {
|
||||
static getJobSpec(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { CoreV1Api } from '@kubernetes/client-node';
|
||||
import RemoteBuilderSecret from './remote-builder-secret';
|
||||
import RemoteBuilderSecret from './cloud-runner-secret';
|
||||
import * as k8s from '@kubernetes/client-node';
|
||||
const base64 = require('base-64');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
class RemoteBuilderConstants {
|
||||
static alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||
}
|
||||
export default RemoteBuilderConstants;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
class RemoteBuilderEnvironmentVariable {
|
||||
public name!: string;
|
||||
public value!: string;
|
||||
}
|
||||
export default RemoteBuilderEnvironmentVariable;
|
||||
Loading…
Reference in New Issue