custom hook files and test
parent
fc11d5be8a
commit
cc0a40a2ec
|
|
@ -578,6 +578,7 @@ class Cli {
|
||||||
if (!__1.CloudRunner.buildParameters.retainWorkspace) {
|
if (!__1.CloudRunner.buildParameters.retainWorkspace) {
|
||||||
yield cloud_runner_system_1.CloudRunnerSystem.Run(`rm -r ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}`);
|
yield cloud_runner_system_1.CloudRunnerSystem.Run(`rm -r ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}`);
|
||||||
}
|
}
|
||||||
|
yield remote_client_1.RemoteClient.runCustomHookFiles(`after-build`);
|
||||||
return new Promise((result) => result(``));
|
return new Promise((result) => result(``));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -4154,6 +4155,7 @@ const console_1 = __nccwpck_require__(96206);
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
const cli_functions_repository_1 = __nccwpck_require__(85301);
|
const cli_functions_repository_1 = __nccwpck_require__(85301);
|
||||||
const cloud_runner_system_1 = __nccwpck_require__(99393);
|
const cloud_runner_system_1 = __nccwpck_require__(99393);
|
||||||
|
const yaml_1 = __importDefault(__nccwpck_require__(44603));
|
||||||
class RemoteClient {
|
class RemoteClient {
|
||||||
static bootstrapRepository() {
|
static bootstrapRepository() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -4245,6 +4247,21 @@ class RemoteClient {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
RemoteClient.handleRetainedWorkspace();
|
RemoteClient.handleRetainedWorkspace();
|
||||||
yield RemoteClient.bootstrapRepository();
|
yield RemoteClient.bootstrapRepository();
|
||||||
|
yield RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static runCustomHookFiles(hookLifecycle) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(`RunCustomHookFiles: ${hookLifecycle}`);
|
||||||
|
const gameCiCustomHooksPath = path_1.default.join(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute, `game-ci`, `hooks`);
|
||||||
|
const files = fs_1.default.readdirSync(gameCiCustomHooksPath);
|
||||||
|
for (const file of files) {
|
||||||
|
const fileContents = fs_1.default.readFileSync(file, `utf8`);
|
||||||
|
const fileContentsObject = yaml_1.default.parse(fileContents.toString());
|
||||||
|
if (fileContentsObject.hook === hookLifecycle) {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(`Active Hook File ${file} contents: ${fileContents}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static handleRetainedWorkspace() {
|
static handleRetainedWorkspace() {
|
||||||
|
|
@ -4255,7 +4272,7 @@ class RemoteClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__decorate([
|
__decorate([
|
||||||
cli_functions_repository_1.CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`)
|
cli_functions_repository_1.CliFunction(`remote-cli-pre-build`, `sets up a repository, usually before a game-ci build`)
|
||||||
], RemoteClient, "runRemoteClientJob", null);
|
], RemoteClient, "runRemoteClientJob", null);
|
||||||
exports.RemoteClient = RemoteClient;
|
exports.RemoteClient = RemoteClient;
|
||||||
|
|
||||||
|
|
@ -5159,7 +5176,7 @@ class BuildAutomationWorkflow {
|
||||||
echo "game ci cloud runner clone"
|
echo "game ci cloud runner clone"
|
||||||
if [ -e "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
|
if [ -e "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
|
||||||
echo "game ci cloud runner bootstrap"
|
echo "game ci cloud runner bootstrap"
|
||||||
node ${builderPath} -m remote-cli`;
|
node ${builderPath} -m remote-cli-pre-build`;
|
||||||
}
|
}
|
||||||
// ToDo: Replace with a very simple "node ${builderPath} -m build-cli" to run the scripts below without enlarging the request size
|
// ToDo: Replace with a very simple "node ${builderPath} -m build-cli" to run the scripts below without enlarging the request size
|
||||||
static BuildCommands(builderPath) {
|
static BuildCommands(builderPath) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,3 @@
|
||||||
|
hook: post-build
|
||||||
|
run: |
|
||||||
|
post-build test!
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
hook: pre-build
|
||||||
|
run: |
|
||||||
|
pre-build test!
|
||||||
|
|
@ -133,6 +133,8 @@ export class Cli {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await RemoteClient.runCustomHookFiles(`after-build`);
|
||||||
|
|
||||||
return new Promise((result) => result(``));
|
return new Promise((result) => result(``));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { assert } from 'console';
|
||||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
import { CliFunction } from '../../cli/cli-functions-repository';
|
import { CliFunction } from '../../cli/cli-functions-repository';
|
||||||
import { CloudRunnerSystem } from '../services/cloud-runner-system';
|
import { CloudRunnerSystem } from '../services/cloud-runner-system';
|
||||||
|
import YAML from 'yaml';
|
||||||
|
|
||||||
export class RemoteClient {
|
export class RemoteClient {
|
||||||
public static async bootstrapRepository() {
|
public static async bootstrapRepository() {
|
||||||
|
|
@ -120,10 +121,23 @@ export class RemoteClient {
|
||||||
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
|
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
|
||||||
}
|
}
|
||||||
|
|
||||||
@CliFunction(`remote-cli`, `sets up a repository, usually before a game-ci build`)
|
@CliFunction(`remote-cli-pre-build`, `sets up a repository, usually before a game-ci build`)
|
||||||
static async runRemoteClientJob() {
|
static async runRemoteClientJob() {
|
||||||
RemoteClient.handleRetainedWorkspace();
|
RemoteClient.handleRetainedWorkspace();
|
||||||
await RemoteClient.bootstrapRepository();
|
await RemoteClient.bootstrapRepository();
|
||||||
|
await RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
|
}
|
||||||
|
static async runCustomHookFiles(hookLifecycle: string) {
|
||||||
|
RemoteClientLogger.log(`RunCustomHookFiles: ${hookLifecycle}`);
|
||||||
|
const gameCiCustomHooksPath = path.join(CloudRunnerFolders.repoPathAbsolute, `game-ci`, `hooks`);
|
||||||
|
const files = fs.readdirSync(gameCiCustomHooksPath);
|
||||||
|
for (const file of files) {
|
||||||
|
const fileContents = fs.readFileSync(file, `utf8`);
|
||||||
|
const fileContentsObject = YAML.parse(fileContents.toString());
|
||||||
|
if (fileContentsObject.hook === hookLifecycle) {
|
||||||
|
RemoteClientLogger.log(`Active Hook File ${file} contents: ${fileContents}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static handleRetainedWorkspace() {
|
static handleRetainedWorkspace() {
|
||||||
if (!CloudRunner.buildParameters.retainWorkspace || !CloudRunner.lockedWorkspace) {
|
if (!CloudRunner.buildParameters.retainWorkspace || !CloudRunner.lockedWorkspace) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
import CloudRunner from '../cloud-runner';
|
||||||
|
import { BuildParameters, ImageTag } from '../..';
|
||||||
|
import UnityVersioning from '../../unity-versioning';
|
||||||
|
import { Cli } from '../../cli/cli';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import CloudRunnerOptions from '../cloud-runner-options';
|
||||||
|
import setups from './cloud-runner-suite.test';
|
||||||
|
|
||||||
|
async function CreateParameters(overrides) {
|
||||||
|
if (overrides) {
|
||||||
|
Cli.options = overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
return await BuildParameters.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Cloud Runner Custom Hooks', () => {
|
||||||
|
it('Responds', () => {});
|
||||||
|
setups();
|
||||||
|
if (CloudRunnerOptions.cloudRunnerTests && CloudRunnerOptions.cloudRunnerCluster !== `k8s`) {
|
||||||
|
it('Run one build it should not already be retained, run subsequent build which should use retained workspace', async () => {
|
||||||
|
const overrides = {
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
|
retainWorkspaces: true,
|
||||||
|
};
|
||||||
|
const buildParameter2 = await CreateParameters(overrides);
|
||||||
|
const baseImage2 = new ImageTag(buildParameter2);
|
||||||
|
const results2 = await CloudRunner.run(buildParameter2, baseImage2.toString());
|
||||||
|
CloudRunnerLogger.log(`run 2 succeeded`);
|
||||||
|
|
||||||
|
const build2ContainsRetainedWorkspacePhrase = results2.includes(`Retained Workspace:`);
|
||||||
|
const build2ContainsWorkspaceExistsAlreadyPhrase = results2.includes(`Retained Workspace Already Exists!`);
|
||||||
|
const build2ContainsBuildSucceeded = results2.includes('Build succeeded');
|
||||||
|
const build2ContainsPreBuildHookMessage = results2.includes('pre-build test!');
|
||||||
|
const build2ContainsPostBuildHookMessage = results2.includes('post-build test!');
|
||||||
|
|
||||||
|
expect(build2ContainsRetainedWorkspacePhrase).toBeTruthy();
|
||||||
|
expect(build2ContainsWorkspaceExistsAlreadyPhrase).toBeTruthy();
|
||||||
|
expect(build2ContainsBuildSucceeded).toBeTruthy();
|
||||||
|
expect(build2ContainsPreBuildHookMessage).toBeTruthy();
|
||||||
|
expect(build2ContainsPostBuildHookMessage).toBeTruthy();
|
||||||
|
}, 10000000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -136,7 +136,7 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
|
||||||
CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute,
|
CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute,
|
||||||
)}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
|
)}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
|
||||||
echo "game ci cloud runner bootstrap"
|
echo "game ci cloud runner bootstrap"
|
||||||
node ${builderPath} -m remote-cli`;
|
node ${builderPath} -m remote-cli-pre-build`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo: Replace with a very simple "node ${builderPath} -m build-cli" to run the scripts below without enlarging the request size
|
// ToDo: Replace with a very simple "node ${builderPath} -m build-cli" to run the scripts below without enlarging the request size
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue