From 311f2b24331ec1d8ef0244807379f38b69b982ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shixiang=20Wang=20=28=E7=8E=8B=E8=AF=97=E7=BF=94=29?= Date: Sun, 11 Oct 2026 18:37:47 +0800 Subject: [PATCH] ci: shallow checkout with on-demand base fetch in deploy workflow B5 of issue #306: change detection only needs the base commit, so fetch-depth: 0 (full ~5 GB history clone) is unnecessary in quarto-publish.yml. - fetch-depth: 1 in the build-deploy checkout - Detect changed QMD files fetches the base SHA on demand with `git fetch --no-tags --depth=1 origin "$BASE_SHA"` before diffing; on fetch failure it falls back to a full build (need_julia=true, need_python=true, has_changes=false), matching the existing no-base-SHA path - so a missing base commit degrades to today's behaviour instead of failing. Verified safe: - date-modified: last-modified does NOT depend on git history: a local render of a file with mtime 2020-01-01 (git log saying 2026) renders "January 1, 2020" - Quarto uses the file mtime, which actions/checkout preserves on shallow clones. So displayed dates are unaffected. - git diff --name-only $BASE_SHA HEAD works after the on-demand fetch (tested against a real shallow clone in /tmp). - Commit-and-push from shallow checkouts (the "Commit updated dependency files" step) works: tested commit+push from a depth-1 clone. - ci-benchmark.yml keeps fetch-depth: 0 (cold-cache benchmark renders legitimately need full history); quarto-publish-update-cache.yml also keeps it - it pushes dependency-update commits to main and those are safest from a full clone. Co-Authored-By: Claude Code --- .github/workflows/quarto-publish.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/quarto-publish.yml b/.github/workflows/quarto-publish.yml index 59e2cd5a3..859fed68e 100644 --- a/.github/workflows/quarto-publish.yml +++ b/.github/workflows/quarto-publish.yml @@ -79,7 +79,10 @@ jobs: - name: Checkout repo uses: actions/checkout@v7 with: - fetch-depth: 0 + # Shallow checkout (issue #306, B5): the change-detection step + # below needs only the base commit, which it fetches on demand. + # Full history costs ~1 min of checkout against a ~5 GB .git. + fetch-depth: 1 # ── Detect changed files ───────────────────────────────── # Determines which QMDs changed so we can: @@ -106,6 +109,18 @@ jobs: exit 0 fi + # Shallow checkout (issue #306, B5): fetch just the base commit so + # the diff below has both endpoints. Fails soft – on error (e.g. + # the base commit was force-pushed away) fall back to a full build. + if ! git fetch --no-tags --depth=1 origin "$BASE_SHA"; then + echo "⚠️ Could not fetch base $BASE_SHA – treating as full build" + echo "changed_qmds=" >> "$GITHUB_OUTPUT" + echo "has_changes=false" >> "$GITHUB_OUTPUT" + echo "need_julia=true" >> "$GITHUB_OUTPUT" + echo "need_python=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + CHANGED_QMDS=$(git diff --name-only --diff-filter=ACMR "$BASE_SHA" HEAD -- '*.qmd' 2>/dev/null | tr '\n' ' ' || echo "") echo "changed_qmds=$CHANGED_QMDS" >> "$GITHUB_OUTPUT"