Skip to content

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

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)

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

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

FileJob / lineWhy
release.ymldetermine-run-id (L47)lookup-run-id calls git rev-parse on a tag
release-cuda-pathfinder.ymlprepare (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.

FileJob / lineWhy it needs the commit graph
build-wheel.ymlbuild (L45)setuptools-scm (git describe)
ci.ymldetect-changes (L109)git merge-base + git diff --name-only
cleanup-pr-previews.ymlcleanup (L34)git worktree on gh-pages
coverage.ymlcoverage-linux (L69)setuptools-scm
coverage.ymlbuild-wheel-windows (L201)setuptools-scm
test-sdist-linux.ymltest-sdist (L30)python -m build → setuptools-scm
test-sdist-windows.ymltest-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 infrastructureenhancementAny code-related improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions