command start and end injector
parent
3ad76f7e5a
commit
66a269d926
|
|
@ -1021,8 +1021,8 @@ class AWSJobStack {
|
|||
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)();
|
||||
commands[1] += `
|
||||
echo "${logGuid}"
|
||||
commands += `
|
||||
echo "${logGuid}"
|
||||
`;
|
||||
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
||||
let taskDefCloudFormation = aws_templates_1.AWSTemplates.readTaskCloudFormationTemplate();
|
||||
|
|
@ -1201,6 +1201,7 @@ const __1 = __webpack_require__(41359);
|
|||
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||
const cloud_runner_statics_1 = __webpack_require__(90828);
|
||||
const cloud_runner_build_command_process_1 = __webpack_require__(71899);
|
||||
class AWSTaskRunner {
|
||||
static runTask(taskDef, ECS, CF, environment, buildGuid, commands) {
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
||||
|
|
@ -1220,7 +1221,7 @@ class AWSTaskRunner {
|
|||
{
|
||||
name: taskDef.taskDefStackName,
|
||||
environment: [...environment, { name: 'BUILDID', value: buildGuid }],
|
||||
command: ['-c', ...commands],
|
||||
command: ['-c', ...cloud_runner_build_command_process_1.CloudRunnerBuildCommandProcessor.ProcessCommands(commands)],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -1849,11 +1850,12 @@ exports.default = Kubernetes;
|
|||
/***/ }),
|
||||
|
||||
/***/ 1739:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const cloud_runner_build_command_process_1 = __webpack_require__(71899);
|
||||
class KubernetesJobSpecFactory {
|
||||
static getJobSpec(command, image, mountdir, workingDirectory, environment, buildGuid, buildParameters, secretName, pvcName, jobName, k8s) {
|
||||
environment.push(...[
|
||||
|
|
@ -1943,7 +1945,7 @@ class KubernetesJobSpecFactory {
|
|||
name: 'main',
|
||||
image,
|
||||
command: ['/bin/sh'],
|
||||
args: ['-c', ...command],
|
||||
args: ['-c', cloud_runner_build_command_process_1.CloudRunnerBuildCommandProcessor.ProcessCommands(command)],
|
||||
workingDir: `/${workingDirectory}`,
|
||||
resources: {
|
||||
requests: {
|
||||
|
|
@ -2405,6 +2407,26 @@ class KubernetesUtilities {
|
|||
exports.default = KubernetesUtilities;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 71899:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CloudRunnerBuildCommandProcessor = void 0;
|
||||
class CloudRunnerBuildCommandProcessor {
|
||||
static ProcessCommands(commands) {
|
||||
return `
|
||||
echo "start"
|
||||
${commands}
|
||||
echo "end"`;
|
||||
}
|
||||
}
|
||||
exports.CloudRunnerBuildCommandProcessor = CloudRunnerBuildCommandProcessor;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 91311:
|
||||
|
|
@ -2796,30 +2818,28 @@ class BuildStep {
|
|||
static BuildStep(image, environmentVariables, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
cloud_runner_logger_1.default.logLine('Starting part 2/2 (build unity project)');
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||
`
|
||||
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
apt-get update
|
||||
apt-get install -y -q zip
|
||||
cd "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}/.."
|
||||
zip -r "lib-$BUILDID.zip" "./Library"
|
||||
mv "lib-$BUILDID.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib"
|
||||
ls -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib"
|
||||
cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
ls -lh "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/build-$BUILDID.zip"
|
||||
ls ${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib
|
||||
echo " "
|
||||
ls
|
||||
`,
|
||||
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, `
|
||||
export GITHUB_WORKSPACE="${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
apt-get update
|
||||
apt-get install -y -q zip
|
||||
cd "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}/.."
|
||||
zip -r "lib-$BUILDID.zip" "./Library"
|
||||
mv "lib-$BUILDID.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib"
|
||||
ls -lh "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib"
|
||||
cd "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
ls -lh "${cloud_runner_state_1.CloudRunnerState.repoPathFull}"
|
||||
zip -r "build-$BUILDID.zip" "./${cloud_runner_state_1.CloudRunnerState.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/build-$BUILDID.zip"
|
||||
ls ${cloud_runner_state_1.CloudRunnerState.cacheFolderFull}/lib
|
||||
echo " "
|
||||
ls
|
||||
`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.projectPathFull}`, environmentVariables, secrets);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -2864,17 +2884,15 @@ class SetupStep {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
cloud_runner_logger_1.default.logLine('Starting step 1/2 download game files from repository, try to use cache');
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [
|
||||
`
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree nodejs -q
|
||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||
mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
||||
git clone -b ${cloud_runner_state_1.CloudRunnerState.branchName} ${cloud_runner_state_1.CloudRunnerState.unityBuilderRepoUrl} ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
||||
chmod +x ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js
|
||||
node ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
||||
`,
|
||||
], `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}/`, environmentVariables, secrets);
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, `
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree nodejs -q
|
||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||
mkdir -p ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
||||
git clone -b ${cloud_runner_state_1.CloudRunnerState.branchName} ${cloud_runner_state_1.CloudRunnerState.unityBuilderRepoUrl} ${cloud_runner_state_1.CloudRunnerState.builderPathFull}
|
||||
chmod +x ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js
|
||||
node ${cloud_runner_state_1.CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
||||
`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}`, `/${cloud_runner_state_1.CloudRunnerState.buildVolumeFolder}/`, environmentVariables, secrets);
|
||||
}
|
||||
catch (error) {
|
||||
cloud_runner_logger_1.default.logLine(`Failed download repository step 1/2`);
|
||||
|
|
@ -3047,7 +3065,7 @@ class EphemeralGitHubRunnerWorkflow {
|
|||
try {
|
||||
cloud_runner_logger_1.default.log(`Cloud Runner is running in ephemeral GitHub runner mode`);
|
||||
const installAndStartRunner = ' cd ../.. && ls && mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz';
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, [installAndStartRunner], `/runner`, `/runner`, environmentVariables, secrets);
|
||||
yield cloud_runner_state_1.CloudRunnerState.CloudRunnerProviderPlatform.runTask(cloud_runner_state_1.CloudRunnerState.buildGuid, image, installAndStartRunner, `/runner`, `/runner`, environmentVariables, secrets);
|
||||
}
|
||||
catch (error) {
|
||||
throw error;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -19,13 +19,13 @@ export class AWSJobStack {
|
|||
buildGuid: string,
|
||||
image: string,
|
||||
entrypoint: string[],
|
||||
commands: string[],
|
||||
commands: string,
|
||||
mountdir: string,
|
||||
workingdir: string,
|
||||
secrets: CloudRunnerSecret[],
|
||||
): Promise<CloudRunnerTaskDef> {
|
||||
const logGuid = customAlphabet(CloudRunnerConstants.alphabet, 9)();
|
||||
commands[1] += `
|
||||
commands += `
|
||||
echo "${logGuid}"
|
||||
`;
|
||||
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { Input } from '../..';
|
|||
import fs from 'fs';
|
||||
import { CloudRunnerState } from '../state/cloud-runner-state';
|
||||
import { CloudRunnerStatics } from '../cloud-runner-statics';
|
||||
import { CloudRunnerBuildCommandProcessor } from '../services/cloud-runner-build-command-process';
|
||||
|
||||
class AWSTaskRunner {
|
||||
static async runTask(
|
||||
|
|
@ -16,7 +17,7 @@ class AWSTaskRunner {
|
|||
CF: AWS.CloudFormation,
|
||||
environment: CloudRunnerEnvironmentVariable[],
|
||||
buildGuid: string,
|
||||
commands: string[],
|
||||
commands: string,
|
||||
) {
|
||||
const cluster = taskDef.baseResources?.find((x) => x.LogicalResourceId === 'ECSCluster')?.PhysicalResourceId || '';
|
||||
const taskDefinition =
|
||||
|
|
@ -39,7 +40,7 @@ class AWSTaskRunner {
|
|||
{
|
||||
name: taskDef.taskDefStackName,
|
||||
environment: [...environment, { name: 'BUILDID', value: buildGuid }],
|
||||
command: ['-c', ...commands],
|
||||
command: ['-c', ...CloudRunnerBuildCommandProcessor.ProcessCommands(commands)],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
|||
async runTask(
|
||||
buildId: string,
|
||||
image: string,
|
||||
commands: string[],
|
||||
commands: string,
|
||||
mountdir: string,
|
||||
workingdir: string,
|
||||
environment: CloudRunnerEnvironmentVariable[],
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class Kubernetes implements CloudRunnerProviderInterface {
|
|||
async runTask(
|
||||
buildGuid: string,
|
||||
image: string,
|
||||
commands: string[],
|
||||
commands: string,
|
||||
mountdir: string,
|
||||
workingdir: string,
|
||||
environment: CloudRunnerEnvironmentVariable[],
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import BuildParameters from '../../build-parameters';
|
||||
import { CloudRunnerBuildCommandProcessor } from '../services/cloud-runner-build-command-process';
|
||||
import CloudRunnerEnvironmentVariable from '../services/cloud-runner-environment-variable';
|
||||
|
||||
class KubernetesJobSpecFactory {
|
||||
static getJobSpec(
|
||||
command: string[],
|
||||
command: string,
|
||||
image: string,
|
||||
mountdir: string,
|
||||
workingDirectory: string,
|
||||
|
|
@ -104,7 +105,7 @@ class KubernetesJobSpecFactory {
|
|||
name: 'main',
|
||||
image,
|
||||
command: ['/bin/sh'],
|
||||
args: ['-c', ...command],
|
||||
args: ['-c', CloudRunnerBuildCommandProcessor.ProcessCommands(command)],
|
||||
|
||||
workingDir: `/${workingDirectory}`,
|
||||
resources: {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
export class CloudRunnerBuildCommandProcessor {
|
||||
public static ProcessCommands(commands: string): string {
|
||||
return `
|
||||
echo "start"
|
||||
${commands}
|
||||
echo "end"`;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ export interface CloudRunnerProviderInterface {
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
image: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
commands: string[],
|
||||
commands: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
mountdir: string,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
|
|
|||
|
|
@ -23,30 +23,28 @@ export class BuildStep implements StepInterface {
|
|||
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||
CloudRunnerState.buildGuid,
|
||||
image,
|
||||
[
|
||||
`
|
||||
export GITHUB_WORKSPACE="${CloudRunnerState.repoPathFull}"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
apt-get update
|
||||
apt-get install -y -q zip
|
||||
cd "${CloudRunnerState.libraryFolderFull}/.."
|
||||
zip -r "lib-$BUILDID.zip" "./Library"
|
||||
mv "lib-$BUILDID.zip" "${CloudRunnerState.cacheFolderFull}/lib"
|
||||
ls -lh "${CloudRunnerState.cacheFolderFull}/lib"
|
||||
cd "${CloudRunnerState.repoPathFull}"
|
||||
ls -lh "${CloudRunnerState.repoPathFull}"
|
||||
zip -r "build-$BUILDID.zip" "./${CloudRunnerState.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "${CloudRunnerState.cacheFolderFull}/build-$BUILDID.zip"
|
||||
ls ${CloudRunnerState.cacheFolderFull}/lib
|
||||
echo " "
|
||||
ls
|
||||
`,
|
||||
],
|
||||
`
|
||||
export GITHUB_WORKSPACE="${CloudRunnerState.repoPathFull}"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/default-build-script/" "/UnityBuilderAction"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/entrypoint.sh" "/entrypoint.sh"
|
||||
cp -r "${CloudRunnerState.builderPathFull}/dist/steps/" "/steps"
|
||||
chmod -R +x "/entrypoint.sh"
|
||||
chmod -R +x "/steps"
|
||||
/entrypoint.sh
|
||||
apt-get update
|
||||
apt-get install -y -q zip
|
||||
cd "${CloudRunnerState.libraryFolderFull}/.."
|
||||
zip -r "lib-$BUILDID.zip" "./Library"
|
||||
mv "lib-$BUILDID.zip" "${CloudRunnerState.cacheFolderFull}/lib"
|
||||
ls -lh "${CloudRunnerState.cacheFolderFull}/lib"
|
||||
cd "${CloudRunnerState.repoPathFull}"
|
||||
ls -lh "${CloudRunnerState.repoPathFull}"
|
||||
zip -r "build-$BUILDID.zip" "./${CloudRunnerState.buildParams.buildPath}"
|
||||
mv "build-$BUILDID.zip" "${CloudRunnerState.cacheFolderFull}/build-$BUILDID.zip"
|
||||
ls ${CloudRunnerState.cacheFolderFull}/lib
|
||||
echo " "
|
||||
ls
|
||||
`,
|
||||
`/${CloudRunnerState.buildVolumeFolder}`,
|
||||
`/${CloudRunnerState.projectPathFull}`,
|
||||
environmentVariables,
|
||||
|
|
|
|||
|
|
@ -28,17 +28,15 @@ export class SetupStep implements StepInterface {
|
|||
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||
CloudRunnerState.buildGuid,
|
||||
image,
|
||||
[
|
||||
`
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree nodejs -q
|
||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||
mkdir -p ${CloudRunnerState.builderPathFull}
|
||||
git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}
|
||||
chmod +x ${CloudRunnerState.builderPathFull}/dist/index.js
|
||||
node ${CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
||||
`,
|
||||
],
|
||||
`
|
||||
apk update -q
|
||||
apk add unzip zip git-lfs jq tree nodejs -q
|
||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||
mkdir -p ${CloudRunnerState.builderPathFull}
|
||||
git clone -b ${CloudRunnerState.branchName} ${CloudRunnerState.unityBuilderRepoUrl} ${CloudRunnerState.builderPathFull}
|
||||
chmod +x ${CloudRunnerState.builderPathFull}/dist/index.js
|
||||
node ${CloudRunnerState.builderPathFull}/dist/index.js -m remote-cli
|
||||
`,
|
||||
`/${CloudRunnerState.buildVolumeFolder}`,
|
||||
`/${CloudRunnerState.buildVolumeFolder}/`,
|
||||
environmentVariables,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export class EphemeralGitHubRunnerWorkflow implements WorkflowInterface {
|
|||
await CloudRunnerState.CloudRunnerProviderPlatform.runTask(
|
||||
CloudRunnerState.buildGuid,
|
||||
image,
|
||||
[installAndStartRunner],
|
||||
installAndStartRunner,
|
||||
`/runner`,
|
||||
`/runner`,
|
||||
environmentVariables,
|
||||
|
|
|
|||
Loading…
Reference in New Issue