Skip to content

Commit a44c4de

Browse files
committed
ci: simplify checkout optimizations with blob filtering
1 parent f1d1ec8 commit a44c4de

9 files changed

Lines changed: 52 additions & 66 deletions

‎.github/workflows/build-wheel.yml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ jobs:
7474
- name: Checkout ${{ github.event.repository.name }}
7575
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
7676
with:
77-
# Full ancestry and tags for setuptools-scm, without unrelated
78-
# branches or historical blobs. See ci/README.md for unlimited depth.
79-
fetch-depth: 2147483647
80-
fetch-tags: true
77+
# Treeless clone: setuptools-scm needs the commit graph (`git describe`)
78+
# but not historical blobs.
79+
fetch-depth: 0
8180
filter: blob:none
8281

8382
- name: Install latest rapidsai/sccache

‎.github/workflows/ci-pixi-lockfile-freshness-check.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ jobs:
6363
- name: Checkout ${{ github.event.repository.name }}
6464
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6565
with:
66-
# Git's unlimited depth keeps this ref's full history without
67-
# fetching every branch (especially gh-pages). See ci/README.md.
68-
fetch-depth: 2147483647
69-
fetch-tags: true
66+
# Keep full ancestry for the PR base worktree, without downloading
67+
# historical file contents (especially gh-pages). See ci/README.md.
68+
fetch-depth: 0
69+
filter: blob:none
7070
persist-credentials: false
7171

7272
- name: Setup pixi

‎.github/workflows/ci-pixi-lockfile-refresh.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
- name: Checkout ${{ github.event.repository.name }}
3939
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4040
with:
41-
# Full history and tags for package metadata, scoped to this ref.
42-
# 2147483647 is Git's unlimited depth; see ci/README.md.
43-
fetch-depth: 2147483647
44-
fetch-tags: true
41+
# Full history and tags for package metadata, without historical
42+
# file contents. See ci/README.md for the checkout policy.
43+
fetch-depth: 0
44+
filter: blob:none
4545
ref: ${{ github.event.repository.default_branch }}
4646

4747
- name: Setup pixi

‎.github/workflows/ci-pixi-source-test.yml‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ jobs:
8080
- name: Checkout ${{ github.event.repository.name }}
8181
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
8282
with:
83-
# This ref's full history + tags so setuptools-scm derives the real (13.x)
83+
# Full history + tags so setuptools-scm derives the real (13.x)
8484
# package version; a shallow checkout yields 0.1.dev1, which trips
8585
# cuda.core's "cuda.bindings 12.x or 13.x must be installed" guard.
86-
# Git's unlimited depth avoids unrelated branches; see ci/README.md.
87-
fetch-depth: 2147483647
88-
fetch-tags: true
86+
fetch-depth: 0
87+
filter: blob:none
8988

9089
- name: Setup pixi
9190
uses: ./.github/actions/setup-pixi
@@ -138,12 +137,11 @@ jobs:
138137
- name: Checkout ${{ github.event.repository.name }}
139138
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
140139
with:
141-
# This ref's full history + tags so setuptools-scm derives the real (13.x)
140+
# Full history + tags so setuptools-scm derives the real (13.x)
142141
# package version; a shallow checkout yields 0.1.dev1, which trips
143142
# cuda.core's "cuda.bindings 12.x or 13.x must be installed" guard.
144-
# Git's unlimited depth avoids unrelated branches; see ci/README.md.
145-
fetch-depth: 2147483647
146-
fetch-tags: true
143+
fetch-depth: 0
144+
filter: blob:none
147145

148146
- name: Setup pixi
149147
uses: ./.github/actions/setup-pixi
@@ -205,12 +203,11 @@ jobs:
205203
- name: Checkout ${{ github.event.repository.name }}
206204
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
207205
with:
208-
# This ref's full history + tags so setuptools-scm derives the real (13.x)
206+
# Full history + tags so setuptools-scm derives the real (13.x)
209207
# package version; a shallow checkout yields 0.1.dev1, which trips
210208
# cuda.core's "cuda.bindings 12.x or 13.x must be installed" guard.
211-
# Git's unlimited depth avoids unrelated branches; see ci/README.md.
212-
fetch-depth: 2147483647
213-
fetch-tags: true
209+
fetch-depth: 0
210+
filter: blob:none
214211

215212
- name: Setup proxy cache
216213
uses: nv-gha-runners/setup-proxy-cache@main

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ jobs:
142142
- name: Checkout repository
143143
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
144144
with:
145-
# Only PR mirrors need ancestry to find a merge base. Git's unlimited
146-
# depth fetches this ref alone; see ci/README.md.
147-
fetch-depth: ${{ startsWith(github.ref_name, 'pull-request/') && 2147483647 || 1 }}
145+
# Only PR mirrors need full ancestry to find their merge base.
146+
fetch-depth: ${{ startsWith(github.ref_name, 'pull-request/') && '0' || '1' }}
148147
filter: blob:none
149148

150149
- name: Resolve PR merge base
@@ -159,10 +158,6 @@ jobs:
159158
exit 1
160159
fi
161160
162-
# The checkout contains only the PR ref. Fetch its base explicitly
163-
# with full ancestry, retaining the blob filter and excluding tags.
164-
git fetch --no-tags --filter=blob:none origin \
165-
"+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
166161
base=$(git merge-base HEAD "origin/${BASE_REF}")
167162
echo "sha=${base}" >> "$GITHUB_OUTPUT"
168163

