stream logs through standard input and new remote client cli command
parent
16284dcf8d
commit
8a501a6c9f
|
@ -526,6 +526,7 @@ class Cli {
|
||||||
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
|
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
|
||||||
program.option('--artifactName <artifactName>', 'caching artifact name');
|
program.option('--artifactName <artifactName>', 'caching artifact name');
|
||||||
program.option('--select <select>', 'select a particular resource');
|
program.option('--select <select>', 'select a particular resource');
|
||||||
|
program.option('--logFile <logFile>', 'output to log file (log stream only)');
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
Cli.options = program.opts();
|
Cli.options = program.opts();
|
||||||
return Cli.isCliMode;
|
return Cli.isCliMode;
|
||||||
|
@ -4295,6 +4296,7 @@ const cloud_runner_system_1 = __nccwpck_require__(4197);
|
||||||
const yaml_1 = __importDefault(__nccwpck_require__(44603));
|
const yaml_1 = __importDefault(__nccwpck_require__(44603));
|
||||||
const github_1 = __importDefault(__nccwpck_require__(39789));
|
const github_1 = __importDefault(__nccwpck_require__(39789));
|
||||||
const build_parameters_1 = __importDefault(__nccwpck_require__(80787));
|
const build_parameters_1 = __importDefault(__nccwpck_require__(80787));
|
||||||
|
const cli_1 = __nccwpck_require__(55651);
|
||||||
class RemoteClient {
|
class RemoteClient {
|
||||||
static async setupRemoteClient() {
|
static async setupRemoteClient() {
|
||||||
cloud_runner_logger_1.default.log(`bootstrap game ci cloud runner...`);
|
cloud_runner_logger_1.default.log(`bootstrap game ci cloud runner...`);
|
||||||
|
@ -4304,6 +4306,23 @@ class RemoteClient {
|
||||||
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
|
await RemoteClient.replaceLargePackageReferencesWithSharedReferences();
|
||||||
await RemoteClient.runCustomHookFiles(`before-build`);
|
await RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
}
|
}
|
||||||
|
static async remoteClientLogStream() {
|
||||||
|
const logFile = cli_1.Cli.options['logFile'];
|
||||||
|
process.stdin.resume();
|
||||||
|
process.stdin.setEncoding('utf8');
|
||||||
|
let lingeringLine = '';
|
||||||
|
process.stdin.on('data', (chunk) => {
|
||||||
|
const lines = chunk.toString().split('\n');
|
||||||
|
lines[0] = lingeringLine + lines[0];
|
||||||
|
lingeringLine = lines.pop() || '';
|
||||||
|
for (const element of lines) {
|
||||||
|
node_fs_1.default.appendFileSync(logFile, element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
process.stdin.on('end', function () {
|
||||||
|
node_fs_1.default.appendFileSync(logFile, lingeringLine);
|
||||||
|
});
|
||||||
|
}
|
||||||
static async remoteClientPostBuild() {
|
static async remoteClientPostBuild() {
|
||||||
remote_client_logger_1.RemoteClientLogger.log(`Running POST build tasks`);
|
remote_client_logger_1.RemoteClientLogger.log(`Running POST build tasks`);
|
||||||
await caching_1.Caching.PushToCache(cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(`${cloud_runner_folders_1.CloudRunnerFolders.cacheFolderForCacheKeyFull}/Library`), cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.libraryFolderAbsolute), `lib-${cloud_runner_1.default.buildParameters.buildGuid}`);
|
await caching_1.Caching.PushToCache(cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(`${cloud_runner_folders_1.CloudRunnerFolders.cacheFolderForCacheKeyFull}/Library`), cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.libraryFolderAbsolute), `lib-${cloud_runner_1.default.buildParameters.buildGuid}`);
|
||||||
|
@ -4437,6 +4456,9 @@ class RemoteClient {
|
||||||
__decorate([
|
__decorate([
|
||||||
cli_functions_repository_1.CliFunction(`remote-cli-pre-build`, `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, "setupRemoteClient", null);
|
], RemoteClient, "setupRemoteClient", null);
|
||||||
|
__decorate([
|
||||||
|
cli_functions_repository_1.CliFunction('remote-cli-log-stream', `log stream from standard input`)
|
||||||
|
], RemoteClient, "remoteClientLogStream", null);
|
||||||
__decorate([
|
__decorate([
|
||||||
cli_functions_repository_1.CliFunction(`remote-cli-post-build`, `runs a cloud runner build`)
|
cli_functions_repository_1.CliFunction(`remote-cli-post-build`, `runs a cloud runner build`)
|
||||||
], RemoteClient, "remoteClientPostBuild", null);
|
], RemoteClient, "remoteClientPostBuild", null);
|
||||||
|
@ -5708,7 +5730,7 @@ node ${builderPath} -m remote-cli-pre-build`;
|
||||||
chmod -R +x "/steps"
|
chmod -R +x "/steps"
|
||||||
echo "game ci start"
|
echo "game ci start"
|
||||||
echo "game ci start" >> /home/job-log.txt
|
echo "game ci start" >> /home/job-log.txt
|
||||||
/entrypoint.sh | tee /home/build-log.txt
|
/entrypoint.sh | node ${builderPath} -m remote-cli-log-stream /home/build-log.txt
|
||||||
cat /home/build-log.txt >> /home/job-log.txt
|
cat /home/build-log.txt >> /home/job-log.txt
|
||||||
node ${builderPath} -m remote-cli-post-build`;
|
node ${builderPath} -m remote-cli-post-build`;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -52,6 +52,7 @@ export class Cli {
|
||||||
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
|
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
|
||||||
program.option('--artifactName <artifactName>', 'caching artifact name');
|
program.option('--artifactName <artifactName>', 'caching artifact name');
|
||||||
program.option('--select <select>', 'select a particular resource');
|
program.option('--select <select>', 'select a particular resource');
|
||||||
|
program.option('--logFile <logFile>', 'output to log file (log stream only)');
|
||||||
program.parse(process.argv);
|
program.parse(process.argv);
|
||||||
Cli.options = program.opts();
|
Cli.options = program.opts();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { CloudRunnerSystem } from '../services/core/cloud-runner-system';
|
||||||
import YAML from 'yaml';
|
import YAML from 'yaml';
|
||||||
import GitHub from '../../github';
|
import GitHub from '../../github';
|
||||||
import BuildParameters from '../../build-parameters';
|
import BuildParameters from '../../build-parameters';
|
||||||
|
import { Cli } from '../../cli/cli';
|
||||||
|
|
||||||
export class RemoteClient {
|
export class RemoteClient {
|
||||||
@CliFunction(`remote-cli-pre-build`, `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`)
|
||||||
|
@ -24,6 +25,30 @@ export class RemoteClient {
|
||||||
await RemoteClient.runCustomHookFiles(`before-build`);
|
await RemoteClient.runCustomHookFiles(`before-build`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CliFunction('remote-cli-log-stream', `log stream from standard input`)
|
||||||
|
public static async remoteClientLogStream() {
|
||||||
|
const logFile = Cli.options!['logFile'];
|
||||||
|
process.stdin.resume();
|
||||||
|
process.stdin.setEncoding('utf8');
|
||||||
|
|
||||||
|
let lingeringLine = '';
|
||||||
|
|
||||||
|
process.stdin.on('data', (chunk) => {
|
||||||
|
const lines = chunk.toString().split('\n');
|
||||||
|
|
||||||
|
lines[0] = lingeringLine + lines[0];
|
||||||
|
lingeringLine = lines.pop() || '';
|
||||||
|
|
||||||
|
for (const element of lines) {
|
||||||
|
fs.appendFileSync(logFile, element);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stdin.on('end', function () {
|
||||||
|
fs.appendFileSync(logFile, lingeringLine);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@CliFunction(`remote-cli-post-build`, `runs a cloud runner build`)
|
@CliFunction(`remote-cli-post-build`, `runs a cloud runner build`)
|
||||||
public static async remoteClientPostBuild(): Promise<string> {
|
public static async remoteClientPostBuild(): Promise<string> {
|
||||||
RemoteClientLogger.log(`Running POST build tasks`);
|
RemoteClientLogger.log(`Running POST build tasks`);
|
||||||
|
|
|
@ -110,7 +110,7 @@ node ${builderPath} -m remote-cli-pre-build`;
|
||||||
chmod -R +x "/steps"
|
chmod -R +x "/steps"
|
||||||
echo "game ci start"
|
echo "game ci start"
|
||||||
echo "game ci start" >> /home/job-log.txt
|
echo "game ci start" >> /home/job-log.txt
|
||||||
/entrypoint.sh | tee /home/build-log.txt
|
/entrypoint.sh | node ${builderPath} -m remote-cli-log-stream /home/build-log.txt
|
||||||
cat /home/build-log.txt >> /home/job-log.txt
|
cat /home/build-log.txt >> /home/job-log.txt
|
||||||
node ${builderPath} -m remote-cli-post-build`;
|
node ${builderPath} -m remote-cli-post-build`;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue