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

38
dist/index.js vendored
View File

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