Skip main clone if game repo exists

pull/461/head
Frostebite 2022-10-06 02:20:19 +01:00
parent fc59a6f4b9
commit 601b47bdf3
5 changed files with 20 additions and 9 deletions

12
dist/index.js vendored
View File

@ -4182,6 +4182,10 @@ class RemoteClient {
} }
static cloneRepoWithoutLFSFiles() { static cloneRepoWithoutLFSFiles() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (fs_1.default.existsSync(path_1.default.basename(cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute))) {
remote_client_logger_1.RemoteClientLogger.log(`${cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute} repo exists - skipping clone - retained workspace mode ${cloud_runner_1.default.buildParameters.retainWorkspace}`);
return;
}
try { try {
process.chdir(`${cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute}`); process.chdir(`${cloud_runner_folders_1.CloudRunnerFolders.repoPathAbsolute}`);
remote_client_logger_1.RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`); remote_client_logger_1.RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
@ -4224,7 +4228,7 @@ class RemoteClient {
}); });
} }
static handleRetainedWorkspace() { static handleRetainedWorkspace() {
if (process.env.LOCKED_WORKSPACE === undefined) { if (!cloud_runner_1.default.buildParameters.retainWorkspace) {
return; return;
} }
remote_client_logger_1.RemoteClientLogger.log(`Retained Workspace: ${process.env.LOCKED_WORKSPACE}`); remote_client_logger_1.RemoteClientLogger.log(`Retained Workspace: ${process.env.LOCKED_WORKSPACE}`);
@ -4356,9 +4360,9 @@ class CloudRunnerFolders {
} }
// Only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute / // Only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute /
static get uniqueCloudRunnerJobFolderAbsolute() { static get uniqueCloudRunnerJobFolderAbsolute() {
return process.env.LOCKED_WORKSPACE === undefined return !cloud_runner_1.default.buildParameters.retainWorkspace
? path_1.default.join(`/`, CloudRunnerFolders.buildVolumeFolder, cloud_runner_1.default.buildParameters.buildGuid) ? path_1.default.join(`/`, CloudRunnerFolders.buildVolumeFolder, cloud_runner_1.default.buildParameters.buildGuid)
: path_1.default.join(`/`, CloudRunnerFolders.buildVolumeFolder, process.env.LOCKED_WORKSPACE); : path_1.default.join(`/`, CloudRunnerFolders.buildVolumeFolder, process.env.LOCKED_WORKSPACE || ``);
} }
static get cacheFolderFull() { static get cacheFolderFull() {
return path_1.default.join('/', CloudRunnerFolders.buildVolumeFolder, CloudRunnerFolders.cacheFolder, cloud_runner_1.default.buildParameters.cacheKey); return path_1.default.join('/', CloudRunnerFolders.buildVolumeFolder, CloudRunnerFolders.cacheFolder, cloud_runner_1.default.buildParameters.cacheKey);
@ -5131,7 +5135,7 @@ class BuildAutomationWorkflow {
const commands = `mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.builderPathAbsolute)} && git clone -q -b ${cloud_runner_1.default.buildParameters.cloudRunnerBranch} ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.unityBuilderRepoUrl)} "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.builderPathAbsolute)}" && chmod +x ${builderPath}`; const commands = `mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.builderPathAbsolute)} && git clone -q -b ${cloud_runner_1.default.buildParameters.cloudRunnerBranch} ${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.unityBuilderRepoUrl)} "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.builderPathAbsolute)}" && chmod +x ${builderPath}`;
return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1 return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
echo "game ci cloud runner clone" echo "game ci cloud runner clone"
if [ -e "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}" ]; then echo "Retained Workspace Already Exists!" ; else ${commands}; fi if [ -e "${cloud_runner_folders_1.CloudRunnerFolders.ToLinuxFolder(cloud_runner_folders_1.CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute)}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
echo "game ci cloud runner bootstrap" echo "game ci cloud runner bootstrap"
node ${builderPath} -m remote-cli`; node ${builderPath} -m remote-cli`;
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -61,6 +61,13 @@ export class RemoteClient {
} }
private static async cloneRepoWithoutLFSFiles() { private static async cloneRepoWithoutLFSFiles() {
if (fs.existsSync(path.basename(CloudRunnerFolders.repoPathAbsolute))) {
RemoteClientLogger.log(
`${CloudRunnerFolders.repoPathAbsolute} repo exists - skipping clone - retained workspace mode ${CloudRunner.buildParameters.retainWorkspace}`,
);
return;
}
try { try {
process.chdir(`${CloudRunnerFolders.repoPathAbsolute}`); process.chdir(`${CloudRunnerFolders.repoPathAbsolute}`);
RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`); RemoteClientLogger.log(`Initializing source repository for cloning with caching of LFS files`);
@ -108,7 +115,7 @@ export class RemoteClient {
await RemoteClient.bootstrapRepository(); await RemoteClient.bootstrapRepository();
} }
static handleRetainedWorkspace() { static handleRetainedWorkspace() {
if (process.env.LOCKED_WORKSPACE === undefined) { if (!CloudRunner.buildParameters.retainWorkspace) {
return; return;
} }
RemoteClientLogger.log(`Retained Workspace: ${process.env.LOCKED_WORKSPACE}`); RemoteClientLogger.log(`Retained Workspace: ${process.env.LOCKED_WORKSPACE}`);

View File

@ -11,9 +11,9 @@ export class CloudRunnerFolders {
// Only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute / // Only the following paths that do not start a path.join with another "Full" suffixed property need to start with an absolute /
public static get uniqueCloudRunnerJobFolderAbsolute(): string { public static get uniqueCloudRunnerJobFolderAbsolute(): string {
return process.env.LOCKED_WORKSPACE === undefined return !CloudRunner.buildParameters.retainWorkspace
? path.join(`/`, CloudRunnerFolders.buildVolumeFolder, CloudRunner.buildParameters.buildGuid) ? path.join(`/`, CloudRunnerFolders.buildVolumeFolder, CloudRunner.buildParameters.buildGuid)
: path.join(`/`, CloudRunnerFolders.buildVolumeFolder, process.env.LOCKED_WORKSPACE); : path.join(`/`, CloudRunnerFolders.buildVolumeFolder, process.env.LOCKED_WORKSPACE || ``);
} }
public static get cacheFolderFull(): string { public static get cacheFolderFull(): string {

View File

@ -132,7 +132,7 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
echo "game ci cloud runner clone" echo "game ci cloud runner clone"
if [ -e "${CloudRunnerFolders.ToLinuxFolder( if [ -e "${CloudRunnerFolders.ToLinuxFolder(
CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute, CloudRunnerFolders.uniqueCloudRunnerJobFolderAbsolute,
)}" ]; then echo "Retained Workspace Already Exists!" ; else ${commands}; fi )}" ]; then echo "Retained Workspace Already Exists!"; else ${commands}; fi
echo "game ci cloud runner bootstrap" echo "game ci cloud runner bootstrap"
node ${builderPath} -m remote-cli`; node ${builderPath} -m remote-cli`;
} }