Skip to content

Commit 6038edb

Browse files
committed
ci: cache uv dependencies via setup-uv native caching
Every CI job cold-installed dependencies (~340s 'Setup UV'), and a prior custom actions/cache never actually hit (exact-key + prime race). Worse, on a cold uv cache 'uv sync' rebuilds the orb-py package, firing setup.py's build hook → build_ui.sh (reflex export + bun) → a full SPA build inside the dependency install, which timed the job out. Fix: use setup-uv's native cache (enable-cache, keyed on uv.lock) which caches UV_CACHE_DIR — the wheel cache uv actually uses — so a warm run links wheels in ~14s instead of ~340s. Pin Python 3.12 via actions/setup-python before uv so uv never fetches an interpreter, and run 'uv sync' with ORB_SKIP_UI_BUILD=1 so the package build never triggers the SPA build. The custom actions/cache prime/restore is removed (setup-uv handles caching per job); cache-management now only emits the cache-key output callers still reference.
1 parent f3d74ba commit 6038edb

11 files changed

Lines changed: 43 additions & 45 deletions

File tree

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
name: 'Setup UV with Cache'
2-
description: 'Install UV and restore cached environment'
2+
description: 'Install UV with its native wheel cache (enable-cache) and install deps'
33
inputs:
44
cache-key:
5-
description: 'Cache key for UV environment'
6-
required: true
5+
description: 'Unused — kept for caller compatibility; setup-uv manages its own cache.'
6+
required: false
7+
default: ''
78
fail-on-cache-miss:
8-
description: 'Whether to fail if cache is not found'
9+
description: 'Unused — kept for caller compatibility.'
910
required: false
10-
default: 'true'
11+
default: 'false'
1112

1213
runs:
1314
using: 'composite'
1415
steps:
16+
# Pin the interpreter BEFORE uv so uv never tries to fetch/build a Python.
17+
- name: Set up Python
18+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
19+
with:
20+
python-version: '3.12'
21+
22+
# setup-uv's native cache keys on the uv.lock hash and caches UV_CACHE_DIR
23+
# (the wheel/download cache uv actually uses). Warm cache → link, not download.
1524
- name: Install UV
1625
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
17-
18-
- name: Restore UV environment
19-
id: restore-cache
20-
uses: actions/cache/restore@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0
2126
with:
22-
path: |
23-
.venv
24-
~/.cache/uv
25-
~/.local/bin/uv
26-
/opt/hostedtoolcache/uv
27-
key: ${{ inputs.cache-key }}
28-
fail-on-cache-miss: ${{ inputs.fail-on-cache-miss }}
27+
version: "0.9.6"
28+
enable-cache: true
29+
cache-dependency-glob: "uv.lock"
2930

30-
- name: Install dependencies if cache miss
31-
if: steps.restore-cache.outputs.cache-hit != 'true'
31+
# ORB_SKIP_UI_BUILD is CRITICAL: `uv sync` builds the orb-py package, which
32+
# runs setup.py's build_py hook → build_ui.sh (reflex export + bun) → the
33+
# full SPA build. On a cold uv cache that rebuild fires and takes >30 min,
34+
# timing the job out. Test jobs don't need the SPA, so skip it here.
35+
- name: Install dependencies
3236
shell: bash
33-
run: make dev-install
37+
env:
38+
ORB_SKIP_UI_BUILD: "1"
39+
run: uv sync --frozen --all-groups

.github/workflows/cache-management.yml

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
required: true
1313
type: string
1414
cache-key-base:
15-
description: 'Base cache key (e.g. test-deps, quality-deps)'
15+
description: 'Base cache key — all callers must pass "deps" for the shared env'
1616
required: true
1717
type: string
1818
python-version:
@@ -22,11 +22,11 @@ on:
2222
outputs:
2323
cache-key:
2424
description: 'Generated cache key for use in setup-uv-cached'
25-
value: ${{ jobs.generate-cache-key.outputs.cache-key }}
25+
value: ${{ jobs.setup-cache.outputs.cache-key }}
2626

