diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5808cda95284..1a93df4117b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1672,6 +1672,7 @@ jobs: git init "$GITHUB_WORKSPACE" git -C "$GITHUB_WORKSPACE" config gc.auto 0 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git" + fetch_timeout_seconds=90 fetch_checkout_ref() { git -C "$GITHUB_WORKSPACE" \ -c protocol.version=2 \ @@ -1680,7 +1681,7 @@ jobs: local fetch_pid="$!" local elapsed=0 while kill -0 "$fetch_pid" 2>/dev/null; do - if [ "$elapsed" -ge 30 ]; then + if [ "$elapsed" -ge "$fetch_timeout_seconds" ]; then kill -TERM "$fetch_pid" 2>/dev/null || true sleep 10 kill -KILL "$fetch_pid" 2>/dev/null || true @@ -1792,6 +1793,7 @@ jobs: git init "$GITHUB_WORKSPACE" git -C "$GITHUB_WORKSPACE" config gc.auto 0 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git" + fetch_timeout_seconds=90 fetch_checkout_ref() { git -C "$GITHUB_WORKSPACE" \ -c protocol.version=2 \ @@ -1800,7 +1802,7 @@ jobs: local fetch_pid="$!" local elapsed=0 while kill -0 "$fetch_pid" 2>/dev/null; do - if [ "$elapsed" -ge 30 ]; then + if [ "$elapsed" -ge "$fetch_timeout_seconds" ]; then kill -TERM "$fetch_pid" 2>/dev/null || true sleep 10 kill -KILL "$fetch_pid" 2>/dev/null || true @@ -1858,6 +1860,7 @@ jobs: git init "$GITHUB_WORKSPACE" git -C "$GITHUB_WORKSPACE" config gc.auto 0 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git" + fetch_timeout_seconds=90 fetch_checkout_ref() { git -C "$GITHUB_WORKSPACE" \ -c protocol.version=2 \ @@ -1866,7 +1869,7 @@ jobs: local fetch_pid="$!" local elapsed=0 while kill -0 "$fetch_pid" 2>/dev/null; do - if [ "$elapsed" -ge 30 ]; then + if [ "$elapsed" -ge "$fetch_timeout_seconds" ]; then kill -TERM "$fetch_pid" 2>/dev/null || true sleep 10 kill -KILL "$fetch_pid" 2>/dev/null || true diff --git a/test/scripts/ci-workflow-guards.test.ts b/test/scripts/ci-workflow-guards.test.ts index 540044988060..af7e7e4fd2f3 100644 --- a/test/scripts/ci-workflow-guards.test.ts +++ b/test/scripts/ci-workflow-guards.test.ts @@ -74,10 +74,14 @@ describe("ci workflow guards", () => { const checkoutStep = workflow.jobs[jobName].steps.find((step) => step.name === "Checkout"); expect(checkoutStep.run, jobName).toContain("fetch_checkout_ref()"); + expect(checkoutStep.run, jobName).toContain("fetch_timeout_seconds=90"); expect(checkoutStep.run, jobName).toContain("-c protocol.version=2"); expect(checkoutStep.run, jobName).toContain( "fetch --no-tags --prune --no-recurse-submodules --depth=1 origin", ); + expect(checkoutStep.run, jobName).toContain( + 'if [ "$elapsed" -ge "$fetch_timeout_seconds" ]; then', + ); expect(checkoutStep.run, jobName).toContain('kill -TERM "$fetch_pid"'); expect(checkoutStep.run, jobName).toContain('kill -KILL "$fetch_pid"'); expect(checkoutStep.run, jobName).not.toContain(