‎.github/workflows/coverage.yml‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ jobs:
6767
- name: Checkout ${{ github.event.repository.name }}
6868
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
6969
with:
70-
# Full ancestry and tags for setuptools-scm, without unrelated
71-
# branches or historical blobs. See ci/README.md for unlimited depth.
72-
fetch-depth: 2147483647
73-
fetch-tags: true
70+
# Treeless clone: setuptools-scm needs the commit graph (`git describe`)
71+
# but not historical blobs.
72+
fetch-depth: 0
7473
filter: blob:none
7574

7675
- name: Fix workspace ownership
@@ -236,10 +235,9 @@ jobs:
236235
- name: Checkout ${{ github.event.repository.name }}
237236
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
238237
with:
239-
# Full ancestry and tags for setuptools-scm, without unrelated
240-
# branches or historical blobs. See ci/README.md for unlimited depth.
241-
fetch-depth: 2147483647
242-
fetch-tags: true
238+
# Treeless clone: setuptools-scm needs the commit graph (`git describe`)
239+
# but not historical blobs.
240+
fetch-depth: 0
243241
filter: blob:none
244242

245243
- name: Set up Python

‎.github/workflows/test-sdist-linux.yml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ jobs:
4040
- name: Checkout ${{ github.event.repository.name }}
4141
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
4242
with:
43-
# Full ancestry and tags for setuptools-scm, without unrelated
44-
# branches or historical blobs. See ci/README.md for unlimited depth.
45-
fetch-depth: 2147483647
46-
fetch-tags: true
43+
# Treeless clone: setuptools-scm (invoked via `python -m build`) needs
44+
# the commit graph (`git describe`) but not historical blobs.
45+
fetch-depth: 0
4746
filter: blob:none
4847

4948
- name: Set up Python

‎.github/workflows/test-sdist-windows.yml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ jobs:
4949
- name: Checkout ${{ github.event.repository.name }}
5050
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5151
with:
52-
# Full ancestry and tags for setuptools-scm, without unrelated
53-
# branches or historical blobs. See ci/README.md for unlimited depth.
54-
fetch-depth: 2147483647
55-
fetch-tags: true
52+
# Treeless clone: setuptools-scm (invoked via `python -m build`) needs
53+
# the commit graph (`git describe`) but not historical blobs.
54+
fetch-depth: 0
5655
filter: blob:none
5756

5857
- name: Set up Python

‎ci/README.md‎

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,24 @@ Use the default shallow checkout for jobs that only read files or test prebuilt
66
wheels. Source builds need complete commit ancestry and release tags so
77
`setuptools-scm` can derive each package's version.
88

9-
For those jobs, use `fetch-depth: 2147483647` with `fetch-tags: true`.
10-
`2147483647` is Git's `INFINITE_DEPTH` value, also used by `git fetch
11-
--unshallow`. It produces a complete, non-shallow history. Unlike
12-
`fetch-depth: 0`, this positive value makes `actions/checkout` fetch only the
13-
requested ref or event SHA plus tags, instead of every branch. In particular,
14-
it avoids the large, unrelated `gh-pages` history discussed in issue #2197.
15-
Keep `filter: blob:none` where historical file contents are unnecessary.
16-
17-
Jobs comparing branches must fetch the comparison ref explicitly. CI change
18-
detection fetches the PR base branch before computing its merge base; non-PR
19-
runs need only a shallow checkout. PR-preview cleanup checks out the script
20-
shallowly and fetches `gh-pages` separately when needed.
21-
22-
Git documents this value in its
23-
[shallow repository reference](https://git-scm.com/docs/shallow).
24-
The pinned checkout action chooses its refspec in
25-
[`git-source-provider.ts`](https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/src/git-source-provider.ts#L173-L202)
26-
and
27-
[`ref-helper.ts`](https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/src/ref-helper.ts#L79-L147).
9+
For those jobs, use `fetch-depth: 0` with `filter: blob:none`. The checkout
10+
action fetches complete ancestry for all branches and tags, while the blob
11+
filter skips historical file contents. This avoids downloading the large
12+
historical `gh-pages` contents discussed in issue #2197. Git retrieves file
13+
contents as needed when checking out the requested commit or creating the
14+
freshness check's base-commit worktree.
15+
16+
CI change detection uses this full-history checkout for PR mirrors, so the
17+
actual PR base branch is available when computing its merge base. Non-PR runs
18+
need only a shallow checkout. PR-preview cleanup checks out its script
19+
shallowly and fetches `gh-pages` separately when needed. Pathfinder release
20+
preparation fetches its exact tag without requesting every other tag.
21+
22+
Git documents blob filtering in its
23+
[clone reference](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---filterltfilter-specgt).
24+
The pinned checkout action's
25+
[`fetch implementation`](https://github.com/actions/checkout/blob/3d3c42e5aac5ba805825da76410c181273ba90b1/src/git-source-provider.ts#L161-L202)
26+
preserves full ancestry and tags at depth zero.
2827

2928
## Repository Customizations
3029

0 commit comments

Comments
 (0)