Skip to content

Failing to detect changed cache? #467

@mikenerone

Description

@mikenerone

There's a good chance this is pilot error, but if so, I'm failing to see what I'm doing wrong or misunderstanding.

Running in a Github-hosted runner, my uv cache, though changed, doesn't seem to be saved between runs. Here are the relevant pieces of my workflow:

      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          enable-cache: true

In the output, we can see there's a cache hit (it did previously save the first time, of course, when the cache didn't yet exist):

Run astral-sh/setup-uv@v5
Downloading uv from "https://github.com/astral-sh/uv/releases/download/0.7.17/uv-x86_64-unknown-linux-gnu.tar.gz" ...
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /home/runner/work/_temp/48fd820e-f06d-49e7-be5b-e5f1d71e58c1 -f /home/runner/work/_temp/19664c42-00be-464b-9509-687f2da5d79b
Added /home/runner/.local/bin to the path
Added /opt/hostedtoolcache/uv/0.7.17/x86_64 to the path
Set UV_CACHE_DIR to /home/runner/work/_temp/setup-uv-cache
Successfully installed uv version 0.7.17
Searching files using cache dependency glob: **/uv.lock,**/requirements*.txt
/home/runner/work/REDACTED/REDACTED/uv.lock
Found 1 files to hash.
Trying to restore uv cache from GitHub Actions cache with key: setup-uv-1-x86_64-unknown-linux-gnu-unknown-c88a825de78a7f8573706abd91c0e54c0b7c016a3bfe1514e4ceba9343bde293
Cache hit for: setup-uv-1-x86_64-unknown-linux-gnu-unknown-c88a825de78a7f8573706abd91c0e54c0b7c016a3bfe1514e4ceba9343bde293
Received 1809858 of 1809858 (100.0%), 19.6 MBs/sec
Cache Size: ~2 MB (1809858 B)
/usr/bin/tar -xf /home/runner/work/_temp/14665711-a1ef-4be8-a41e-c9df4651a6fc/cache.tzst -P -C /home/runner/work/REDACTED/REDACTED --use-compress-program unzstd
Cache restored successfully
uv cache restored from GitHub Actions cache with key: setup-uv-1-x86_64-unknown-linux-gnu-unknown-c88a825de78a7f8573706abd91c0e54c0b7c016a3bfe1514e4ceba9343bde293
      - name: Check cache
        run: |
          echo "uv cache dir: $(uv cache dir)"
          find $(uv cache dir) -type f | wc -l
          du -sh $(uv cache dir)

Here I'm just logging the state of the cache directories contents. Output:

Run echo "uv cache dir: $(uv cache dir)"
uv cache dir: /home/runner/work/_temp/setup-uv-cache
25
8.6M	/home/runner/work/_temp/setup-uv-cache

Then I sync:

      - name: Sync venv 🔍
        run: uv sync --locked --all-extras --no-default-groups

Here we see that the some of the deps are actually downloaded:

Run uv sync --locked --all-extras --no-default-groups
Downloading cpython-3.12.11-linux-x86_64-gnu (download) (32.8MiB)
 Downloading cpython-3.12.11-linux-x86_64-gnu (download)
Using CPython 3.12.11
Creating virtual environment at: .venv
Resolved 82 packages in 1ms
   Building REDACTED @ file:///home/runner/work/REDACTED/REDACTED
Downloading lxml (5.0MiB)
Downloading pycountry (6.0MiB)
Downloading faker (1.8MiB)
Downloading pygments (1.2MiB)
Downloading pydantic-core (1.9MiB)
 Downloading pydantic-core
 Downloading lxml
 Downloading pygments
 Downloading pycountry
 Downloading faker
      Built REDACTED @ file:///home/runner/work/REDACTED/REDACTED
Prepared 55 packages in 1.57s
Installed 55 packages in 97ms
[LIST OF INSTALLED DEPS REDACTED]

Then check the state of the cache again, confirming it changed (same step definition as above):

Run echo "uv cache dir: $(uv cache dir)"
uv cache dir: /home/runner/work/_temp/setup-uv-cache
4970
91M	/home/runner/work/_temp/setup-uv-cache

So the cache changed, but in the Post Install uv step, it doesn't get saved:

Post job cleanup.
Cache hit occurred on key setup-uv-1-x86_64-unknown-linux-gnu-unknown-c88a825de78a7f8573706abd91c0e54c0b7c016a3bfe1514e4ceba9343bde293, not saving cache.

If I run this workflow again (with no changes at all to the branch content), it continues to be missing those downloaded packages in the cache, and has to redownload them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions