test
parent
d493981964
commit
e6327a37fc
|
|
@ -554,16 +554,15 @@ class SetupRemoteRepository {
|
|||
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.repoPathFull);
|
||||
yield SetupRemoteRepository.cloneRepoWithoutLFSFiles();
|
||||
yield SetupRemoteRepository.createLFSHashFiles();
|
||||
const LFS_ASSETS_HASH = fs_1.default.readFileSync(`${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.lfs-assets-guid`)}`, 'utf8');
|
||||
yield SetupRemoteRepository.printLFSHashState();
|
||||
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`);
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`tree ${cloud_runner_state_1.CloudRunnerState.builderPathFull}`);
|
||||
yield SetupRemoteRepository.libraryCaching(lfsCacheFolder, libraryCacheFolder);
|
||||
yield SetupRemoteRepository.lfsCaching(lfsCacheFolder, LFS_ASSETS_HASH);
|
||||
yield SetupRemoteRepository.lfsCaching(lfsCacheFolder);
|
||||
yield SetupRemoteRepository.printCacheState(lfsCacheFolder, libraryCacheFolder);
|
||||
yield SetupRemoteRepository.pullLatestLFS();
|
||||
yield SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
|
||||
yield SetupRemoteRepository.cacheLatestLFSFiles(lfsCacheFolder);
|
||||
SetupRemoteRepository.handleCachePurging();
|
||||
}
|
||||
catch (error) {
|
||||
|
|
@ -608,14 +607,14 @@ class SetupRemoteRepository {
|
|||
fs_1.default.rmdirSync(cloud_runner_state_1.CloudRunnerState.cacheFolder, { recursive: true });
|
||||
}
|
||||
}
|
||||
static cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder) {
|
||||
static cacheLatestLFSFiles(lfsCacheFolder) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
process.chdir(`${cloud_runner_state_1.CloudRunnerState.lfsDirectory}/..`);
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`zip -r "${LFS_ASSETS_HASH}.zip" "lfs"`);
|
||||
cloud_runner_logger_1.default.logRemoteCli(fs_1.default.existsSync(`${LFS_ASSETS_HASH}.zip`).toString());
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`zip -r "${SetupRemoteRepository.LFS_ASSETS_HASH}.zip" "lfs"`);
|
||||
cloud_runner_logger_1.default.logRemoteCli(fs_1.default.existsSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`).toString());
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`tree`);
|
||||
fs_1.default.copyFileSync(`${LFS_ASSETS_HASH}.zip`, path_1.default.join(lfsCacheFolder, '/'));
|
||||
cloud_runner_logger_1.default.logRemoteCli(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||
fs_1.default.copyFileSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`, path_1.default.join(lfsCacheFolder, '/'));
|
||||
cloud_runner_logger_1.default.logRemoteCli(`copied ${SetupRemoteRepository.LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||
});
|
||||
}
|
||||
static pullLatestLFS() {
|
||||
|
|
@ -625,15 +624,15 @@ class SetupRemoteRepository {
|
|||
cloud_runner_logger_1.default.logRemoteCli(`pulled latest LFS files`);
|
||||
});
|
||||
}
|
||||
static lfsCaching(lfsCacheFolder, LFS_ASSETS_HASH) {
|
||||
static lfsCaching(lfsCacheFolder) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
cloud_runner_logger_1.default.logRemoteCli(` `);
|
||||
cloud_runner_logger_1.default.logRemoteCli(`LFS Caching`);
|
||||
process.chdir(lfsCacheFolder);
|
||||
let latestLFSCacheFile;
|
||||
if (fs_1.default.existsSync(`${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`;
|
||||
if (fs_1.default.existsSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`)) {
|
||||
cloud_runner_logger_1.default.logRemoteCli(`Match found: using large file hash match ${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`);
|
||||
latestLFSCacheFile = `${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`;
|
||||
}
|
||||
else {
|
||||
latestLFSCacheFile = yield remote_client_system_1.RemoteClientSystem.Run(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
||||
|
|
@ -678,6 +677,8 @@ class SetupRemoteRepository {
|
|||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid`);
|
||||
yield remote_client_system_1.RemoteClientSystem.Run(`md5sum .lfs-assets-guid > .lfs-assets-guid-sum`);
|
||||
SetupRemoteRepository.LFS_ASSETS_HASH = fs_1.default.readFileSync(`${path_1.default.join(cloud_runner_state_1.CloudRunnerState.repoPathFull, `.lfs-assets-guid`)}`, 'utf8');
|
||||
cloud_runner_logger_1.default.logRemoteCli(SetupRemoteRepository.LFS_ASSETS_HASH);
|
||||
});
|
||||
}
|
||||
static cloneRepoWithoutLFSFiles() {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -5,6 +5,7 @@ import { CloudRunnerState } from '../../cloud-runner/state/cloud-runner-state';
|
|||
import { RemoteClientSystem } from './remote-client-system';
|
||||
|
||||
export class SetupRemoteRepository {
|
||||
static LFS_ASSETS_HASH;
|
||||
public static async run() {
|
||||
try {
|
||||
fs.mkdirSync(CloudRunnerState.buildPathFull);
|
||||
|
|
@ -12,20 +13,16 @@ export class SetupRemoteRepository {
|
|||
await SetupRemoteRepository.cloneRepoWithoutLFSFiles();
|
||||
|
||||
await SetupRemoteRepository.createLFSHashFiles();
|
||||
const LFS_ASSETS_HASH = fs.readFileSync(
|
||||
`${path.join(CloudRunnerState.repoPathFull, `.lfs-assets-guid`)}`,
|
||||
'utf8',
|
||||
);
|
||||
await SetupRemoteRepository.printLFSHashState();
|
||||
const lfsCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lfs`);
|
||||
const libraryCacheFolder = path.join(CloudRunnerState.cacheFolderFull, `lib`);
|
||||
await RemoteClientSystem.Run(`tree ${CloudRunnerState.builderPathFull}`);
|
||||
await SetupRemoteRepository.libraryCaching(lfsCacheFolder, libraryCacheFolder);
|
||||
await SetupRemoteRepository.lfsCaching(lfsCacheFolder, LFS_ASSETS_HASH);
|
||||
await SetupRemoteRepository.lfsCaching(lfsCacheFolder);
|
||||
|
||||
await SetupRemoteRepository.printCacheState(lfsCacheFolder, libraryCacheFolder);
|
||||
await SetupRemoteRepository.pullLatestLFS();
|
||||
await SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
|
||||
await SetupRemoteRepository.cacheLatestLFSFiles(lfsCacheFolder);
|
||||
SetupRemoteRepository.handleCachePurging();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
|
@ -72,13 +69,13 @@ export class SetupRemoteRepository {
|
|||
}
|
||||
}
|
||||
|
||||
private static async cacheLatestLFSFiles(LFS_ASSETS_HASH: string, lfsCacheFolder: string) {
|
||||
private static async cacheLatestLFSFiles(lfsCacheFolder: string) {
|
||||
process.chdir(`${CloudRunnerState.lfsDirectory}/..`);
|
||||
await RemoteClientSystem.Run(`zip -r "${LFS_ASSETS_HASH}.zip" "lfs"`);
|
||||
CloudRunnerLogger.logRemoteCli(fs.existsSync(`${LFS_ASSETS_HASH}.zip`).toString());
|
||||
await RemoteClientSystem.Run(`zip -r "${SetupRemoteRepository.LFS_ASSETS_HASH}.zip" "lfs"`);
|
||||
CloudRunnerLogger.logRemoteCli(fs.existsSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`).toString());
|
||||
await RemoteClientSystem.Run(`tree`);
|
||||
fs.copyFileSync(`${LFS_ASSETS_HASH}.zip`, path.join(lfsCacheFolder, '/'));
|
||||
CloudRunnerLogger.logRemoteCli(`copied ${LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||
fs.copyFileSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`, path.join(lfsCacheFolder, '/'));
|
||||
CloudRunnerLogger.logRemoteCli(`copied ${SetupRemoteRepository.LFS_ASSETS_HASH} to ${lfsCacheFolder}`);
|
||||
}
|
||||
|
||||
private static async pullLatestLFS() {
|
||||
|
|
@ -87,14 +84,16 @@ export class SetupRemoteRepository {
|
|||
CloudRunnerLogger.logRemoteCli(`pulled latest LFS files`);
|
||||
}
|
||||
|
||||
private static async lfsCaching(lfsCacheFolder: string, LFS_ASSETS_HASH: string) {
|
||||
private static async lfsCaching(lfsCacheFolder: string) {
|
||||
CloudRunnerLogger.logRemoteCli(` `);
|
||||
CloudRunnerLogger.logRemoteCli(`LFS Caching`);
|
||||
process.chdir(lfsCacheFolder);
|
||||
let latestLFSCacheFile;
|
||||
if (fs.existsSync(`${LFS_ASSETS_HASH}.zip`)) {
|
||||
CloudRunnerLogger.logRemoteCli(`Match found: using large file hash match ${LFS_ASSETS_HASH}.zip`);
|
||||
latestLFSCacheFile = `${LFS_ASSETS_HASH}.zip`;
|
||||
if (fs.existsSync(`${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`)) {
|
||||
CloudRunnerLogger.logRemoteCli(
|
||||
`Match found: using large file hash match ${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`,
|
||||
);
|
||||
latestLFSCacheFile = `${SetupRemoteRepository.LFS_ASSETS_HASH}.zip`;
|
||||
} else {
|
||||
latestLFSCacheFile = await RemoteClientSystem.Run(`ls -t "${lfsCacheFolder}" | grep .zip$ | head -1`);
|
||||
}
|
||||
|
|
@ -140,6 +139,11 @@ export class SetupRemoteRepository {
|
|||
private static async createLFSHashFiles() {
|
||||
await RemoteClientSystem.Run(`git lfs ls-files -l | cut -d ' ' -f1 | sort > .lfs-assets-guid`);
|
||||
await RemoteClientSystem.Run(`md5sum .lfs-assets-guid > .lfs-assets-guid-sum`);
|
||||
SetupRemoteRepository.LFS_ASSETS_HASH = fs.readFileSync(
|
||||
`${path.join(CloudRunnerState.repoPathFull, `.lfs-assets-guid`)}`,
|
||||
'utf8',
|
||||
);
|
||||
CloudRunnerLogger.logRemoteCli(SetupRemoteRepository.LFS_ASSETS_HASH);
|
||||
}
|
||||
|
||||
private static async cloneRepoWithoutLFSFiles() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue