Skip to content

Commit ab8907a

Browse files
committed
CI: pin XDG_CACHE_HOME=/runner/root/.cache on self-hosted runners
The self-hosted Linux runner's work dir lives on /runner, which is a separate filesystem from /root. uv's default cache lives under $HOME/.cache/uv (or $XDG_CACHE_HOME/uv if set) and uv hard-links from the cache into the venv — hard-links can't cross filesystem boundaries, so uv silently falls back to copying every dep, adding tens of seconds to every ``uv sync`` / ``uv venv``. Pin XDG_CACHE_HOME to a path on /runner (same fs as the work dir) so uv keeps its cache there and hard-linking succeeds. Wrapped in ``if: runner.environment == 'self-hosted'`` so GitHub-hosted runs (which don't have /runner and run as unprivileged ``runner`` user) aren't affected. Added to every job that runs uv: precheck, discover-standard-tests, build, discover-live-tests, live-integration, deploy-pages build, release-state.
1 parent 1134af0 commit ab8907a

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/deploy-pages.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v6
2525

26+
- name: Pin XDG_CACHE_HOME for self-hosted
27+
if: runner.environment == 'self-hosted'
28+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
29+
2630
- name: Install uv
2731
uses: astral-sh/setup-uv@v5
2832

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
fetch-depth: 0
2929
ref: ${{ github.ref_name }}
3030

31+
- name: Pin XDG_CACHE_HOME for self-hosted
32+
if: runner.environment == 'self-hosted'
33+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
34+
3135
- uses: actions/setup-python@v6
3236
with:
3337
python-version: "3.12"

.github/workflows/tests.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ permissions:
1212

1313
env:
1414
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
15+
# On self-hosted runners, the runner work dir lives on /runner which
16+
# is a separate filesystem from /root — keep uv's cache on the same
17+
# fs as the work dir so hard-linking into venvs succeeds (uv falls
18+
# back to copying across fs boundaries, which is much slower). The
19+
# "if" guards below no-op this on GitHub-hosted runners where the
20+
# path doesn't exist.
1521

1622
concurrency:
1723
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -26,6 +32,10 @@ jobs:
2632
steps:
2733
- uses: actions/checkout@v6
2834

35+
- name: Pin XDG_CACHE_HOME for self-hosted
36+
if: runner.environment == 'self-hosted'
37+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
38+
2939
- name: Setup Python
3040
uses: actions/setup-python@v6
3141
with:
@@ -64,6 +74,10 @@ jobs:
6474
steps:
6575
- uses: actions/checkout@v6
6676

77+
- name: Pin XDG_CACHE_HOME for self-hosted
78+
if: runner.environment == 'self-hosted'
79+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
80+
6781
- name: Discover standard test files
6882
id: set-matrix
6983
run: |
@@ -111,11 +125,15 @@ jobs:
111125
steps:
112126
- uses: actions/checkout@v6
113127

128+
- name: Pin XDG_CACHE_HOME for self-hosted
129+
if: runner.environment == 'self-hosted'
130+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
131+
114132
- name: Setup Python
115133
uses: actions/setup-python@v6
116134
with:
117135
python-version: ${{ matrix.target.python_version }}
118-
136+
119137
- name: Install uv
120138
uses: astral-sh/setup-uv@v8.0.0
121139
with:
@@ -240,6 +258,10 @@ jobs:
240258
steps:
241259
- uses: actions/checkout@v6
242260

261+
- name: Pin XDG_CACHE_HOME for self-hosted
262+
if: runner.environment == 'self-hosted'
263+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
264+
243265
- name: Discover live integration test files
244266
id: set-matrix
245267
run: |
@@ -290,6 +312,10 @@ jobs:
290312
steps:
291313
- uses: actions/checkout@v6
292314

315+
- name: Pin XDG_CACHE_HOME for self-hosted
316+
if: runner.environment == 'self-hosted'
317+
run: echo "XDG_CACHE_HOME=/runner/root/.cache" >> "$GITHUB_ENV"
318+
293319
- name: Setup Python
294320
uses: actions/setup-python@v6
295321
with:

0 commit comments

Comments
 (0)