Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching of workspace on Github Action does not work well. #9263

Open
higumachan opened this issue Nov 20, 2024 · 1 comment
Open

Caching of workspace on Github Action does not work well. #9263

higumachan opened this issue Nov 20, 2024 · 1 comment

Comments

@higumachan
Copy link

When creating a workspace with multiple sub project, the cache for subdirectories does not work as expected.

uv version

0.5.3

Prerequisites

For example, when running the following in a GitHub Action:

      - name: "Install the project"
        run: uv sync --no-editable --all-extras --dev --frozen -vvv  --all-packages
        env:
          UV_CONCURRENT_BUILDS: 1
          UV_CONCURRENT_DOWNLOADS: 1
          UV_CONCURRENT_INSTALLS: 1

This issue occurs in projects using uv with multiple pyproject.toml files, such as the following structure:

.
├── pyproject.toml
└── src/
    └── packages/
        ├── package1/
        │   ├── src
        │   └── pyproject.toml
        └── package2/
            ├── src
            └── pyproject.toml

Here is an example pyproject.toml:

[project]
name = "some_project"
version = "0.1.0"
requires-python = ">=3.12"
classifiers = [
    "Programming Language :: Rust",
    "Programming Language :: Python :: Implementation :: CPython",
    "Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = [
    "package1",
    "package2",
]

Observed Behavior

Even when configuring the uv cache directory on GitHub Actions, the cache is not applied correctly within uv.

Cause

The issue seems to stem from a combination of two factors:

  1. Timestamp updates during git clone: Files managed by Git have their timestamps updated to the clone time. As a result, the source files are always considered "newer" than the cache files, causing uv to bypass the cache.
  2. Reliance on ctime in uv: Since uv uses ctime to determine cache freshness, workarounds like using the touch command cannot be applied.

Ideas

Use hash-based cache management in CI mode

Similar to the --ci option for cache prune, a --ci option for sync and run commands could enable hash-based cache management instead of timestamp-based.

Use mtime instead of ctime

Using mtime would allow workarounds such as touch to function. However, as noted in #1060, this approach may have its own drawbacks and is not ideal.


If there are other potential solutions, please share! Especially if there's a way to resolve this issue with the current version of uv.

@higumachan
Copy link
Author

higumachan commented Nov 20, 2024

Use mtime with ctime

Adopt mtime and ctime which is ahead in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant