pull/310/head
Frostebite 2021-12-26 00:47:33 +00:00
parent 9bcd11c51c
commit 07ed0dc3b4
3 changed files with 78 additions and 57 deletions

64
dist/index.js vendored
View File

@ -540,21 +540,26 @@ const remote_client_system_1 = __webpack_require__(91269);
class SetupRemoteRepository {
static run() {
return __awaiter(this, void 0, void 0, function* () {
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.buildPathFull);
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.printCacheState(lfsCacheFolder, libraryCacheFolder);
yield SetupRemoteRepository.pullLatestLFS();
yield SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
SetupRemoteRepository.handleCachePurging();
try {
fs_1.default.mkdirSync(cloud_runner_state_1.CloudRunnerState.buildPathFull);
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.printCacheState(lfsCacheFolder, libraryCacheFolder);
yield SetupRemoteRepository.pullLatestLFS();
yield SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
SetupRemoteRepository.handleCachePurging();
}
catch (error) {
throw error;
}
});
}
static printLFSHashState() {
@ -666,18 +671,23 @@ class SetupRemoteRepository {
}
static cloneRepoWithoutLFSFiles() {
return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.logRemoteCli(`Initializing source repository for cloning with caching of LFS files`);
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
yield remote_client_system_1.RemoteClientSystem.Run(`git config --global advice.detachedHead false`);
cloud_runner_logger_1.default.logRemoteCli(`Cloning the repository being built:`);
yield remote_client_system_1.RemoteClientSystem.Run(`git lfs install --skip-smudge`);
cloud_runner_logger_1.default.logRemoteCli(cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl);
yield remote_client_system_1.RemoteClientSystem.Run(`git clone --depth 1 ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
yield remote_client_system_1.RemoteClientSystem.Run(`ls -lh`);
yield remote_client_system_1.RemoteClientSystem.Run(`tree`);
yield remote_client_system_1.RemoteClientSystem.Run(`${cloud_runner_state_1.CloudRunnerState.buildParams.gitSha}`);
yield remote_client_system_1.RemoteClientSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.gitSha}`);
cloud_runner_logger_1.default.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
try {
cloud_runner_logger_1.default.logRemoteCli(`Initializing source repository for cloning with caching of LFS files`);
process.chdir(cloud_runner_state_1.CloudRunnerState.repoPathFull);
yield remote_client_system_1.RemoteClientSystem.Run(`git config --global advice.detachedHead false`);
cloud_runner_logger_1.default.logRemoteCli(`Cloning the repository being built:`);
yield remote_client_system_1.RemoteClientSystem.Run(`git lfs install --skip-smudge`);
cloud_runner_logger_1.default.logRemoteCli(cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl);
yield remote_client_system_1.RemoteClientSystem.Run(`git clone --depth 1 ${cloud_runner_state_1.CloudRunnerState.targetBuildRepoUrl} ${cloud_runner_state_1.CloudRunnerState.repoPathFull}`);
yield remote_client_system_1.RemoteClientSystem.Run(`ls -lh`);
yield remote_client_system_1.RemoteClientSystem.Run(`tree`);
yield remote_client_system_1.RemoteClientSystem.Run(`${cloud_runner_state_1.CloudRunnerState.buildParams.gitSha}`);
yield remote_client_system_1.RemoteClientSystem.Run(`git checkout ${cloud_runner_state_1.CloudRunnerState.buildParams.gitSha}`);
cloud_runner_logger_1.default.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
}
catch (error) {
throw error;
}
});
}
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -6,23 +6,30 @@ import { RemoteClientSystem } from './remote-client-system';
export class SetupRemoteRepository {
public static async run() {
fs.mkdirSync(CloudRunnerState.buildPathFull);
fs.mkdirSync(CloudRunnerState.repoPathFull);
await SetupRemoteRepository.cloneRepoWithoutLFSFiles();
try {
fs.mkdirSync(CloudRunnerState.buildPathFull);
fs.mkdirSync(CloudRunnerState.repoPathFull);
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.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.printCacheState(lfsCacheFolder, libraryCacheFolder);
await SetupRemoteRepository.pullLatestLFS();
await SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
SetupRemoteRepository.handleCachePurging();
await SetupRemoteRepository.printCacheState(lfsCacheFolder, libraryCacheFolder);
await SetupRemoteRepository.pullLatestLFS();
await SetupRemoteRepository.cacheLatestLFSFiles(LFS_ASSETS_HASH, lfsCacheFolder);
SetupRemoteRepository.handleCachePurging();
} catch (error) {
throw error;
}
}
private static async printLFSHashState() {
@ -134,19 +141,23 @@ export class SetupRemoteRepository {
}
private static async cloneRepoWithoutLFSFiles() {
CloudRunnerLogger.logRemoteCli(`Initializing source repository for cloning with caching of LFS files`);
process.chdir(CloudRunnerState.repoPathFull);
await RemoteClientSystem.Run(`git config --global advice.detachedHead false`);
CloudRunnerLogger.logRemoteCli(`Cloning the repository being built:`);
await RemoteClientSystem.Run(`git lfs install --skip-smudge`);
CloudRunnerLogger.logRemoteCli(CloudRunnerState.targetBuildRepoUrl);
await RemoteClientSystem.Run(
`git clone --depth 1 ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}`,
);
await RemoteClientSystem.Run(`ls -lh`);
await RemoteClientSystem.Run(`tree`);
await RemoteClientSystem.Run(`${CloudRunnerState.buildParams.gitSha}`);
await RemoteClientSystem.Run(`git checkout ${CloudRunnerState.buildParams.gitSha}`);
CloudRunnerLogger.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
try {
CloudRunnerLogger.logRemoteCli(`Initializing source repository for cloning with caching of LFS files`);
process.chdir(CloudRunnerState.repoPathFull);
await RemoteClientSystem.Run(`git config --global advice.detachedHead false`);
CloudRunnerLogger.logRemoteCli(`Cloning the repository being built:`);
await RemoteClientSystem.Run(`git lfs install --skip-smudge`);
CloudRunnerLogger.logRemoteCli(CloudRunnerState.targetBuildRepoUrl);
await RemoteClientSystem.Run(
`git clone --depth 1 ${CloudRunnerState.targetBuildRepoUrl} ${CloudRunnerState.repoPathFull}`,
);
await RemoteClientSystem.Run(`ls -lh`);
await RemoteClientSystem.Run(`tree`);
await RemoteClientSystem.Run(`${CloudRunnerState.buildParams.gitSha}`);
await RemoteClientSystem.Run(`git checkout ${CloudRunnerState.buildParams.gitSha}`);
CloudRunnerLogger.logRemoteCli(`Checked out ${process.env.GITHUB_SHA}`);
} catch (error) {
throw error;
}
}
}