Skip to content

fix(uv): Reuse the uv cache in runnable lock targets - #4180

Merged
rickeylev merged 4 commits into
bazel-contrib:mainfrom
hartikainen:uv-lock-cache
Sep 28, 2026
Merged

rickeylev merged 4 commits into
bazel-contrib:mainfrom
hartikainen:uv-lock-cache

Conversation

@hartikainen

Copy link
Copy Markdown
Contributor

This PR lets .run targets reuse the caller's uv cache by moving --no-cache from the shared arguments to the build-action arguments. Repeated runs can reuse registry metadata, Git checkouts, and build metadata. Build actions retain cache isolation, and callers can still pass --no-cache.

The lock tests use a sandbox-writable UV_CACHE_DIR and verify that .run creates it.

Closes #4179.

Copilot AI lite review requested due to automatic review settings September 23, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Correct the integration test lock-file path and update the news entry’s required references.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Updates lock() runnable targets to reuse the caller’s uv cache while preserving cache isolation for build actions.

Changes:

  • Moves --no-cache to build-action arguments.
  • Adds cache analysis and integration tests.
  • Documents the new runnable cache behavior.
File Summary
tests/​uv/​lock/​lock_run_test.py Updates runnable-script expectations and cache setup.
tests/​uv/​lock/​cache_tests.bzl Adds cache-policy analysis tests.
tests/​uv/​lock/​BUILD.bazel Registers cache tests.
tests/​integration/​uv_lock/​BUILD.bazel Adds the integration lock target.
tests/​integration/​uv_lock_test.py Tests cache reuse and bypass behavior; the lock-file path needs correction.
python/​uv/​private/​lock.bzl Separates build-only and runnable cache flags.
news/​uv-lock-run-cache.fixed.md Documents the change; needs required formatting and issue cross-reference updates.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread news/4179.fixed.md
Keep `--no-cache` on Bazel build actions while allowing `.run` targets
to reuse the persistent `uv` cache. Document the cache controls and test
both lock formats, cache opt-outs, and POSIX and Windows script generation.

The integration regression resolves against a local authenticated package
index, deletes the output, and regenerates the lockfile offline. It fails
for both formats when `.run` receives `--no-cache` by default.

Related to [bazel-contrib#4164](bazel-contrib#4164).
This applies the same separation between build-action flags and `.run`
defaults to caching. Output verbosity remains unchanged.
Stardoc requires the description and version note before `Args:`.
Comment thread tests/integration/uv_lock_test.py
Comment thread news/4179.fixed.md Outdated
Align the news fragment and Starlark analysis test file with project style conventions by adding the (uv) subsystem prefix and {obj} cross-reference in news/4179.fixed.md and wrapping lines to 80 columns in tests/uv/lock/cache_tests.bzl.
…ffline

Add blank lines between each setup/run/assert block in UvLockIntegrationTest.test_run_reuses_cache_offline for readability.
@rickeylev
rickeylev enabled auto-merge September 28, 2026 03:15
@rickeylev

Copy link
Copy Markdown
Collaborator

Thanks for the fix!

@rickeylev
rickeylev added this pull request to the merge queue Sep 28, 2026
Merged via the queue into bazel-contrib:main with commit 6efa7c3 Sep 28, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

Allow runnable lock targets to reuse the uv cache

3 participants