Cleanup logging
parent
4f8aef5354
commit
b28e93012b
|
|
@ -2051,18 +2051,18 @@ class DownloadRepository {
|
||||||
yield run_cli_1.RunCli.RunCli(`tree -f -L 2`);
|
yield run_cli_1.RunCli.RunCli(`tree -f -L 2`);
|
||||||
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.buildPathFull);
|
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.buildPathFull);
|
||||||
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||||
cloud_runner_logger_1.default.log(`Initializing source repository for cloning with caching of LFS files`);
|
cloud_runner_logger_1.default.logRemoteCli(`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);
|
||||||
// stop annoying git detatched head info
|
// stop annoying git detatched head info
|
||||||
yield run_cli_1.RunCli.RunCli(`git config --global advice.detachedHead false`);
|
yield run_cli_1.RunCli.RunCli(`git config --global advice.detachedHead false`);
|
||||||
cloud_runner_logger_1.default.log(`Cloning the repository being built:`);
|
cloud_runner_logger_1.default.logRemoteCli(`Cloning the repository being built:`);
|
||||||
yield run_cli_1.RunCli.RunCli(`git lfs install --skip-smudge`);
|
yield run_cli_1.RunCli.RunCli(`git lfs install --skip-smudge`);
|
||||||
cloud_runner_logger_1.default.log(cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl);
|
cloud_runner_logger_1.default.logRemoteCli(cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
git clone ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}
|
||||||
git checkout ${process.env.GITHUB_SHA}
|
git checkout ${process.env.GITHUB_SHA}
|
||||||
`);
|
`);
|
||||||
cloud_runner_logger_1.default.log(`Checked out ${process.env.GITHUB_SHA}`);
|
cloud_runner_logger_1.default.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
||||||
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
||||||
|
|
@ -2083,48 +2083,48 @@ class DownloadRepository {
|
||||||
const lfsCacheFolder = path_1.default.join(cloud_runner_state_1.CloudRunnerState.cacheFolderFull, `lfs`);
|
const lfsCacheFolder = path_1.default.join(cloud_runner_state_1.CloudRunnerState.cacheFolderFull, `lfs`);
|
||||||
const libraryCacheFolder = path_1.default.join(cloud_runner_state_1.CloudRunnerState.cacheFolderFull, `lib`);
|
const libraryCacheFolder = path_1.default.join(cloud_runner_state_1.CloudRunnerState.cacheFolderFull, `lib`);
|
||||||
yield run_cli_1.RunCli.RunCli(`tree ${cloud_runner_state_1.CloudRunnerState.builderPathFull}`);
|
yield run_cli_1.RunCli.RunCli(`tree ${cloud_runner_state_1.CloudRunnerState.builderPathFull}`);
|
||||||
cloud_runner_logger_1.default.log(`Starting checks of cache for the Unity project Library and git LFS files`);
|
cloud_runner_logger_1.default.logRemoteCli(`Starting checks of cache for the Unity project Library and git LFS files`);
|
||||||
if (!fs_1.default.existsSync(lfsCacheFolder)) {
|
if (!fs_1.default.existsSync(lfsCacheFolder)) {
|
||||||
fs_1.default.mkdirSync(lfsCacheFolder);
|
fs_1.default.mkdirSync(lfsCacheFolder);
|
||||||
}
|
}
|
||||||
if (!fs_1.default.existsSync(libraryCacheFolder)) {
|
if (!fs_1.default.existsSync(libraryCacheFolder)) {
|
||||||
fs_1.default.mkdirSync(libraryCacheFolder);
|
fs_1.default.mkdirSync(libraryCacheFolder);
|
||||||
}
|
}
|
||||||
cloud_runner_logger_1.default.log(`Library Caching`);
|
cloud_runner_logger_1.default.logRemoteCli(`Library Caching`);
|
||||||
//if the unity git project has included the library delete it and echo a warning
|
//if the unity git project has included the library delete it and echo a warning
|
||||||
if (fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
|
if (fs_1.default.existsSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull)) {
|
||||||
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull, { recursive: true });
|
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.libraryFolderFull, { recursive: true });
|
||||||
cloud_runner_logger_1.default.log(`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`);
|
cloud_runner_logger_1.default.logRemoteCli(`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`);
|
||||||
}
|
}
|
||||||
//Restore library cache
|
//Restore library cache
|
||||||
const latestLibraryCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
const latestLibraryCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
||||||
yield run_cli_1.RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
yield run_cli_1.RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
||||||
cloud_runner_logger_1.default.log(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
cloud_runner_logger_1.default.logRemoteCli(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
||||||
if (fs_1.default.existsSync(latestLibraryCacheFile)) {
|
if (fs_1.default.existsSync(latestLibraryCacheFile)) {
|
||||||
cloud_runner_logger_1.default.log(`Library cache exists`);
|
cloud_runner_logger_1.default.logRemoteCli(`Library cache exists`);
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
unzip -q "${path_1.default.join(libraryCacheFolder, latestLibraryCacheFile)}" -d "$projectPathFull"
|
unzip -q "${path_1.default.join(libraryCacheFolder, latestLibraryCacheFile)}" -d "$projectPathFull"
|
||||||
tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
|
tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
cloud_runner_logger_1.default.log(` `);
|
cloud_runner_logger_1.default.logRemoteCli(` `);
|
||||||
cloud_runner_logger_1.default.log(`LFS Caching`);
|
cloud_runner_logger_1.default.logRemoteCli(`LFS Caching`);
|
||||||
process.chdir(lfsCacheFolder);
|
process.chdir(lfsCacheFolder);
|
||||||
let latestLFSCacheFile;
|
let latestLFSCacheFile;
|
||||||
if (fs_1.default.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
|
if (fs_1.default.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
|
||||||
cloud_runner_logger_1.default.log(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
|
cloud_runner_logger_1.default.logRemoteCli(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
|
||||||
latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
|
latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
latestLFSCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
latestLFSCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
||||||
}
|
}
|
||||||
if (fs_1.default.existsSync(latestLFSCacheFile)) {
|
if (fs_1.default.existsSync(latestLFSCacheFile)) {
|
||||||
cloud_runner_logger_1.default.log(`LFS cache exists`);
|
cloud_runner_logger_1.default.logRemoteCli(`LFS cache exists`);
|
||||||
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.lfsDirectory, { recursive: true });
|
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.lfsDirectory, { recursive: true });
|
||||||
cloud_runner_logger_1.default.log(`LFS cache exists from build $latestLFSCacheFile from $branch`);
|
cloud_runner_logger_1.default.logRemoteCli(`LFS cache exists from build $latestLFSCacheFile from $branch`);
|
||||||
yield run_cli_1.RunCli.RunCli(`unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.git`)}"`);
|
yield run_cli_1.RunCli.RunCli(`unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.git`)}"`);
|
||||||
yield run_cli_1.RunCli.RunCli(`ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}"`);
|
yield run_cli_1.RunCli.RunCli(`ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}"`);
|
||||||
cloud_runner_logger_1.default.log(`git LFS folder, (should not contain $latestLFSCacheFile)`);
|
cloud_runner_logger_1.default.logRemoteCli(`git LFS folder, (should not contain $latestLFSCacheFile)`);
|
||||||
}
|
}
|
||||||
yield run_cli_1.RunCli.RunCli(`
|
yield run_cli_1.RunCli.RunCli(`
|
||||||
echo ' '
|
echo ' '
|
||||||
|
|
@ -2143,13 +2143,13 @@ class DownloadRepository {
|
||||||
`);
|
`);
|
||||||
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||||
yield run_cli_1.RunCli.RunCli(`git lfs pull`);
|
yield run_cli_1.RunCli.RunCli(`git lfs pull`);
|
||||||
cloud_runner_logger_1.default.log(`pulled latest LFS files`);
|
cloud_runner_logger_1.default.logRemoteCli(`pulled latest LFS files`);
|
||||||
process.chdir(`${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/..`);
|
process.chdir(`${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/..`);
|
||||||
yield run_cli_1.RunCli.RunCli(`zip -r "${LFS_ASSETS_HASH}.zip" "./lfs"`);
|
yield run_cli_1.RunCli.RunCli(`zip -r "${LFS_ASSETS_HASH}.zip" "./lfs"`);
|
||||||
fs_1.default.copyFileSync(`${LFS_ASSETS_HASH}.zip`, lfsCacheFolder);
|
fs_1.default.copyFileSync(`${LFS_ASSETS_HASH}.zip`, lfsCacheFolder);
|
||||||
cloud_runner_logger_1.default.log(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
cloud_runner_logger_1.default.logRemoteCli(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||||
if (process.env.purgeRemoteCaching !== undefined) {
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
cloud_runner_logger_1.default.log(`purging ${cloud_runner_state_1.CloudRunnerState.purgeRemoteCaching}`);
|
cloud_runner_logger_1.default.logRemoteCli(`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 });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -2174,28 +2174,29 @@ 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.RunCli = void 0;
|
exports.RunCli = 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));
|
||||||
class RunCli {
|
class RunCli {
|
||||||
static RunCli(command) {
|
static RunCli(command) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield new Promise((promise) => {
|
return yield new Promise((promise) => {
|
||||||
child_process_1.exec(command, (error, stdout, stderr) => {
|
child_process_1.exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
// eslint-disable-next-line no-console
|
cloud_runner_logger_1.default.logRemoteCli(`[ERROR] ${error.message}`);
|
||||||
console.log(`[Remote-CLI][ERROR] ${error.message}`);
|
|
||||||
promise(error.message);
|
promise(error.message);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
// eslint-disable-next-line no-console
|
cloud_runner_logger_1.default.logRemoteCli(`[STD-ERROR] ${stderr}`);
|
||||||
console.log(`[Remote-CLI][STD-ERROR] ${stderr}`);
|
|
||||||
promise(stderr);
|
promise(stderr);
|
||||||
throw stderr;
|
throw stderr;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-console
|
cloud_runner_logger_1.default.logRemoteCli(`${stdout}`);
|
||||||
console.log(`[Remote-CLI] ${stdout}`);
|
|
||||||
promise(stdout);
|
promise(stdout);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -2255,6 +2256,9 @@ class CloudRunnerLogger {
|
||||||
static log(message) {
|
static log(message) {
|
||||||
core.info(message);
|
core.info(message);
|
||||||
}
|
}
|
||||||
|
static logRemoteCli(message) {
|
||||||
|
CloudRunnerLogger.log(`[Remote-Cli] ${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
|
|
@ -10,18 +10,18 @@ export class DownloadRepository {
|
||||||
await RunCli.RunCli(`tree -f -L 2`);
|
await RunCli.RunCli(`tree -f -L 2`);
|
||||||
fs.mkdirSync(CloudRunnerState.buildPathFull);
|
fs.mkdirSync(CloudRunnerState.buildPathFull);
|
||||||
fs.mkdirSync(CloudRunnerState.repoPathFull);
|
fs.mkdirSync(CloudRunnerState.repoPathFull);
|
||||||
CloudRunnerLogger.log(`Initializing source repository for cloning with caching of LFS files`);
|
CloudRunnerLogger.logRemoteCli(`Initializing source repository for cloning with caching of LFS files`);
|
||||||
process.chdir(CloudRunnerState.repoPathFull);
|
process.chdir(CloudRunnerState.repoPathFull);
|
||||||
// stop annoying git detatched head info
|
// stop annoying git detatched head info
|
||||||
await RunCli.RunCli(`git config --global advice.detachedHead false`);
|
await RunCli.RunCli(`git config --global advice.detachedHead false`);
|
||||||
CloudRunnerLogger.log(`Cloning the repository being built:`);
|
CloudRunnerLogger.logRemoteCli(`Cloning the repository being built:`);
|
||||||
await RunCli.RunCli(`git lfs install --skip-smudge`);
|
await RunCli.RunCli(`git lfs install --skip-smudge`);
|
||||||
CloudRunnerLogger.log(CloudRunnerState.targetBuildRepoUrl);
|
CloudRunnerLogger.logRemoteCli(CloudRunnerState.targetBuildRepoUrl);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}
|
git clone ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}
|
||||||
git checkout ${process.env.GITHUB_SHA}
|
git checkout ${process.env.GITHUB_SHA}
|
||||||
`);
|
`);
|
||||||
CloudRunnerLogger.log(`Checked out ${process.env.GITHUB_SHA}`);
|
CloudRunnerLogger.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid
|
||||||
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
md5sum .lfs-assets-guid > .lfs-assets-guid-sum
|
||||||
|
|
@ -42,51 +42,51 @@ export class DownloadRepository {
|
||||||
const lfsCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lfs`);
|
const lfsCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lfs`);
|
||||||
const libraryCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lib`);
|
const libraryCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lib`);
|
||||||
await RunCli.RunCli(`tree ${CloudRunnerState.builderPathFull}`);
|
await RunCli.RunCli(`tree ${CloudRunnerState.builderPathFull}`);
|
||||||
CloudRunnerLogger.log(`Starting checks of cache for the Unity project Library and git LFS files`);
|
CloudRunnerLogger.logRemoteCli(`Starting checks of cache for the Unity project Library and git LFS files`);
|
||||||
if (!fs.existsSync(lfsCacheFolder)) {
|
if (!fs.existsSync(lfsCacheFolder)) {
|
||||||
fs.mkdirSync(lfsCacheFolder);
|
fs.mkdirSync(lfsCacheFolder);
|
||||||
}
|
}
|
||||||
if (!fs.existsSync(libraryCacheFolder)) {
|
if (!fs.existsSync(libraryCacheFolder)) {
|
||||||
fs.mkdirSync(libraryCacheFolder);
|
fs.mkdirSync(libraryCacheFolder);
|
||||||
}
|
}
|
||||||
CloudRunnerLogger.log(`Library Caching`);
|
CloudRunnerLogger.logRemoteCli(`Library Caching`);
|
||||||
//if the unity git project has included the library delete it and echo a warning
|
//if the unity git project has included the library delete it and echo a warning
|
||||||
if (fs.existsSync(CloudRunnerState.libraryFolderFull)) {
|
if (fs.existsSync(CloudRunnerState.libraryFolderFull)) {
|
||||||
fs.rmdirSync(CloudRunnerState.libraryFolderFull, { recursive: true });
|
fs.rmdirSync(CloudRunnerState.libraryFolderFull, { recursive: true });
|
||||||
CloudRunnerLogger.log(
|
CloudRunnerLogger.logRemoteCli(
|
||||||
`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`,
|
`!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
//Restore library cache
|
//Restore library cache
|
||||||
const latestLibraryCacheFile = await RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
const latestLibraryCacheFile = await RunCli.RunCli(`ls -t "${libraryCacheFolder}" | grep .zip$ | head -1`);
|
||||||
await RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
await RunCli.RunCli(`ls -lh "${libraryCacheFolder}"`);
|
||||||
CloudRunnerLogger.log(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
CloudRunnerLogger.logRemoteCli(`Checking if Library cache ${libraryCacheFolder}/${latestLibraryCacheFile} exists`);
|
||||||
if (fs.existsSync(latestLibraryCacheFile)) {
|
if (fs.existsSync(latestLibraryCacheFile)) {
|
||||||
CloudRunnerLogger.log(`Library cache exists`);
|
CloudRunnerLogger.logRemoteCli(`Library cache exists`);
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
unzip -q "${path.join(libraryCacheFolder, latestLibraryCacheFile)}" -d "$projectPathFull"
|
unzip -q "${path.join(libraryCacheFolder, latestLibraryCacheFile)}" -d "$projectPathFull"
|
||||||
tree "${CloudRunnerState.libraryFolderFull}"
|
tree "${CloudRunnerState.libraryFolderFull}"
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
CloudRunnerLogger.log(` `);
|
CloudRunnerLogger.logRemoteCli(` `);
|
||||||
CloudRunnerLogger.log(`LFS Caching`);
|
CloudRunnerLogger.logRemoteCli(`LFS Caching`);
|
||||||
process.chdir(lfsCacheFolder);
|
process.chdir(lfsCacheFolder);
|
||||||
let latestLFSCacheFile;
|
let latestLFSCacheFile;
|
||||||
if (fs.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
|
if (fs.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
|
||||||
CloudRunnerLogger.log(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
|
CloudRunnerLogger.logRemoteCli(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
|
||||||
latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
|
latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
|
||||||
} else {
|
} else {
|
||||||
latestLFSCacheFile = await RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
latestLFSCacheFile = await RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
||||||
}
|
}
|
||||||
if (fs.existsSync(latestLFSCacheFile)) {
|
if (fs.existsSync(latestLFSCacheFile)) {
|
||||||
CloudRunnerLogger.log(`LFS cache exists`);
|
CloudRunnerLogger.logRemoteCli(`LFS cache exists`);
|
||||||
fs.rmdirSync(CloudRunnerState.lfsDirectory, { recursive: true });
|
fs.rmdirSync(CloudRunnerState.lfsDirectory, { recursive: true });
|
||||||
CloudRunnerLogger.log(`LFS cache exists from build $latestLFSCacheFile from $branch`);
|
CloudRunnerLogger.logRemoteCli(`LFS cache exists from build $latestLFSCacheFile from $branch`);
|
||||||
await RunCli.RunCli(
|
await RunCli.RunCli(
|
||||||
`unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${path.join(CloudRunnerState.repoPathFull, `.git`)}"`,
|
`unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${path.join(CloudRunnerState.repoPathFull, `.git`)}"`,
|
||||||
);
|
);
|
||||||
await RunCli.RunCli(`ls -lh "${CloudRunnerState.lfsDirectory}"`);
|
await RunCli.RunCli(`ls -lh "${CloudRunnerState.lfsDirectory}"`);
|
||||||
CloudRunnerLogger.log(`git LFS folder, (should not contain $latestLFSCacheFile)`);
|
CloudRunnerLogger.logRemoteCli(`git LFS folder, (should not contain $latestLFSCacheFile)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await RunCli.RunCli(`
|
await RunCli.RunCli(`
|
||||||
|
|
@ -106,13 +106,13 @@ export class DownloadRepository {
|
||||||
`);
|
`);
|
||||||
process.chdir(CloudRunnerState.repoPathFull);
|
process.chdir(CloudRunnerState.repoPathFull);
|
||||||
await RunCli.RunCli(`git lfs pull`);
|
await RunCli.RunCli(`git lfs pull`);
|
||||||
CloudRunnerLogger.log(`pulled latest LFS files`);
|
CloudRunnerLogger.logRemoteCli(`pulled latest LFS files`);
|
||||||
process.chdir(`${CloudRunnerState.lfsDirectory}/..`);
|
process.chdir(`${CloudRunnerState.lfsDirectory}/..`);
|
||||||
await RunCli.RunCli(`zip -r "${LFS_ASSETS_HASH}.zip" "./lfs"`);
|
await RunCli.RunCli(`zip -r "${LFS_ASSETS_HASH}.zip" "./lfs"`);
|
||||||
fs.copyFileSync(`${LFS_ASSETS_HASH}.zip`, lfsCacheFolder);
|
fs.copyFileSync(`${LFS_ASSETS_HASH}.zip`, lfsCacheFolder);
|
||||||
CloudRunnerLogger.log(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
CloudRunnerLogger.logRemoteCli(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||||
if (process.env.purgeRemoteCaching !== undefined) {
|
if (process.env.purgeRemoteCaching !== undefined) {
|
||||||
CloudRunnerLogger.log(`purging ${CloudRunnerState.purgeRemoteCaching}`);
|
CloudRunnerLogger.logRemoteCli(`purging ${CloudRunnerState.purgeRemoteCaching}`);
|
||||||
fs.rmdirSync(CloudRunnerState.cacheFolder, { recursive: true });
|
fs.rmdirSync(CloudRunnerState.cacheFolder, { recursive: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,21 @@
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
|
|
||||||
export class RunCli {
|
export class RunCli {
|
||||||
public static async RunCli(command: string) {
|
public static async RunCli(command: string) {
|
||||||
return await new Promise<string>((promise) => {
|
return await new Promise<string>((promise) => {
|
||||||
exec(command, (error, stdout, stderr) => {
|
exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
// eslint-disable-next-line no-console
|
CloudRunnerLogger.logRemoteCli(`[ERROR] ${error.message}`);
|
||||||
console.log(`[Remote-CLI][ERROR] ${error.message}`);
|
|
||||||
promise(error.message);
|
promise(error.message);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
// eslint-disable-next-line no-console
|
CloudRunnerLogger.logRemoteCli(`[STD-ERROR] ${stderr}`);
|
||||||
console.log(`[Remote-CLI][STD-ERROR] ${stderr}`);
|
|
||||||
promise(stderr);
|
promise(stderr);
|
||||||
throw stderr;
|
throw stderr;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-console
|
CloudRunnerLogger.logRemoteCli(`${stdout}`);
|
||||||
console.log(`[Remote-CLI] ${stdout}`);
|
|
||||||
promise(stdout);
|
promise(stdout);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,10 @@ class CloudRunnerLogger {
|
||||||
core.info(message);
|
core.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static logRemoteCli(message: string) {
|
||||||
|
CloudRunnerLogger.log(`[Remote-Cli] ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
public static logLine(message: string) {
|
public static logLine(message: string) {
|
||||||
core.info(`${message}\n`);
|
core.info(`${message}\n`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue