[AUTO-INF-2] CI Performance: Cache uv cache directory to speed up dependency installation #8046

Closed
opened 2026-04-13 01:25:25 +00:00 by HAL9000 · 2 comments
Owner

Metadata

  • Commit Message: perf(ci): cache uv cache directory to speed up dependency installation
  • Branch: task/auto-inf-2-cache-uv-cache-directory

Background and Context

A significant portion of CI time is often spent on installing dependencies. While nox reuses virtual environments, which helps, we can further optimize this by caching the uv cache directory across CI runs. This would prevent uv from having to download and build dependencies that have already been fetched in a previous run.

The uv cache directory is typically located at ~/.cache/uv on Linux. By configuring the CI system to cache this directory between runs (keyed on the dependency lock file, e.g., uv.lock), subsequent CI runs that have not changed dependencies will skip the download step entirely, resulting in significantly faster pipeline execution.

Expected Behavior

The CI pipeline caches the uv cache directory (~/.cache/uv) between runs, keyed on the contents of uv.lock. Dependency installation in all nox sessions is significantly faster on cache hits, as uv can resolve packages from the local cache rather than downloading them from the network.

Acceptance Criteria

  • The CI configuration (e.g., .forgejo/workflows/*.yml) is updated to cache the uv cache directory at ~/.cache/uv.
  • The cache key is based on the hash of uv.lock (or equivalent lock file) so that the cache is invalidated when dependencies change.
  • A restore key is configured as a fallback for partial cache hits.
  • CI runs that have not changed dependencies complete the dependency installation step faster than before (verified by comparing CI run times before and after).
  • All nox sessions (unit_tests, integration_tests, coverage_report, etc.) continue to pass after the caching change.
  • No existing tests are broken by this change.

Subtasks

  • Identify the CI workflow file(s) in .forgejo/workflows/ that run nox sessions.
  • Determine the correct cache key strategy (e.g., hash of uv.lock).
  • Add a cache step for ~/.cache/uv to the relevant CI workflow file(s).
  • Verify that the cache is correctly restored on subsequent runs by inspecting CI logs.
  • Run nox locally to confirm no regressions are introduced.
  • Verify coverage ≥ 97% via nox -s coverage_report.
  • Run full nox (all default sessions) and fix any errors.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches perf(ci): cache uv cache directory to speed up dependency installation exactly, followed by a blank line, then additional lines providing relevant implementation details.
  • The commit is pushed to the remote on the branch task/auto-inf-2-cache-uv-cache-directory.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Duplicate Check

  • Keyword search in open issues: Searched for open issues containing keywords like "CI", "performance", "speed", "slow", "cache", "nox", and "dependencies". No similar issues were found.
  • Cross-area search for similar proposals: Reviewed the titles of all open issues and found no similar proposals in other areas.
  • Closed issues search: Searched for closed issues with the same keywords and found no similar proposals.
  • Include a ### Duplicate Check section in every issue body: This section is included in this issue.
  • If uncertain, do not file: I am confident that this is a valid proposal.

Automated by CleverAgents Bot
Supervisor: Test Infrastructure Worker | Agent: [AUTO-INF-2]

## Metadata - **Commit Message**: `perf(ci): cache uv cache directory to speed up dependency installation` - **Branch**: `task/auto-inf-2-cache-uv-cache-directory` ## Background and Context A significant portion of CI time is often spent on installing dependencies. While `nox` reuses virtual environments, which helps, we can further optimize this by caching the `uv` cache directory across CI runs. This would prevent `uv` from having to download and build dependencies that have already been fetched in a previous run. The `uv` cache directory is typically located at `~/.cache/uv` on Linux. By configuring the CI system to cache this directory between runs (keyed on the dependency lock file, e.g., `uv.lock`), subsequent CI runs that have not changed dependencies will skip the download step entirely, resulting in significantly faster pipeline execution. ## Expected Behavior The CI pipeline caches the `uv` cache directory (`~/.cache/uv`) between runs, keyed on the contents of `uv.lock`. Dependency installation in all `nox` sessions is significantly faster on cache hits, as `uv` can resolve packages from the local cache rather than downloading them from the network. ## Acceptance Criteria - [ ] The CI configuration (e.g., `.forgejo/workflows/*.yml`) is updated to cache the `uv` cache directory at `~/.cache/uv`. - [ ] The cache key is based on the hash of `uv.lock` (or equivalent lock file) so that the cache is invalidated when dependencies change. - [ ] A restore key is configured as a fallback for partial cache hits. - [ ] CI runs that have not changed dependencies complete the dependency installation step faster than before (verified by comparing CI run times before and after). - [ ] All `nox` sessions (`unit_tests`, `integration_tests`, `coverage_report`, etc.) continue to pass after the caching change. - [ ] No existing tests are broken by this change. ## Subtasks - [ ] Identify the CI workflow file(s) in `.forgejo/workflows/` that run `nox` sessions. - [ ] Determine the correct cache key strategy (e.g., hash of `uv.lock`). - [ ] Add a cache step for `~/.cache/uv` to the relevant CI workflow file(s). - [ ] Verify that the cache is correctly restored on subsequent runs by inspecting CI logs. - [ ] Run `nox` locally to confirm no regressions are introduced. - [ ] Verify coverage ≥ 97% via `nox -s coverage_report`. - [ ] Run full `nox` (all default sessions) and fix any errors. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches `perf(ci): cache uv cache directory to speed up dependency installation` exactly, followed by a blank line, then additional lines providing relevant implementation details. - The commit is pushed to the remote on the branch `task/auto-inf-2-cache-uv-cache-directory`. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ### Duplicate Check - [x] **Keyword search in open issues:** Searched for open issues containing keywords like "CI", "performance", "speed", "slow", "cache", "nox", and "dependencies". No similar issues were found. - [x] **Cross-area search for similar proposals:** Reviewed the titles of all open issues and found no similar proposals in other areas. - [x] **Closed issues search:** Searched for closed issues with the same keywords and found no similar proposals. - [x] **Include a `### Duplicate Check` section in every issue body:** This section is included in this issue. - [x] **If uncertain, do not file:** I am confident that this is a valid proposal. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure Worker | Agent: [AUTO-INF-2]
Author
Owner

Parent Epic: This issue is a child of Epic #2810 (CI Quality Gates Restoration). It also relates to #7853 (Investigate and optimize the CI pipeline for large changes).

The dependency has been registered: this issue blocks Epic #2810.

**Parent Epic:** This issue is a child of Epic #2810 (CI Quality Gates Restoration). It also relates to #7853 (Investigate and optimize the CI pipeline for large changes). The dependency has been registered: this issue blocks Epic #2810.
Owner

superseded by next cycle

superseded by next cycle
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8046
No description provided.