2727
jobs:
28-
generate-cache-key:
29-
name: Generate Cache Key
28+
setup-cache:
29+
name: Prime Dependency Cache
3030
runs-on: ubuntu-latest
3131
permissions:
3232
contents: read
@@ -50,16 +50,8 @@ jobs:
5050
echo "key=$KEY" >> "$GITHUB_OUTPUT"
5151
echo "Generated cache key: $KEY"
5252
53-
- name: Restore cache
54-
id: cache
55-
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
56-
with:
57-
path: |
58-
~/.cache/uv
59-
.venv
60-
dist/
61-
.pytest_cache
62-
key: ${{ steps.cache-key.outputs.key }}
63-
restore-keys: |
64-
${{ inputs.cache-key-base }}-py${{ inputs.python-version }}-
65-
${{ inputs.cache-key-base }}-
53+
# NOTE: no cache save/restore here. Dependency caching is handled per-job
54+
# by the setup-uv-cached composite action via setup-uv's native cache
55+
# (keyed on uv.lock). This job only emits the cache-key output that callers
56+
# still reference; the custom prime/restore was removed because it never hit
57+
# (exact-key + prime race) and duplicated setup-uv's own cache.

.github/workflows/changelog-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: ./.github/workflows/cache-management.yml
3333
with:
3434
cache-type: dependencies
35-
cache-key-base: changelog-validation
35+
cache-key-base: deps
3636
python-version: ${{ needs.config.outputs.default-python-version }}
3737

3838
validate-changelog:

.github/workflows/ci-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
uses: ./.github/workflows/cache-management.yml
4747
with:
4848
cache-type: dependencies
49-
cache-key-base: quality-deps
49+
cache-key-base: deps
5050
python-version: ${{ needs.config.outputs.default-python-version }}
5151

5252
auto-format:

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: ./.github/workflows/cache-management.yml
5050
with:
5151
cache-type: dependencies
52-
cache-key-base: test-deps
52+
cache-key-base: deps
5353
python-version: ${{ needs.config.outputs.default-python-version }}
5454

5555
# Parallel test-group matrix (T2613): splits the non-provider test corpus

.github/workflows/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: ./.github/workflows/cache-management.yml
3333
with:
3434
cache-type: dependencies
35-
cache-key-base: dependabot
35+
cache-key-base: deps
3636
python-version: ${{ needs.config.outputs.default-python-version }}
3737

3838
update-uv-lock:

.github/workflows/dev-containers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
# fell through to the SHA-based fallback arm in cache-management.yml, producing
8383
# a cold key on every run and forcing a full dep reinstall each time.
8484
cache-type: dependencies
85-
cache-key-base: container-build
85+
cache-key-base: deps
8686
python-version: ${{ needs.config.outputs.default-python-version }}
8787

8888
container-pipeline:

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: ./.github/workflows/cache-management.yml
5757
with:
5858
cache-type: dependencies
59-
cache-key-base: docs-deps
59+
cache-key-base: deps
6060
python-version: ${{ needs.config.outputs.default-python-version }}
6161

6262
build:

.github/workflows/reusable-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
${{
117117
inputs.cache-key != ''
118118
&& inputs.cache-key
119-
|| format('test-deps-py{0}-{1}',
119+
|| format('deps-py{0}-{1}',
120120
inputs.python-version || inputs.default-python-version,
121121
hashFiles('.project.yml', 'pyproject.toml', 'uv.lock'))
122122
}}

.github/workflows/test-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: ./.github/workflows/cache-management.yml
2929
with:
3030
cache-type: dependencies
31-
cache-key-base: test-deps
31+
cache-key-base: deps
3232
python-version: ${{ needs.config.outputs.default-python-version }}
3333

3434
unit-tests:

0 commit comments

Comments
 (0)