Converting caching from shell to typescript

pull/310/head
Frostebite 2021-12-24 02:08:42 +00:00
parent 9079429c8d
commit f67f5bc615
3 changed files with 93 additions and 90 deletions

40
dist/index.js vendored
View File

@ -2073,26 +2073,28 @@ class DownloadRepository {
tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}" tree "${cloud_runner_state_1.CloudRunnerState.libraryFolderFull}"
`); `);
} }
yield run_cli_1.RunCli.RunCli(` cloud_runner_logger_1.default.log(` `);
echo ' ' cloud_runner_logger_1.default.log(`LFS Caching`);
echo 'Large File Caching' cloud_runner_logger_1.default.log(`Checking largest LFS file exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)`);
echo "Checking large file cache exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)" process.chdir(lfsCacheFolder);
cd ${lfsCacheFolder} let latestLFSCacheFile;
if [ -f "${LFS_ASSETS_HASH}.zip" ]; then if (fs_1.default.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
echo "Match found: using large file hash match ${LFS_ASSETS_HASH}.zip" cloud_runner_logger_1.default.log(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
latestLFSCacheFile="${LFS_ASSETS_HASH}" latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
else }
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1) else {
echo "Match not found: using latest large file cache $latestLFSCacheFile" latestLFSCacheFile = yield run_cli_1.RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
fi }
if [ ! -f "$latestLFSCacheFile" ]; then if (fs_1.default.existsSync(latestLFSCacheFile)) {
echo "LFS cache exists from build $latestLFSCacheFile from $branch" cloud_runner_logger_1.default.log(`LFS cache exists`);
rm -r "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}" fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.lfsDirectory, { recursive: true });
unzip -q "${lfsCacheFolder}/$latestLFSCacheFile" -d "$repoPathFull/.git" cloud_runner_logger_1.default.log(`LFS cache exists from build $latestLFSCacheFile from $branch`);
echo "git LFS folder, (should not contain $latestLFSCacheFile)" yield run_cli_1.RunCli.RunCli(`
ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/" unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${cloud_runner_state_1.CloudRunnerState.repoPathFull}/.git"
fi ls -lh "${cloud_runner_state_1.CloudRunnerState.lfsDirectory}"
`); `);
cloud_runner_logger_1.default.log(`git LFS folder, (should not contain $latestLFSCacheFile)`);
}
yield run_cli_1.RunCli.RunCli(` yield run_cli_1.RunCli.RunCli(`
echo ' ' echo ' '
echo "LFS cache for $branch" echo "LFS cache for $branch"

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -64,26 +64,27 @@ export class DownloadRepository {
tree "${CloudRunnerState.libraryFolderFull}" tree "${CloudRunnerState.libraryFolderFull}"
`); `);
} }
await RunCli.RunCli(` CloudRunnerLogger.log(` `);
echo ' ' CloudRunnerLogger.log(`LFS Caching`);
echo 'Large File Caching' CloudRunnerLogger.log(`Checking largest LFS file exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)`);
echo "Checking large file cache exists (${lfsCacheFolder}/${LFS_ASSETS_HASH}.zip)" process.chdir(lfsCacheFolder);
cd ${lfsCacheFolder} let latestLFSCacheFile;
if [ -f "${LFS_ASSETS_HASH}.zip" ]; then if (fs.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
echo "Match found: using large file hash match ${LFS_ASSETS_HASH}.zip" CloudRunnerLogger.log(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
latestLFSCacheFile="${LFS_ASSETS_HASH}" latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
else } else {
latestLFSCacheFile=$(ls -t "${lfsCacheFolder}" | grep .zip$ | head -1) latestLFSCacheFile = await RunCli.RunCli(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
echo "Match not found: using latest large file cache $latestLFSCacheFile" }
fi if (fs.existsSync(latestLFSCacheFile)) {
if [ ! -f "$latestLFSCacheFile" ]; then CloudRunnerLogger.log(`LFS cache exists`);
echo "LFS cache exists from build $latestLFSCacheFile from $branch" fs.rmdirSync(CloudRunnerState.lfsDirectory, { recursive: true });
rm -r "${CloudRunnerState.lfsDirectory}" CloudRunnerLogger.log(`LFS cache exists from build $latestLFSCacheFile from $branch`);
unzip -q "${lfsCacheFolder}/$latestLFSCacheFile" -d "$repoPathFull/.git" await RunCli.RunCli(`
echo "git LFS folder, (should not contain $latestLFSCacheFile)" unzip -q "${lfsCacheFolder}/${latestLFSCacheFile}" -d "${CloudRunnerState.repoPathFull}/.git"
ls -lh "${CloudRunnerState.lfsDirectory}/" ls -lh "${CloudRunnerState.lfsDirectory}"
fi
`); `);
CloudRunnerLogger.log(`git LFS folder, (should not contain $latestLFSCacheFile)`);
}
await RunCli.RunCli(` await RunCli.RunCli(`
echo ' ' echo ' '
echo "LFS cache for $branch" echo "LFS cache for $branch"