Skip to content

CI: Optimize fetch-depth: 0 usage across workflows #2091

@leofang

Description

@leofang

All 14 fetch-depth: 0 checkouts across our workflows do a full clone with every blob in history. Most don't need that. Optimizing these would speed up CI, especially on Windows where git operations are slower.

Audit results

Can use fetch-depth: 1 (no history needed — 6 occurrences)

File Job / line Why history is unnecessary
ci.yml ci-vars (L38) Just reads ci/versions.yml with yq
build-docs.yml docs build (L50) Checks out a specific tag/ref, reads config
release-upload.yml upload (L46) git archive on a tag already checked out
release.yml check-tag (L65) Only uses GitHub CLI, no git ops
release-cuda-pathfinder.yml upload-assets (L164) git archive on a tag already checked out
coverage.yml coverage-windows (L272) Downloads pre-built wheels, no build step

Can use fetch-depth: 1 + fetch-tags: true (only need tag resolution — 2 occurrences)

File Job / line Why
release.yml determine-run-id (L47) lookup-run-id calls git rev-parse on a tag
release-cuda-pathfinder.yml prepare (L64) Same — lookup-run-id resolves tag to SHA

Should use fetch-depth: 0 + filter: blob:none (need commit graph, not blobs — 7 occurrences)

These need the full commit graph (for setuptools-scm / git describe, git merge-base, or git worktree), but don't need historical blobs. A treeless clone (filter: blob:none) fetches the commit graph without blob data, which is significantly faster.

Verified locally that git describe produces identical output with a treeless clone.

File Job / line Why it needs the commit graph
build-wheel.yml build (L45) setuptools-scm (git describe)
ci.yml detect-changes (L109) git merge-base + git diff --name-only
cleanup-pr-previews.yml cleanup (L34) git worktree on gh-pages
coverage.yml coverage-linux (L69) setuptools-scm
coverage.yml build-wheel-windows (L201) setuptools-scm
test-sdist-linux.yml test-sdist (L30) python -m build → setuptools-scm
test-sdist-windows.yml test-sdist (L36) same

Summary

Out of 14 occurrences, only 7 actually need the commit graph. The other 7 can be made cheaper — 6 with a plain shallow clone and 2 with shallow + tags. The remaining 7 benefit from filter: blob:none to skip historical blob downloads.

-- Leo's bot

Metadata

Metadata

Assignees

Labels

CI/CDCI/CD infrastructure

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions