From 418456f871b3cf8c5e0b6a752978743a92681e0c Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 16 Nov 2023 11:41:44 -0800 Subject: [PATCH 1/3] Attempt repack once before giving up --- .github/libs/GitUtils.js | 42 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 7bc600470dd1..92a1f58fff8d 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -9,20 +9,36 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = require('../libs/versionUp */ function fetchTag(tag) { const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH); - try { - let command = `git fetch origin tag ${tag} --no-tags`; - - // Exclude commits reachable from the previous patch version (i.e: previous checklist), - // so that we don't have to fetch the full history - // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case - if (previousPatchVersion !== tag) { - command += ` --shallow-exclude=${previousPatchVersion}`; - } + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + if (needsRepack) { + execSync('git repack -d'); + } - console.log(`Running command: ${command}`); - execSync(command); - } catch (e) { - console.error(e); + let command = `git fetch origin tag ${tag} --no-tags`; + + // Exclude commits reachable from the previous patch version (i.e: previous checklist), + // so that we don't have to fetch the full history + // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case + if (previousPatchVersion !== tag) { + command += ` --shallow-exclude=${previousPatchVersion}`; + } + + console.log(`Running command: ${command}`); + execSync(command); + shouldRetry = false; + } catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } } } From 377abd1e09a9d4eeabdf6ebd7da0a09958396cec Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 16 Nov 2023 11:58:24 -0800 Subject: [PATCH 2/3] Rebuild gh actions --- .../createOrUpdateStagingDeploy/index.js | 40 +++++++++++++------ .../getDeployPullRequestList/index.js | 40 +++++++++++++------ 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index abf0712103a5..e6ee577cf832 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -194,20 +194,36 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007); */ function fetchTag(tag) { const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH); - try { - let command = `git fetch origin tag ${tag} --no-tags`; + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + if (needsRepack) { + execSync('git repack -d'); + } - // Exclude commits reachable from the previous patch version (i.e: previous checklist), - // so that we don't have to fetch the full history - // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case - if (previousPatchVersion !== tag) { - command += ` --shallow-exclude=${previousPatchVersion}`; - } + let command = `git fetch origin tag ${tag} --no-tags`; - console.log(`Running command: ${command}`); - execSync(command); - } catch (e) { - console.error(e); + // Exclude commits reachable from the previous patch version (i.e: previous checklist), + // so that we don't have to fetch the full history + // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case + if (previousPatchVersion !== tag) { + command += ` --shallow-exclude=${previousPatchVersion}`; + } + + console.log(`Running command: ${command}`); + execSync(command); + shouldRetry = false; + } catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } } } diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index dbe109d99e32..17b0a9c29979 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -136,20 +136,36 @@ const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007); */ function fetchTag(tag) { const previousPatchVersion = getPreviousVersion(tag, SEMANTIC_VERSION_LEVELS.PATCH); - try { - let command = `git fetch origin tag ${tag} --no-tags`; + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + if (needsRepack) { + execSync('git repack -d'); + } - // Exclude commits reachable from the previous patch version (i.e: previous checklist), - // so that we don't have to fetch the full history - // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case - if (previousPatchVersion !== tag) { - command += ` --shallow-exclude=${previousPatchVersion}`; - } + let command = `git fetch origin tag ${tag} --no-tags`; - console.log(`Running command: ${command}`); - execSync(command); - } catch (e) { - console.error(e); + // Exclude commits reachable from the previous patch version (i.e: previous checklist), + // so that we don't have to fetch the full history + // Note that this condition would only ever _not_ be true in the 1.0.0-0 edge case + if (previousPatchVersion !== tag) { + command += ` --shallow-exclude=${previousPatchVersion}`; + } + + console.log(`Running command: ${command}`); + execSync(command); + shouldRetry = false; + } catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } } } From b62cbdd572a9d2aab8a937cab19fea86c584cca2 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 16 Nov 2023 12:05:00 -0800 Subject: [PATCH 3/3] Add cheeky comment --- .github/actions/javascript/createOrUpdateStagingDeploy/index.js | 2 ++ .github/actions/javascript/getDeployPullRequestList/index.js | 2 ++ .github/libs/GitUtils.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index e6ee577cf832..b7ab57e68974 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -199,6 +199,8 @@ function fetchTag(tag) { while (shouldRetry) { try { if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 execSync('git repack -d'); } diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 17b0a9c29979..1217c5e97de4 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -141,6 +141,8 @@ function fetchTag(tag) { while (shouldRetry) { try { if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 execSync('git repack -d'); } diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 92a1f58fff8d..42a7ecff1263 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -14,6 +14,8 @@ function fetchTag(tag) { while (shouldRetry) { try { if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 execSync('git repack -d'); }