fix(ci): replace fetch-depth: 0 with targeted shallow fetch in detect-changes

Root cause of mc#1314: detect-changes jobs in CI/E2E workflows were
running `fetch-depth: 0` (full repository history clone) before
computing the git diff. On large repositories this takes 10+ minutes,
causing the detect-changes job itself to timeout and fail.

Fix: use `fetch-depth: 1` (shallow clone of HEAD only) plus explicit
`git fetch --depth=1 origin <BASE> --no-walk` to fetch the BASE commit
without its ancestry. This makes detect-changes complete in seconds
instead of minutes.

Files changed:
- ci.yml: changes job
- e2e-api.yml: detect-changes job
- e2e-staging-canvas.yml: detect-changes job
- runtime-prbuild-compat.yml: detect-changes job

Lint workflows (lint-mask-pr-atomicity, lint-required-context-exists-in-bp,
check-migration-collisions, lint-pre-flip-continue-on-error) retain
fetch-depth: 0 because they use `git show <base>:<path>` which needs
the full blob set from the base commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-devops 2026-05-16 07:47:14 +00:00
parent 8e754e6b28
commit 004599750f
4 changed files with 42 additions and 7 deletions

View File

@ -84,7 +84,11 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Shallow clone: only the PR head tip. BASE commit is fetched below.
# mc#1314 fix: was fetch-depth: 0 (full history clone), which caused
# detect-changes to hang for 10+ minutes on large repos. The diff only
# needs HEAD + BASE, so we fetch those two commits explicitly.
fetch-depth: 1
- id: check
run: |
# For PR events: diff against the base branch (not HEAD~1 of the branch,
@ -107,6 +111,13 @@ jobs:
echo "scripts=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Shallow-fetch the BASE commit explicitly. git fetch --depth=1 with
# --no-walk fetches the commit without its full ancestry (fast), then
# git diff works because both BASE and HEAD are now in the object store.
if ! git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=1 origin "$BASE" --no-walk 2>/dev/null || \
git fetch --depth=50 origin "$BASE" 2>/dev/null || true
fi
# Workflow-only edits are covered by the workflow lint family
# and by this workflow's always-present required jobs. Do not fan
# those edits out into Go/Canvas/Python/shellcheck work; the

View File

@ -117,7 +117,11 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Shallow clone: only the PR head tip. BASE commit is fetched below.
# mc#1314 fix: was fetch-depth: 0 (full history clone), which caused
# detect-changes to hang for 10+ minutes on large repos. The diff only
# needs HEAD + BASE, so we fetch those two commits explicitly.
fetch-depth: 1
- id: decide
# Inline replacement for dorny/paths-filter — same pattern PR#372's
# ci.yml port used. Diffs against the PR base or push BEFORE SHA,
@ -131,8 +135,12 @@ jobs:
echo "api=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Shallow-fetch the BASE commit explicitly. git fetch --depth=1 with
# --no-walk fetches the commit without its full ancestry (fast), then
# git diff works because both BASE and HEAD are now in the object store.
if ! git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=1 origin "$BASE" 2>/dev/null || true
git fetch --depth=1 origin "$BASE" --no-walk 2>/dev/null || \
git fetch --depth=50 origin "$BASE" 2>/dev/null || true
fi
if ! git cat-file -e "$BASE" 2>/dev/null; then
echo "api=true" >> "$GITHUB_OUTPUT"

View File

@ -77,7 +77,11 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Shallow clone: only the PR head tip. BASE commit is fetched below.
# mc#1314 fix: was fetch-depth: 0 (full history clone), which caused
# detect-changes to hang for 10+ minutes on large repos. The diff only
# needs HEAD + BASE, so we fetch those two commits explicitly.
fetch-depth: 1
- id: decide
# Inline replacement for dorny/paths-filter — see e2e-api.yml.
# Cron triggers always run real work (no diff context).
@ -94,8 +98,12 @@ jobs:
echo "canvas=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Shallow-fetch the BASE commit explicitly. git fetch --depth=1 with
# --no-walk fetches the commit without its full ancestry (fast), then
# git diff works because both BASE and HEAD are now in the object store.
if ! git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=1 origin "$BASE" 2>/dev/null || true
git fetch --depth=1 origin "$BASE" --no-walk 2>/dev/null || \
git fetch --depth=50 origin "$BASE" 2>/dev/null || true
fi
if ! git cat-file -e "$BASE" 2>/dev/null; then
echo "canvas=true" >> "$GITHUB_OUTPUT"

View File

@ -59,7 +59,11 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# Shallow clone: only the PR head tip. BASE commit is fetched below.
# mc#1314 fix: was fetch-depth: 0 (full history clone), which caused
# detect-changes to hang for 10+ minutes on large repos. The diff only
# needs HEAD + BASE, so we fetch those two commits explicitly.
fetch-depth: 1
- id: decide
run: |
# Inline replacement for dorny/paths-filter — same pattern
@ -84,8 +88,12 @@ jobs:
echo "wheel=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Shallow-fetch the BASE commit explicitly. git fetch --depth=1 with
# --no-walk fetches the commit without its full ancestry (fast), then
# git diff works because both BASE and HEAD are now in the object store.
if ! timeout 30 git cat-file -e "$BASE" 2>/dev/null; then
git fetch --depth=1 origin "$BASE" 2>/dev/null || true
git fetch --depth=1 origin "$BASE" --no-walk 2>/dev/null || \
git fetch --depth=50 origin "$BASE" 2>/dev/null || true
fi
if ! timeout 30 git cat-file -e "$BASE" 2>/dev/null; then
echo "wheel=true" >> "$GITHUB_OUTPUT"