fixes
parent
e687e5a81f
commit
e14aea2c63
|
@ -4182,7 +4182,36 @@ 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));
|
const yaml_1 = __importDefault(__nccwpck_require__(44603));
|
||||||
const github_1 = __importDefault(__nccwpck_require__(83654));
|
const github_1 = __importDefault(__nccwpck_require__(83654));
|
||||||
|
const task_parameter_serializer_1 = __nccwpck_require__(35346);
|
||||||
class RemoteClient {
|
class RemoteClient {
|
||||||
|
static async runRemoteClientJob() {
|
||||||
|
if (!(await RemoteClient.handleRetainedWorkspace())) {
|
||||||
|
await RemoteClient.bootstrapRepository();
|
||||||
|
}
|
||||||
|
await RemoteClient.exportCiParameters();
|
||||||
|
await RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
|
}
|
||||||
|
static async exportCiParameters() {
|
||||||
|
await task_parameter_serializer_1.TaskParameterSerializer.exportAllCiVariablesWithoutPrefix();
|
||||||
|
}
|
||||||
|
static async runCustomHookFiles(hookLifecycle) {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(`RunCustomHookFiles: ${hookLifecycle}`);
|
||||||
|
const gameCiCustomHooksPath = node_path_1.default.join(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute, `game-ci`, `hooks`);
|
||||||
|
try {
|
||||||
|
const files = node_fs_1.default.readdirSync(gameCiCustomHooksPath);
|
||||||
|
for (const file of files) {
|
||||||
|
const fileContents = node_fs_1.default.readFileSync(node_path_1.default.join(gameCiCustomHooksPath, file), `utf8`);
|
||||||
|
const fileContentsObject = yaml_1.default.parse(fileContents.toString());
|
||||||
|
if (fileContentsObject.hook === hookLifecycle) {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(`Active Hook File ${file} \n \n file contents: \n ${fileContents}`);
|
||||||
|
await cloud_runner_system_1.CloudRunnerSystem.Run(fileContentsObject.commands);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(JSON.stringify(error, undefined, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
static async bootstrapRepository() {
|
static async bootstrapRepository() {
|
||||||
await cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute)}`);
|
await cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute)}`);
|
||||||
await cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.cacheFolderForCacheKeyFull)}`);
|
await cloud_runner_system_1.CloudRunnerSystem.Run(`mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.cacheFolderForCacheKeyFull)}`);
|
||||||
|
@ -4265,30 +4294,6 @@ class RemoteClient {
|
||||||
node_console_1.assert(node_fs_1.default.existsSync(cloud_runner_folders_1.CloudRunnerFolders.lfsFolderAbsolute));
|
node_console_1.assert(node_fs_1.default.existsSync(cloud_runner_folders_1.CloudRunnerFolders.lfsFolderAbsolute));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async runRemoteClientJob() {
|
|
||||||
if (!(await RemoteClient.handleRetainedWorkspace())) {
|
|
||||||
await RemoteClient.bootstrapRepository();
|
|
||||||
}
|
|
||||||
await RemoteClient.runCustomHookFiles(`before-build`);
|
|
||||||
}
|
|
||||||
static async runCustomHookFiles(hookLifecycle) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`RunCustomHookFiles: ${hookLifecycle}`);
|
|
||||||
const gameCiCustomHooksPath = node_path_1.default.join(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute, `game-ci`, `hooks`);
|
|
||||||
try {
|
|
||||||
const files = node_fs_1.default.readdirSync(gameCiCustomHooksPath);
|
|
||||||
for (const file of files) {
|
|
||||||
const fileContents = node_fs_1.default.readFileSync(node_path_1.default.join(gameCiCustomHooksPath, file), `utf8`);
|
|
||||||
const fileContentsObject = yaml_1.default.parse(fileContents.toString());
|
|
||||||
if (fileContentsObject.hook === hookLifecycle) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Active Hook File ${file} \n \n file contents: \n ${fileContents}`);
|
|
||||||
await cloud_runner_system_1.CloudRunnerSystem.Run(fileContentsObject.commands);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
remote_client_logger_1.RemoteClientLogger.log(JSON.stringify(error, undefined, 4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async handleRetainedWorkspace() {
|
static async handleRetainedWorkspace() {
|
||||||
if (!cloud_runner_1.default.buildParameters.retainWorkspaces) {
|
if (!cloud_runner_1.default.buildParameters.retainWorkspaces) {
|
||||||
return;
|
return;
|
||||||
|
@ -5589,6 +5594,11 @@ class TaskParameterSerializer {
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
static async exportAllCiVariablesWithoutPrefix() {
|
||||||
|
for (const variable of Object.entries(process.env)) {
|
||||||
|
process.env[variable[0].replace(`CI_`, ``)] = variable[1] || ``;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.TaskParameterSerializer = TaskParameterSerializer;
|
exports.TaskParameterSerializer = TaskParameterSerializer;
|
||||||
TaskParameterSerializer.blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']);
|
TaskParameterSerializer.blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,8 +11,37 @@ 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';
|
import YAML from 'yaml';
|
||||||
import GitHub from '../../github';
|
import GitHub from '../../github';
|
||||||
|
import { TaskParameterSerializer } from '../services/task-parameter-serializer';
|
||||||
|
|
||||||
export class RemoteClient {
|
export class RemoteClient {
|
||||||
|
@CliFunction(`remote-cli-pre-build`, `sets up a repository, usually before a game-ci build`)
|
||||||
|
static async runRemoteClientJob() {
|
||||||
|
if (!(await RemoteClient.handleRetainedWorkspace())) {
|
||||||
|
await RemoteClient.bootstrapRepository();
|
||||||
|
}
|
||||||
|
await RemoteClient.exportCiParameters();
|
||||||
|
await RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
|
}
|
||||||
|
static async exportCiParameters() {
|
||||||
|
await TaskParameterSerializer.exportAllCiVariablesWithoutPrefix();
|
||||||
|
}
|
||||||
|
static async runCustomHookFiles(hookLifecycle: string) {
|
||||||
|
RemoteClientLogger.log(`RunCustomHookFiles: ${hookLifecycle}`);
|
||||||
|
const gameCiCustomHooksPath = path.join(CloudRunnerFolders.repoPathAbsolute, `game-ci`, `hooks`);
|
||||||
|
try {
|
||||||
|
const files = fs.readdirSync(gameCiCustomHooksPath);
|
||||||
|
for (const file of files) {
|
||||||
|
const fileContents = fs.readFileSync(path.join(gameCiCustomHooksPath, file), `utf8`);
|
||||||
|
const fileContentsObject = YAML.parse(fileContents.toString());
|
||||||
|
if (fileContentsObject.hook === hookLifecycle) {
|
||||||
|
RemoteClientLogger.log(`Active Hook File ${file} \n \n file contents: \n ${fileContents}`);
|
||||||
|
await CloudRunnerSystem.Run(fileContentsObject.commands);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
RemoteClientLogger.log(JSON.stringify(error, undefined, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
public static async bootstrapRepository() {
|
public static async bootstrapRepository() {
|
||||||
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute)}`);
|
await CloudRunnerSystem.Run(`mkdir -p ${CloudRunnerFolders.ToLinuxFolder(CloudRunnerFolders.repoPathAbsolute)}`);
|
||||||
await CloudRunnerSystem.Run(
|
await CloudRunnerSystem.Run(
|
||||||
|
@ -122,31 +151,6 @@ export class RemoteClient {
|
||||||
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
|
assert(fs.existsSync(CloudRunnerFolders.lfsFolderAbsolute));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CliFunction(`remote-cli-pre-build`, `sets up a repository, usually before a game-ci build`)
|
|
||||||
static async runRemoteClientJob() {
|
|
||||||
if (!(await RemoteClient.handleRetainedWorkspace())) {
|
|
||||||
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`);
|
|
||||||
try {
|
|
||||||
const files = fs.readdirSync(gameCiCustomHooksPath);
|
|
||||||
for (const file of files) {
|
|
||||||
const fileContents = fs.readFileSync(path.join(gameCiCustomHooksPath, file), `utf8`);
|
|
||||||
const fileContentsObject = YAML.parse(fileContents.toString());
|
|
||||||
if (fileContentsObject.hook === hookLifecycle) {
|
|
||||||
RemoteClientLogger.log(`Active Hook File ${file} \n \n file contents: \n ${fileContents}`);
|
|
||||||
await CloudRunnerSystem.Run(fileContentsObject.commands);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
RemoteClientLogger.log(JSON.stringify(error, undefined, 4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static async handleRetainedWorkspace() {
|
static async handleRetainedWorkspace() {
|
||||||
if (!CloudRunner.buildParameters.retainWorkspaces) {
|
if (!CloudRunner.buildParameters.retainWorkspaces) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -153,4 +153,9 @@ export class TaskParameterSerializer {
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
public static async exportAllCiVariablesWithoutPrefix() {
|
||||||
|
for (const variable of Object.entries(process.env)) {
|
||||||
|
process.env[variable[0].replace(`CI_`, ``)] = variable[1] || ``;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue