fix
parent
eca0bd0778
commit
9193b8fd15
|
|
@ -465,9 +465,9 @@ const console_1 = __webpack_require__(57082);
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
const path_1 = __importDefault(__webpack_require__(85622));
|
const path_1 = __importDefault(__webpack_require__(85622));
|
||||||
const __1 = __webpack_require__(41359);
|
const __1 = __webpack_require__(41359);
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
||||||
|
const remote_client_logger_1 = __webpack_require__(68972);
|
||||||
class Caching {
|
class Caching {
|
||||||
static PushToCache(cacheFolder, destinationFolder, artifactName) {
|
static PushToCache(cacheFolder, destinationFolder, artifactName) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -476,7 +476,7 @@ class Caching {
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -r "${artifactName}.zip" "${path_1.default.dirname(destinationFolder)}"`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`zip -r "${artifactName}.zip" "${path_1.default.dirname(destinationFolder)}"`);
|
||||||
console_1.assert(fs_1.default.existsSync(`${artifactName}.zip`));
|
console_1.assert(fs_1.default.existsSync(`${artifactName}.zip`));
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`cp "${artifactName}.zip" "${path_1.default.join(cacheFolder, `${artifactName}.zip`)}"`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`cp "${artifactName}.zip" "${path_1.default.join(cacheFolder, `${artifactName}.zip`)}"`);
|
||||||
cloud_runner_logger_1.default.logCli(`copied ${artifactName} to ${cacheFolder}`);
|
remote_client_logger_1.RemoteClientLogger.log(`copied ${artifactName} to ${cacheFolder}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -505,12 +505,12 @@ class Caching {
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
||||||
}
|
}
|
||||||
cloud_runner_logger_1.default.logCli(`cache item exists`);
|
remote_client_logger_1.RemoteClientLogger.log(`cache item exists`);
|
||||||
console_1.assert(fs_1.default.existsSync(destinationFolder));
|
console_1.assert(fs_1.default.existsSync(destinationFolder));
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cloud_runner_logger_1.default.logCli(`cache item doesn't exist`);
|
remote_client_logger_1.RemoteClientLogger.logWarning(`cache item ${specificHashMatch} doesn't exist ${destinationFolder}`);
|
||||||
if (cacheSelection !== ``) {
|
if (cacheSelection !== ``) {
|
||||||
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
||||||
}
|
}
|
||||||
|
|
@ -523,7 +523,7 @@ class Caching {
|
||||||
}
|
}
|
||||||
static handleCachePurging() {
|
static handleCachePurging() {
|
||||||
if (process.env.purgeRemoteCaching !== undefined) {
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
cloud_runner_logger_1.default.logCli(`purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}`);
|
remote_client_logger_1.RemoteClientLogger.log(`purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}`);
|
||||||
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.cacheFolder, { recursive: true });
|
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.cacheFolder, { recursive: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -564,39 +564,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.CloudRunnerAgentSystem = void 0;
|
exports.CloudRunnerAgentSystem = void 0;
|
||||||
const child_process_1 = __webpack_require__(63129);
|
const child_process_1 = __webpack_require__(63129);
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
const remote_client_logger_1 = __webpack_require__(68972);
|
||||||
class CloudRunnerAgentSystem {
|
class CloudRunnerAgentSystem {
|
||||||
static Run(command) {
|
static Run(command) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
cloud_runner_logger_1.default.logCli(`${command}`);
|
remote_client_logger_1.RemoteClientLogger.log(`${command}`);
|
||||||
return yield new Promise((promise) => {
|
return yield new Promise((promise) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
const child = child_process_1.exec(command, (error, stdout, stderr) => {
|
const child = child_process_1.exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
cloud_runner_logger_1.default.logCliError(`${error.message}`);
|
remote_client_logger_1.RemoteClientLogger.logCliError(`${error.message}`);
|
||||||
throw new Error(error.toString());
|
throw new Error(error.toString());
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
cloud_runner_logger_1.default.logCliDiagnostic(`${stderr.toString()}`);
|
remote_client_logger_1.RemoteClientLogger.logCliDiagnostic(`${stderr.toString()}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const outputChunk = `${stdout}`;
|
const outputChunk = `${stdout}`;
|
||||||
output += outputChunk;
|
output += outputChunk;
|
||||||
});
|
});
|
||||||
child.on('close', function (code) {
|
child.on('close', function (code) {
|
||||||
cloud_runner_logger_1.default.logCli(`[Exit code ${code}]`);
|
remote_client_logger_1.RemoteClientLogger.log(`[Exit code ${code}]`);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
throw new Error(output);
|
throw new Error(output);
|
||||||
}
|
}
|
||||||
const outputLines = output.split(`\n`);
|
const outputLines = output.split(`\n`);
|
||||||
for (const element of outputLines) {
|
for (const element of outputLines) {
|
||||||
cloud_runner_logger_1.default.logCli(element);
|
remote_client_logger_1.RemoteClientLogger.log(element);
|
||||||
}
|
}
|
||||||
promise(output);
|
promise(output);
|
||||||
});
|
});
|
||||||
|
|
@ -623,19 +620,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.RemoteClient = void 0;
|
exports.RemoteClient = void 0;
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
|
const remote_client_logger_1 = __webpack_require__(68972);
|
||||||
const setup_cloud_runner_repository_1 = __webpack_require__(39656);
|
const setup_cloud_runner_repository_1 = __webpack_require__(39656);
|
||||||
class RemoteClient {
|
class RemoteClient {
|
||||||
static Run() {
|
static Run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
||||||
cloud_runner_logger_1.default.log(`Build Params:
|
remote_client_logger_1.RemoteClientLogger.log(`Build Params:
|
||||||
${JSON.stringify(buildParameter, undefined, 4)}
|
${JSON.stringify(buildParameter, undefined, 4)}
|
||||||
`);
|
`);
|
||||||
cloud_runner_state_1.CloudRunnerState.setup(buildParameter);
|
cloud_runner_state_1.CloudRunnerState.setup(buildParameter);
|
||||||
|
|
@ -702,6 +696,36 @@ class LFSHashing {
|
||||||
exports.LFSHashing = LFSHashing;
|
exports.LFSHashing = LFSHashing;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 68972:
|
||||||
|
/***/ (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 }));
|
||||||
|
exports.RemoteClientLogger = void 0;
|
||||||
|
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
||||||
|
class RemoteClientLogger {
|
||||||
|
static log(message) {
|
||||||
|
cloud_runner_logger_1.default.log(`[Client] ${message}`);
|
||||||
|
}
|
||||||
|
static logCliError(message) {
|
||||||
|
cloud_runner_logger_1.default.log(`[Client][Error] ${message}`);
|
||||||
|
}
|
||||||
|
static logCliDiagnostic(message) {
|
||||||
|
cloud_runner_logger_1.default.log(`[Client][Diagnostic] ${message}`);
|
||||||
|
}
|
||||||
|
static logWarning(message) {
|
||||||
|
cloud_runner_logger_1.default.logWarning(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.RemoteClientLogger = RemoteClientLogger;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 39656:
|
/***/ 39656:
|
||||||
|
|
@ -723,15 +747,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.SetupCloudRunnerRepository = void 0;
|
exports.SetupCloudRunnerRepository = void 0;
|
||||||
const console_1 = __webpack_require__(57082);
|
|
||||||
const fs_1 = __importDefault(__webpack_require__(35747));
|
const fs_1 = __importDefault(__webpack_require__(35747));
|
||||||
const cloud_runner_logger_1 = __importDefault(__webpack_require__(22855));
|
|
||||||
const cloud_runner_state_1 = __webpack_require__(70912);
|
const cloud_runner_state_1 = __webpack_require__(70912);
|
||||||
const caching_1 = __webpack_require__(35010);
|
const caching_1 = __webpack_require__(35010);
|
||||||
const lfs_hashing_1 = __webpack_require__(47011);
|
const lfs_hashing_1 = __webpack_require__(47011);
|
||||||
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
const cloud_runner_agent_system_1 = __webpack_require__(87685);
|
||||||
const path_1 = __importDefault(__webpack_require__(85622));
|
const path_1 = __importDefault(__webpack_require__(85622));
|
||||||
const __1 = __webpack_require__(41359);
|
const __1 = __webpack_require__(41359);
|
||||||
|
const remote_client_logger_1 = __webpack_require__(68972);
|
||||||
class SetupCloudRunnerRepository {
|
class SetupCloudRunnerRepository {
|
||||||
static run() {
|
static run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|
@ -741,12 +764,14 @@ class SetupCloudRunnerRepository {
|
||||||
yield SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles();
|
yield SetupCloudRunnerRepository.cloneRepoWithoutLFSFiles();
|
||||||
SetupCloudRunnerRepository.LFS_ASSETS_HASH = yield lfs_hashing_1.LFSHashing.createLFSHashFiles();
|
SetupCloudRunnerRepository.LFS_ASSETS_HASH = yield lfs_hashing_1.LFSHashing.createLFSHashFiles();
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
cloud_runner_logger_1.default.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
|
remote_client_logger_1.RemoteClientLogger.log(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
|
||||||
}
|
}
|
||||||
yield lfs_hashing_1.LFSHashing.printLFSHashState();
|
yield lfs_hashing_1.LFSHashing.printLFSHashState();
|
||||||
cloud_runner_logger_1.default.logCli(`Library Caching`);
|
remote_client_logger_1.RemoteClientLogger.log(`Library Caching`);
|
||||||
console_1.assert(!fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull), `!Warning!: The Unity library was included in the git repository`);
|
if (!fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
|
||||||
cloud_runner_logger_1.default.logCli(`LFS Caching`);
|
remote_client_logger_1.RemoteClientLogger.logWarning(`!Warning!: The Unity library was included in the git repository`);
|
||||||
|
}
|
||||||
|
remote_client_logger_1.RemoteClientLogger.log(`LFS Caching`);
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree ${path_1.default.join(cloud_runner_state_1.CloudRunnerState.lfsDirectory, '..')}`);
|
||||||
}
|
}
|
||||||
|
|
@ -774,19 +799,19 @@ class SetupCloudRunnerRepository {
|
||||||
static cloneRepoWithoutLFSFiles() {
|
static cloneRepoWithoutLFSFiles() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
cloud_runner_logger_1.default.logCli(`Initializing source repository for cloning with caching of LFS files`);
|
remote_client_logger_1.RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
|
||||||
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git config --global advice.detachedHead false`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git config --global advice.detachedHead false`);
|
||||||
cloud_runner_logger_1.default.logCli(`Cloning the repository being built:`);
|
remote_client_logger_1.RemoteClientLogger.log(`Cloning the repository being built:`);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs install --skip-smudge`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs install --skip-smudge`);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
|
||||||
if (__1.Input.cloudRunnerTests) {
|
if (__1.Input.cloudRunnerTests) {
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -lh`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`ls -lh`);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`tree`);
|
||||||
}
|
}
|
||||||
cloud_runner_logger_1.default.logCli(`${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.branch}`);
|
||||||
cloud_runner_logger_1.default.logCli(`Checked out ${process.env.GITHUB_SHA}`);
|
remote_client_logger_1.RemoteClientLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -797,7 +822,7 @@ class SetupCloudRunnerRepository {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||||
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs pull`);
|
yield cloud_runner_agent_system_1.CloudRunnerAgentSystem.Run(`git lfs pull`);
|
||||||
cloud_runner_logger_1.default.logCli(`pulled latest LFS files`);
|
remote_client_logger_1.RemoteClientLogger.log(`pulled latest LFS files`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2502,14 +2527,8 @@ class CloudRunnerLogger {
|
||||||
static log(message) {
|
static log(message) {
|
||||||
core.info(message);
|
core.info(message);
|
||||||
}
|
}
|
||||||
static logCli(message) {
|
static logWarning(message) {
|
||||||
CloudRunnerLogger.log(`[Client] ${message}`);
|
core.warning(message);
|
||||||
}
|
|
||||||
static logCliError(message) {
|
|
||||||
CloudRunnerLogger.log(`[Client][Error] ${message}`);
|
|
||||||
}
|
|
||||||
static logCliDiagnostic(message) {
|
|
||||||
CloudRunnerLogger.log(`[Client][Diagnostic] ${message}`);
|
|
||||||
}
|
}
|
||||||
static logLine(message) {
|
static logLine(message) {
|
||||||
core.info(`${message}\n`);
|
core.info(`${message}\n`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -2,9 +2,9 @@ import { assert } from 'console';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Input } from '../..';
|
import { Input } from '../..';
|
||||||
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
|
|
||||||
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
||||||
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
|
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
|
||||||
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class Caching {
|
export class Caching {
|
||||||
public static async PushToCache(cacheFolder: string, destinationFolder: string, artifactName: string) {
|
public static async PushToCache(cacheFolder: string, destinationFolder: string, artifactName: string) {
|
||||||
|
|
@ -13,7 +13,7 @@ export class Caching {
|
||||||
await CloudRunnerAgentSystem.Run(`zip -r "${artifactName}.zip" "${path.dirname(destinationFolder)}"`);
|
await CloudRunnerAgentSystem.Run(`zip -r "${artifactName}.zip" "${path.dirname(destinationFolder)}"`);
|
||||||
assert(fs.existsSync(`${artifactName}.zip`));
|
assert(fs.existsSync(`${artifactName}.zip`));
|
||||||
await CloudRunnerAgentSystem.Run(`cp "${artifactName}.zip" "${path.join(cacheFolder, `${artifactName}.zip`)}"`);
|
await CloudRunnerAgentSystem.Run(`cp "${artifactName}.zip" "${path.join(cacheFolder, `${artifactName}.zip`)}"`);
|
||||||
CloudRunnerLogger.logCli(`copied ${artifactName} to ${cacheFolder}`);
|
RemoteClientLogger.log(`copied ${artifactName} to ${cacheFolder}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
@ -45,11 +45,11 @@ export class Caching {
|
||||||
if (Input.cloudRunnerTests) {
|
if (Input.cloudRunnerTests) {
|
||||||
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
await CloudRunnerAgentSystem.Run(`tree ${destinationFolder}`);
|
||||||
}
|
}
|
||||||
CloudRunnerLogger.logCli(`cache item exists`);
|
RemoteClientLogger.log(`cache item exists`);
|
||||||
assert(fs.existsSync(destinationFolder));
|
assert(fs.existsSync(destinationFolder));
|
||||||
await CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
|
await CloudRunnerAgentSystem.Run(`unzip "${cacheSelection}" -d "${destinationFolder}/.."`);
|
||||||
} else {
|
} else {
|
||||||
CloudRunnerLogger.logCli(`cache item doesn't exist`);
|
RemoteClientLogger.logWarning(`cache item ${specificHashMatch} doesn't exist ${destinationFolder}`);
|
||||||
if (cacheSelection !== ``) {
|
if (cacheSelection !== ``) {
|
||||||
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
throw new Error(`Failed to get cache item, but cache hit was found: ${cacheSelection}`);
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +61,7 @@ export class Caching {
|
||||||
|
|
||||||
public static handleCachePurging() {
|
public static handleCachePurging() {
|
||||||
if (process.env.purgeRemoteCaching !== undefined) {
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
CloudRunnerLogger.logCli(`purging ${CloudRunnerState.purgeRemoteCaching}`);
|
RemoteClientLogger.log(`purging ${CloudRunnerState.purgeRemoteCaching}`);
|
||||||
fs.rmdirSync(CloudRunnerState.cacheFolder, { recursive: true });
|
fs.rmdirSync(CloudRunnerState.cacheFolder, { recursive: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,31 @@
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class CloudRunnerAgentSystem {
|
export class CloudRunnerAgentSystem {
|
||||||
public static async Run(command: string) {
|
public static async Run(command: string) {
|
||||||
CloudRunnerLogger.logCli(`${command}`);
|
RemoteClientLogger.log(`${command}`);
|
||||||
return await new Promise<string>((promise) => {
|
return await new Promise<string>((promise) => {
|
||||||
let output = '';
|
let output = '';
|
||||||
const child = exec(command, (error, stdout, stderr) => {
|
const child = exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
CloudRunnerLogger.logCliError(`${error.message}`);
|
RemoteClientLogger.logCliError(`${error.message}`);
|
||||||
throw new Error(error.toString());
|
throw new Error(error.toString());
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
CloudRunnerLogger.logCliDiagnostic(`${stderr.toString()}`);
|
RemoteClientLogger.logCliDiagnostic(`${stderr.toString()}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const outputChunk = `${stdout}`;
|
const outputChunk = `${stdout}`;
|
||||||
output += outputChunk;
|
output += outputChunk;
|
||||||
});
|
});
|
||||||
child.on('close', function (code) {
|
child.on('close', function (code) {
|
||||||
CloudRunnerLogger.logCli(`[Exit code ${code}]`);
|
RemoteClientLogger.log(`[Exit code ${code}]`);
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
throw new Error(output);
|
throw new Error(output);
|
||||||
}
|
}
|
||||||
const outputLines = output.split(`\n`);
|
const outputLines = output.split(`\n`);
|
||||||
for (const element of outputLines) {
|
for (const element of outputLines) {
|
||||||
CloudRunnerLogger.logCli(element);
|
RemoteClientLogger.log(element);
|
||||||
}
|
}
|
||||||
promise(output);
|
promise(output);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
|
|
||||||
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
||||||
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
import { SetupCloudRunnerRepository } from './setup-cloud-runner-repository';
|
import { SetupCloudRunnerRepository } from './setup-cloud-runner-repository';
|
||||||
|
|
||||||
export class RemoteClient {
|
export class RemoteClient {
|
||||||
static async Run() {
|
static async Run() {
|
||||||
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
const buildParameter = JSON.parse(process.env.BUILD_PARAMETERS || '{}');
|
||||||
CloudRunnerLogger.log(`Build Params:
|
RemoteClientLogger.log(`Build Params:
|
||||||
${JSON.stringify(buildParameter, undefined, 4)}
|
${JSON.stringify(buildParameter, undefined, 4)}
|
||||||
`);
|
`);
|
||||||
CloudRunnerState.setup(buildParameter);
|
CloudRunnerState.setup(buildParameter);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
|
||||||
|
|
||||||
|
export class RemoteClientLogger {
|
||||||
|
public static log(message: string) {
|
||||||
|
CloudRunnerLogger.log(`[Client] ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static logCliError(message: string) {
|
||||||
|
CloudRunnerLogger.log(`[Client][Error] ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static logCliDiagnostic(message: string) {
|
||||||
|
CloudRunnerLogger.log(`[Client][Diagnostic] ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static logWarning(message) {
|
||||||
|
CloudRunnerLogger.logWarning(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
import { assert } from 'console';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger';
|
|
||||||
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
||||||
import { Caching } from './caching';
|
import { Caching } from './caching';
|
||||||
import { LFSHashing } from './lfs-hashing';
|
import { LFSHashing } from './lfs-hashing';
|
||||||
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
|
import { CloudRunnerAgentSystem } from './cloud-runner-agent-system';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Input } from '../..';
|
import { Input } from '../..';
|
||||||
|
import { RemoteClientLogger } from './remote-client-logger';
|
||||||
|
|
||||||
export class SetupCloudRunnerRepository {
|
export class SetupCloudRunnerRepository {
|
||||||
static LFS_ASSETS_HASH;
|
static LFS_ASSETS_HASH;
|
||||||
|
|
@ -19,15 +18,14 @@ export class SetupCloudRunnerRepository {
|
||||||
SetupCloudRunnerRepository.LFS_ASSETS_HASH = await LFSHashing.createLFSHashFiles();
|
SetupCloudRunnerRepository.LFS_ASSETS_HASH = await LFSHashing.createLFSHashFiles();
|
||||||
|
|
||||||
if (Input.cloudRunnerTests) {
|
if (Input.cloudRunnerTests) {
|
||||||
CloudRunnerLogger.logCli(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
|
RemoteClientLogger.log(SetupCloudRunnerRepository.LFS_ASSETS_HASH);
|
||||||
}
|
}
|
||||||
await LFSHashing.printLFSHashState();
|
await LFSHashing.printLFSHashState();
|
||||||
CloudRunnerLogger.logCli(`Library Caching`);
|
RemoteClientLogger.log(`Library Caching`);
|
||||||
assert(
|
if (!fs.existsSync(CloudRunnerState.libraryFolderFull)) {
|
||||||
!fs.existsSync(CloudRunnerState.libraryFolderFull),
|
RemoteClientLogger.logWarning(`!Warning!: The Unity library was included in the git repository`);
|
||||||
`!Warning!: The Unity library was included in the git repository`,
|
}
|
||||||
);
|
RemoteClientLogger.log(`LFS Caching`);
|
||||||
CloudRunnerLogger.logCli(`LFS Caching`);
|
|
||||||
|
|
||||||
if (Input.cloudRunnerTests) {
|
if (Input.cloudRunnerTests) {
|
||||||
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
|
await CloudRunnerAgentSystem.Run(`tree ${path.join(CloudRunnerState.lfsDirectory, '..')}`);
|
||||||
|
|
@ -65,10 +63,10 @@ export class SetupCloudRunnerRepository {
|
||||||
|
|
||||||
private static async cloneRepoWithoutLFSFiles() {
|
private static async cloneRepoWithoutLFSFiles() {
|
||||||
try {
|
try {
|
||||||
CloudRunnerLogger.logCli(`Initializing source repository for cloning with caching of LFS files`);
|
RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
|
||||||
process.chdir(CloudRunnerState.repoPathFull);
|
process.chdir(CloudRunnerState.repoPathFull);
|
||||||
await CloudRunnerAgentSystem.Run(`git config --global advice.detachedHead false`);
|
await CloudRunnerAgentSystem.Run(`git config --global advice.detachedHead false`);
|
||||||
CloudRunnerLogger.logCli(`Cloning the repository being built:`);
|
RemoteClientLogger.log(`Cloning the repository being built:`);
|
||||||
await CloudRunnerAgentSystem.Run(`git lfs install --skip-smudge`);
|
await CloudRunnerAgentSystem.Run(`git lfs install --skip-smudge`);
|
||||||
await CloudRunnerAgentSystem.Run(
|
await CloudRunnerAgentSystem.Run(
|
||||||
`git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}`,
|
`git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}`,
|
||||||
|
|
@ -77,9 +75,9 @@ export class SetupCloudRunnerRepository {
|
||||||
await CloudRunnerAgentSystem.Run(`ls -lh`);
|
await CloudRunnerAgentSystem.Run(`ls -lh`);
|
||||||
await CloudRunnerAgentSystem.Run(`tree`);
|
await CloudRunnerAgentSystem.Run(`tree`);
|
||||||
}
|
}
|
||||||
CloudRunnerLogger.logCli(`${CloudRunnerState.buildParams.branch}`);
|
RemoteClientLogger.log(`${CloudRunnerState.buildParams.branch}`);
|
||||||
await CloudRunnerAgentSystem.Run(`git checkout ${CloudRunnerState.buildParams.branch}`);
|
await CloudRunnerAgentSystem.Run(`git checkout ${CloudRunnerState.buildParams.branch}`);
|
||||||
CloudRunnerLogger.logCli(`Checked out ${process.env.GITHUB_SHA}`);
|
RemoteClientLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +86,6 @@ export class SetupCloudRunnerRepository {
|
||||||
private static async pullLatestLFS() {
|
private static async pullLatestLFS() {
|
||||||
process.chdir(CloudRunnerState.repoPathFull);
|
process.chdir(CloudRunnerState.repoPathFull);
|
||||||
await CloudRunnerAgentSystem.Run(`git lfs pull`);
|
await CloudRunnerAgentSystem.Run(`git lfs pull`);
|
||||||
CloudRunnerLogger.logCli(`pulled latest LFS files`);
|
RemoteClientLogger.log(`pulled latest LFS files`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,8 @@ class CloudRunnerLogger {
|
||||||
core.info(message);
|
core.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static logCli(message: string) {
|
public static logWarning(message: string) {
|
||||||
CloudRunnerLogger.log(`[Client] ${message}`);
|
core.warning(message);
|
||||||
}
|
|
||||||
|
|
||||||
public static logCliError(message: string) {
|
|
||||||
CloudRunnerLogger.log(`[Client][Error] ${message}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static logCliDiagnostic(message: string) {
|
|
||||||
CloudRunnerLogger.log(`[Client][Diagnostic] ${message}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static logLine(message: string) {
|
public static logLine(message: string) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue