From 820e47700295a66797ecbfdf4fdd5e04e8c4bb7a Mon Sep 17 00:00:00 2001 From: Wesley Simplicio Date: Sat, 9 May 2026 00:01:27 -0300 Subject: [PATCH 1/2] perf(ci): cache uv + .venv to skip rebuild on every run Closes #22004 --- .github/workflows/tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a92afdfa40dd9..70d555d1c17c9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,16 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 + - name: Cache uv + .venv + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + with: + path: | + ~/.cache/uv + .venv + key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + ${{ runner.os }}-py3.11-uv- + - name: Set up Python 3.11 run: uv python install 3.11 @@ -63,6 +73,16 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 + - name: Cache uv + .venv + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + with: + path: | + ~/.cache/uv + .venv + key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + ${{ runner.os }}-py3.11-uv- + - name: Set up Python 3.11 run: uv python install 3.11 From 38377046fa09872b0b7327dd61e04cdccbca6ce8 Mon Sep 17 00:00:00 2001 From: Wesley Simplicio Date: Sat, 9 May 2026 15:03:51 -0300 Subject: [PATCH 2/2] ci(tests): split uv download cache from .venv cache and gate install Previously a single cache step combined ~/.cache/uv and .venv with broad restore-keys. The cache step had no id and the install step always ran, making the cache effectively unused. Worse, restore-keys on .venv could restore an environment built for a different dependency set. Split into two caches: broad restore-keys for ~/.cache/uv (always safe), and strict-key-only for .venv (no restore-keys). Gate the install step on the .venv cache-hit so cached envs skip reinstall. --- .github/workflows/tests.yml | 40 ++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 70d555d1c17c9..dd3dc66cda4a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,20 +34,28 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 - - name: Cache uv + .venv + - name: Cache uv download cache uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 with: - path: | - ~/.cache/uv - .venv - key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }} + path: ~/.cache/uv + key: ${{ runner.os }}-py3.11-uv-cache-${{ hashFiles('pyproject.toml', 'uv.lock') }} restore-keys: | - ${{ runner.os }}-py3.11-uv- + ${{ runner.os }}-py3.11-uv-cache- + + - name: Cache .venv + id: cache-venv + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + with: + path: .venv + # Strict key only — no restore-keys, since pip/uv installs don't + # reliably prune removed deps and a stale venv breaks builds. + key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml', 'uv.lock') }} - name: Set up Python 3.11 run: uv python install 3.11 - name: Install dependencies + if: steps.cache-venv.outputs.cache-hit != 'true' run: | uv venv .venv --python 3.11 source .venv/bin/activate @@ -73,20 +81,28 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 - - name: Cache uv + .venv + - name: Cache uv download cache uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 with: - path: | - ~/.cache/uv - .venv - key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }} + path: ~/.cache/uv + key: ${{ runner.os }}-py3.11-uv-cache-${{ hashFiles('pyproject.toml', 'uv.lock') }} restore-keys: | - ${{ runner.os }}-py3.11-uv- + ${{ runner.os }}-py3.11-uv-cache- + + - name: Cache .venv + id: cache-venv + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + with: + path: .venv + # Strict key only — no restore-keys, since pip/uv installs don't + # reliably prune removed deps and a stale venv breaks builds. + key: ${{ runner.os }}-py3.11-venv-${{ hashFiles('pyproject.toml', 'uv.lock') }} - name: Set up Python 3.11 run: uv python install 3.11 - name: Install dependencies + if: steps.cache-venv.outputs.cache-hit != 'true' run: | uv venv .venv --python 3.11 source .venv/bin/activate