From 83d51e871676ac3744eb7f6e97b0efdabd2b5d95 Mon Sep 17 00:00:00 2001 From: Vishal Bala Date: Mon, 9 Nov 2026 10:20:39 +0100 Subject: [PATCH 1/3] ci: share pruned uv caches with restore-keys and cancel superseded PR runs (FDE-205) - Replace setup-uv's built-in cache (no restore-keys) with actions/cache/restore + save, pruned with `uv cache prune --ci` and saved after install, before the tests. A uv.lock change now gets a partial hit instead of a cold rebuild. - One saver per Python version: service-tests saves 3.11, the redis-py 8.x x redis:8.4 leg saves the others; every other job is restore-only. docs and lint's lock job no longer cache. - HuggingFace cache: versioned key (-v2), restore-only in the matrix and notebooks, saved only by the canary; off actions/cache@v4. - test-fork-pr.yml runs the service-tests action from this repository with save-cache false, so a fork PR cannot save main-scoped caches. - Cancel superseded PR runs in test.yml and lint.yml; never cancel pushes, schedule or dispatch. - Pin runs-on: ubuntu-24.04 (the cache key names the OS), drop the docs group from test legs, setup-python v5 -> v6. --- .github/actions/run-service-tests/action.yml | 60 +++++++++-- .github/workflows/lint.yml | 36 +++++-- .github/workflows/test-fork-pr.yml | 21 +++- .github/workflows/test.yml | 103 ++++++++++++++----- 4 files changed, 173 insertions(+), 47 deletions(-) diff --git a/.github/actions/run-service-tests/action.yml b/.github/actions/run-service-tests/action.yml index aae42e55d..a53a28408 100644 --- a/.github/actions/run-service-tests/action.yml +++ b/.github/actions/run-service-tests/action.yml @@ -8,15 +8,26 @@ inputs: uv-version: description: 'uv version to use' required: true + save-cache: + description: >- + Save the uv and HuggingFace caches. Only one job per cache key should + save; pass "false" from every other caller, and always from a run that + executes untrusted code. + required: false + default: 'true' runs: using: 'composite' steps: - - name: Cache HuggingFace Models - uses: actions/cache@v5 + # Bump the version suffix to drop a stale model cache; the key is static, + # so a saved cache is never refreshed otherwise. Keep it in sync with the + # restore steps in test.yml. + - name: Restore HuggingFace models + id: hf-cache + uses: actions/cache/restore@v5 with: path: hf_cache - key: ${{ runner.os }}-hf-cache + key: ${{ runner.os }}-hf-cache-v2 - name: Set HuggingFace token shell: bash @@ -29,15 +40,26 @@ runs: with: python-version: ${{ inputs.python-version }} + # Caching is done by the restore/save steps around the install instead of + # by setup-uv, which has no restore-keys fallback. See test.yml. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ inputs.uv-version }} - enable-cache: true + enable-cache: false + cache-local-path: ~/.cache/uv # sets UV_CACHE_DIR python-version: ${{ inputs.python-version }} - cache-dependency-glob: | - pyproject.toml - uv.lock + + # The runner OS is hard-coded in the key; callers pin runs-on: ubuntu-24.04. + # Key format is shared with test.yml and lint.yml; keep all three in sync. + - name: Restore uv cache + id: uv-cache + uses: actions/cache/restore@v5 + with: + path: ~/.cache/uv + key: uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ inputs.python-version }}-pruned-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ inputs.python-version }}-pruned- - name: Install required dependencies shell: bash @@ -54,6 +76,20 @@ runs: run: | uv sync --all-extras + # Saved before the tests, so a failing test doesn't cost the next run its + # cache. `prune --ci` keeps only wheels built from source. + - name: Prune uv cache + if: inputs.save-cache == 'true' && steps.uv-cache.outputs.cache-hit != 'true' + shell: bash + run: uv cache prune --ci + + - name: Save uv cache + if: inputs.save-cache == 'true' && steps.uv-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: ~/.cache/uv + key: ${{ steps.uv-cache.outputs.cache-primary-key }} + - name: Authenticate to Google Cloud uses: google-github-actions/auth@v1 with: @@ -63,3 +99,13 @@ runs: shell: bash run: | make test-all + + # After the tests, which download the models. Only on success, because the + # key is static: a cache saved after an early failure would be missing + # models until the key is bumped. + - name: Save HuggingFace models + if: inputs.save-cache == 'true' && steps.hf-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v5 + with: + path: hf_cache + key: ${{ steps.hf-cache.outputs.cache-primary-key }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d6b162b3..3bdd69efd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,26 +6,33 @@ on: branches: - main +# A new push to a PR cancels that PR's previous run; pushes to main are never +# cancelled. Same rule as test.yml. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: UV_VERSION: "0.13.1" + # The uv cache key below hard-codes the runner OS, so the jobs pin + # `runs-on: ubuntu-24.04`. Change both together. jobs: lock: name: Check uv.lock is up to date - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Check out repository uses: actions/checkout@v6 + # No cache: `uv lock --check` installs nothing, so a cache would only take + # up space. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true - cache-dependency-glob: | - pyproject.toml - uv.lock + enable-cache: false # Fails a pyproject.toml change that was never locked, before the drift # lands on main and dirties the next contributor's tree. @@ -34,7 +41,7 @@ jobs: check: name: Style-check ${{ matrix.python-version }} - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 strategy: matrix: python-version: @@ -58,11 +65,20 @@ jobs: uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + enable-cache: false + cache-local-path: ~/.cache/uv # sets UV_CACHE_DIR python-version: ${{ matrix.python-version }} # sets UV_PYTHON - cache-dependency-glob: | - pyproject.toml - uv.lock + + # Restore-only: the Test Suite workflow saves these caches (same key format + # as test.yml; keep them in sync). This job installs the same + # `--all-extras` environment, so it reuses them as they are. + - name: Restore uv cache + uses: actions/cache/restore@v5 + with: + path: ~/.cache/uv + key: uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ matrix.python-version }}-pruned-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ matrix.python-version }}-pruned- - name: Install dependencies run: | diff --git a/.github/workflows/test-fork-pr.yml b/.github/workflows/test-fork-pr.yml index 715102084..a3c2b6676 100644 --- a/.github/workflows/test-fork-pr.yml +++ b/.github/workflows/test-fork-pr.yml @@ -13,6 +13,9 @@ permissions: checks: write pull-requests: read +# No `concurrency` block: cancelling a run would leave the check run created +# below stuck at in_progress on the fork PR. + env: PYTHON_VERSION: "3.11" UV_VERSION: "0.13.1" @@ -20,7 +23,7 @@ env: jobs: setup: name: Validate PR - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 outputs: head_sha: ${{ steps.pr-info.outputs.head_sha }} head_repo: ${{ steps.pr-info.outputs.head_repo }} @@ -59,7 +62,7 @@ jobs: service-tests: name: Service Tests - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 needs: setup steps: - name: Create check run @@ -83,11 +86,23 @@ jobs: repository: ${{ needs.setup.outputs.head_repo }} ref: ${{ needs.setup.outputs.head_sha }} + # This run is on the dispatching ref (main), so any cache it saved would + # be restored by every later run on main and by every PR. Run the action + # from this repository rather than from the fork checkout, so the fork + # cannot edit away `save-cache: "false"`. + - name: Check out trusted actions + uses: actions/checkout@v6 + with: + path: trusted-actions + sparse-checkout: .github/actions + persist-credentials: false + - name: Run service tests - uses: ./.github/actions/run-service-tests + uses: ./trusted-actions/.github/actions/run-service-tests with: python-version: ${{ env.PYTHON_VERSION }} uv-version: ${{ env.UV_VERSION }} + save-cache: "false" env: HF_HOME: ${{ github.workspace }}/hf_cache HF_TOKEN: ${{ secrets.HF_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c95f7a7e7..d48902776 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,14 +12,24 @@ on: workflow_dispatch: +# A new push to a PR cancels that PR's previous run. Every other event gets a +# group of its own (the run ID), so pushes to main, the nightly schedule and +# manual dispatches are never cancelled. +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + env: PYTHON_VERSION: "3.11" UV_VERSION: "0.13.1" + # The uv cache keys below hard-code the runner OS, so every job pins + # `runs-on: ubuntu-24.04` rather than following ubuntu-latest. Change both + # together. jobs: service-tests: name: Service Tests - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # Needs API-key secrets. Fork PRs and Dependabot-triggered runs get none, so # they skip here; a maintainer runs them via test-fork-pr.yml instead. if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') @@ -27,11 +37,15 @@ jobs: - name: Check out repository uses: actions/checkout@v6 + # The canary saves the Python 3.11 uv cache and the HuggingFace model + # cache. It finishes before the matrix starts, so the matrix legs and + # notebooks restore what it saved and never save themselves. - name: Run service tests uses: ./.github/actions/run-service-tests with: python-version: ${{ env.PYTHON_VERSION }} uv-version: ${{ env.UV_VERSION }} + save-cache: "true" env: HF_HOME: ${{ github.workspace }}/hf_cache HF_TOKEN: ${{ secrets.HF_TOKEN }} @@ -64,7 +78,7 @@ jobs: test: name: Python ${{ matrix.python-version }} - redis-py ${{ matrix.redis-py-version }} [${{ matrix.redis-image }}] - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # `needs` is here to order this job after the HF model cache is primed, not # to gate it on the service suite passing (it was `needs: prime-cache` when # it was introduced in #306). Without a status check function, `needs` also @@ -97,32 +111,45 @@ jobs: - name: Check out repository uses: actions/checkout@v6 - - name: Cache HuggingFace Models - uses: actions/cache@v4 + # Restore-only: service-tests is the one job that saves this cache. + - name: Restore HuggingFace models + uses: actions/cache/restore@v5 with: path: hf_cache - key: ${{ runner.os }}-hf-cache + key: ${{ runner.os }}-hf-cache-v2 - name: Install Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + # setup-uv's own cache has no restore-keys fallback, so any uv.lock change + # (the release bot's version bump included) would start every leg cold. + # The restore and save steps around the install do the caching instead. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + enable-cache: false + cache-local-path: ~/.cache/uv # sets UV_CACHE_DIR python-version: ${{ matrix.python-version }} # sets UV_PYTHON - cache-dependency-glob: | - pyproject.toml - uv.lock + + # Key format is shared with lint.yml and the run-service-tests action; + # keep all three in sync. + - name: Restore uv cache + id: uv-cache + uses: actions/cache/restore@v5 + with: + path: ~/.cache/uv + key: uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ matrix.python-version }}-pruned-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ matrix.python-version }}-pruned- - name: Install dependencies run: | set -euo pipefail - uv sync --all-extras --frozen + uv sync --all-extras --no-group docs --frozen # Must cover every redis-py-version matrix value; unhandled values fail. case "$REDIS_PY_VERSION" in @@ -138,13 +165,29 @@ jobs: uv pip install "$spec" uv run python -c 'import redis; print("redis-py:", redis.__version__)' + # One saver per Python version, so legs don't race to save the same key. + # service-tests saves 3.11; for the other versions the redis-py 8.x x + # redis:8.4 leg saves. Saving here rather than after the tests keeps the + # cache when a test fails. `prune --ci` keeps only wheels built from + # source; pre-built wheels download faster than they restore. + - name: Prune uv cache + if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:8.4' && steps.uv-cache.outputs.cache-hit != 'true' }} + run: uv cache prune --ci + + - name: Save uv cache + if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:8.4' && steps.uv-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v5 + with: + path: ~/.cache/uv + key: ${{ steps.uv-cache.outputs.cache-primary-key }} + - name: Run tests run: | make test notebooks: name: Notebook Validation - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 # Ordered after the HF cache is primed, not gated on it; see the `test` job. needs: service-tests # Needs API-key secrets, unavailable to fork PRs and Dependabot. Keep in @@ -156,14 +199,15 @@ jobs: - name: Check out repository uses: actions/checkout@v6 - - name: Cache HuggingFace Models - uses: actions/cache@v4 + # Restore-only, like the uv cache below: service-tests saves both. + - name: Restore HuggingFace models + uses: actions/cache/restore@v5 with: path: hf_cache - key: ${{ runner.os }}-hf-cache + key: ${{ runner.os }}-hf-cache-v2 - name: Install Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} @@ -171,11 +215,17 @@ jobs: uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + enable-cache: false + cache-local-path: ~/.cache/uv # sets UV_CACHE_DIR python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON - cache-dependency-glob: | - pyproject.toml - uv.lock + + - name: Restore uv cache + uses: actions/cache/restore@v5 + with: + path: ~/.cache/uv + key: uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ env.PYTHON_VERSION }}-pruned-${{ hashFiles('pyproject.toml', 'uv.lock') }} + restore-keys: | + uv-v1-ubuntu-24.04-${{ runner.arch }}-py${{ env.PYTHON_VERSION }}-pruned- - name: Install dependencies run: | @@ -233,26 +283,25 @@ jobs: make test-notebooks docs: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Check out repository uses: actions/checkout@v6 - name: Install Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} + # No cache: the docs install is small, and its cache used to claim the + # shared 3.11 key before the test jobs could save a useful one. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + enable-cache: false python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON - cache-dependency-glob: | - pyproject.toml - uv.lock - + - name: Install dependencies run: | uv sync --group docs --frozen From e964e9f0d8425da733401cd5cfa4dce4c9a4981c Mon Sep 17 00:00:00 2001 From: Vishal Bala Date: Mon, 9 Nov 2026 10:25:24 +0100 Subject: [PATCH 2/3] ci: harden the fork-PR cache path and pick a stable uv saver leg (FDE-205) - test-fork-pr.yml: cache-mode: read on the job that runs fork code, and persist-credentials: false on the fork checkout; the comment now says what this does and does not stop. - Pick the non-3.11 uv saver by redis:latest, the image value that never rotates, and note the dependency beside the matrix. - Correct comments on the docs group, the canary's HF save and the runs-on pins. --- .github/workflows/lint.yml | 7 ++++--- .github/workflows/test-fork-pr.yml | 17 +++++++++++++---- .github/workflows/test.yml | 20 ++++++++++++++------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3bdd69efd..06dd01003 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,7 @@ concurrency: env: UV_VERSION: "0.13.1" # The uv cache key below hard-codes the runner OS, so the jobs pin - # `runs-on: ubuntu-24.04`. Change both together. + # `runs-on: ubuntu-24.04` (all of them, for uniformity). Change both together. jobs: lock: @@ -70,8 +70,9 @@ jobs: python-version: ${{ matrix.python-version }} # sets UV_PYTHON # Restore-only: the Test Suite workflow saves these caches (same key format - # as test.yml; keep them in sync). This job installs the same - # `--all-extras` environment, so it reuses them as they are. + # as test.yml; keep them in sync). This job installs the test legs' + # `--all-extras` environment plus the docs group, so it reuses them as + # they are. - name: Restore uv cache uses: actions/cache/restore@v5 with: diff --git a/.github/workflows/test-fork-pr.yml b/.github/workflows/test-fork-pr.yml index a3c2b6676..ea0dacd94 100644 --- a/.github/workflows/test-fork-pr.yml +++ b/.github/workflows/test-fork-pr.yml @@ -64,6 +64,11 @@ jobs: name: Service Tests runs-on: ubuntu-24.04 needs: setup + # This job runs fork code on the dispatching ref (main), and a cache saved + # here would be restored by every later run on main and by every PR. + # `read` lets it restore but makes the cache toolkit skip every save, + # whichever step attempts it. + cache-mode: read steps: - name: Create check run id: check @@ -85,11 +90,15 @@ jobs: with: repository: ${{ needs.setup.outputs.head_repo }} ref: ${{ needs.setup.outputs.head_sha }} + # Keep GITHUB_TOKEN (checks: write) out of .git/config, where the + # fork's code could read it. + persist-credentials: false - # This run is on the dispatching ref (main), so any cache it saved would - # be restored by every later run on main and by every PR. Run the action - # from this repository rather than from the fork checkout, so the fork - # cannot edit away `save-cache: "false"`. + # Run the action from this repository rather than from the fork + # checkout, so the fork cannot edit away `save-cache: "false"`. Together + # with `cache-mode: read` this stops the workflow's own steps saving a + # cache; it cannot stop fork code that obtains the runner's cache token + # and calls the cache service itself. - name: Check out trusted actions uses: actions/checkout@v6 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d48902776..588e30a0f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,9 +37,11 @@ jobs: - name: Check out repository uses: actions/checkout@v6 - # The canary saves the Python 3.11 uv cache and the HuggingFace model - # cache. It finishes before the matrix starts, so the matrix legs and - # notebooks restore what it saved and never save themselves. + # The canary saves the Python 3.11 uv cache and, when its tests pass, the + # HuggingFace model cache. It finishes before the matrix starts, so the + # matrix legs and notebooks restore what it saved and never save these + # themselves. When it is skipped (fork and Dependabot PRs) they restore + # from the base branch instead. - name: Run service tests uses: ./.github/actions/run-service-tests with: @@ -103,6 +105,8 @@ jobs: redis-py-version: ["6.x", "7.x", "8.x"] # `redis:latest` floats, so a failure on it is not reproducible from a # SHA; it is advisory below. Pinned tags carry the blocking coverage. + # The uv cache saver below matches redis-py-version 8.x and + # redis:latest; update it if either value goes. redis-image: ["redis:8.2", "redis:8.4", "redis:latest"] include: - redis-image: "redis:latest" @@ -149,6 +153,8 @@ jobs: run: | set -euo pipefail + # The docs group (Sphinx and friends) is only for building docs; + # no test imports it. uv sync --all-extras --no-group docs --frozen # Must cover every redis-py-version matrix value; unhandled values fail. @@ -167,15 +173,17 @@ jobs: # One saver per Python version, so legs don't race to save the same key. # service-tests saves 3.11; for the other versions the redis-py 8.x x - # redis:8.4 leg saves. Saving here rather than after the tests keeps the + # redis:latest leg saves (`redis:latest` is the image value that never + # rotates; its continue-on-error doesn't matter because the save comes + # before the tests). Saving here rather than after the tests keeps the # cache when a test fails. `prune --ci` keeps only wheels built from # source; pre-built wheels download faster than they restore. - name: Prune uv cache - if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:8.4' && steps.uv-cache.outputs.cache-hit != 'true' }} + if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:latest' && steps.uv-cache.outputs.cache-hit != 'true' }} run: uv cache prune --ci - name: Save uv cache - if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:8.4' && steps.uv-cache.outputs.cache-hit != 'true' }} + if: ${{ matrix.python-version != env.PYTHON_VERSION && matrix.redis-py-version == '8.x' && matrix.redis-image == 'redis:latest' && steps.uv-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@v5 with: path: ~/.cache/uv From ca4e2a74e13ff8cb79524f85484a7f651379cc6b Mon Sep 17 00:00:00 2001 From: Vishal Bala Date: Thu, 19 Nov 2026 16:22:20 +0100 Subject: [PATCH 3/3] ci: stop the release workflow caching and correct the cache comments (FDE-205) - auto-release.yml: enable-cache false in all three setup-uv steps. Its saves competed with the test caches for the 10 GB, and the publish job should not restore anything from the shared cache. - test-fork-pr.yml: cache-mode read is enforced through a read-only cache token, so say so; the trusted-actions checkout is now described as the second guard it is. - test.yml: name PYTHON_VERSION rather than 3.11 where the code keys off it, and drop two stale reasons from the coverage and docs comments. --- .github/workflows/auto-release.yml | 24 ++++++++++++------------ .github/workflows/test-fork-pr.yml | 12 +++++------- .github/workflows/test.yml | 9 ++++----- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 6b89c2590..4e243e8cb 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -111,11 +111,11 @@ jobs: uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + # No cache: a release job must not run anything restored from the + # shared cache, and its saves would only compete with the test + # jobs' caches for the repository's 10 GB. + enable-cache: false python-version: ${{ env.PYTHON_VERSION }} - cache-dependency-glob: | - pyproject.toml - uv.lock - name: Install dependencies run: uv sync --frozen @@ -194,11 +194,11 @@ jobs: uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + # No cache: a release job must not run anything restored from the + # shared cache, and its saves would only compete with the test + # jobs' caches for the repository's 10 GB. + enable-cache: false python-version: ${{ env.PYTHON_VERSION }} - cache-dependency-glob: | - pyproject.toml - uv.lock - name: Apply release version to pyproject.toml and uv.lock run: | @@ -320,11 +320,11 @@ jobs: uses: astral-sh/setup-uv@v10.0.0 with: version: ${{ env.UV_VERSION }} - enable-cache: true + # No cache: a release job must not run anything restored from the + # shared cache, and its saves would only compete with the test + # jobs' caches for the repository's 10 GB. + enable-cache: false python-version: ${{ env.PYTHON_VERSION }} - cache-dependency-glob: | - pyproject.toml - uv.lock - name: Install dependencies run: uv sync --frozen diff --git a/.github/workflows/test-fork-pr.yml b/.github/workflows/test-fork-pr.yml index ea0dacd94..f16ea33ae 100644 --- a/.github/workflows/test-fork-pr.yml +++ b/.github/workflows/test-fork-pr.yml @@ -66,8 +66,8 @@ jobs: needs: setup # This job runs fork code on the dispatching ref (main), and a cache saved # here would be restored by every later run on main and by every PR. - # `read` lets it restore but makes the cache toolkit skip every save, - # whichever step attempts it. + # `read` gives the job a cache token that can restore but not save, so + # the cache service refuses a save from any step, fork code included. cache-mode: read steps: - name: Create check run @@ -94,11 +94,9 @@ jobs: # fork's code could read it. persist-credentials: false - # Run the action from this repository rather than from the fork - # checkout, so the fork cannot edit away `save-cache: "false"`. Together - # with `cache-mode: read` this stops the workflow's own steps saving a - # cache; it cannot stop fork code that obtains the runner's cache token - # and calls the cache service itself. + # A second guard, in case `cache-mode` is ever not honoured: run the + # action from this repository rather than from the fork checkout, so + # the fork cannot edit away `save-cache: "false"`. - name: Check out trusted actions uses: actions/checkout@v6 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b208f684..a24b14726 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: - name: Check out repository uses: actions/checkout@v6 - # The canary saves the Python 3.11 uv cache and, when its tests pass, the + # The canary saves the PYTHON_VERSION uv cache and, when its tests pass, the # HuggingFace model cache. It finishes before the matrix starts, so the # matrix legs and notebooks restore what it saved and never save these # themselves. When it is skipped (fork and Dependabot PRs) they restore @@ -184,7 +184,7 @@ jobs: uv run python -c 'import redis; print("redis-py:", redis.__version__)' # One saver per Python version, so legs don't race to save the same key. - # service-tests saves 3.11; for the other versions the redis-py 8.x x + # service-tests saves PYTHON_VERSION; for the others the redis-py 8.x x # redis:latest leg saves (`redis:latest` is the image value that never # rotates; its continue-on-error doesn't matter because the save comes # before the tests). Saving here rather than after the tests keeps the @@ -238,7 +238,7 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} # No cache: this job installs only the dev group, without the project, - # so a cache would hold little and claim a key the test jobs need. + # so a cache would hold little. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: @@ -559,8 +559,7 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} - # No cache: the docs install is small, and its cache used to claim the - # shared 3.11 key before the test jobs could save a useful one. + # No cache: the docs install is small. - name: Install uv uses: astral-sh/setup-uv@v10.0.0 with: