TEST-INFRA: [ci-execution-time] Optimize uv cache keys for better cache hits #1861

Open
opened 2026-04-03 00:00:12 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: chore/ci-uv-cache-key-optimization
  • Commit Message: chore(ci): optimize uv cache keys to hash only dependency sections
  • Milestone: v3.8.0
  • Parent Epic: #1678

Background and Context

The current CI pipeline uses hashFiles('pyproject.toml') as the cache key for uv packages. While this is a reasonable starting point, pyproject.toml contains far more than just dependency declarations (e.g., build configuration, tool settings, metadata). As a result, the cache is invalidated whenever any part of pyproject.toml changes — even changes completely unrelated to dependencies — causing unnecessary full re-installs and increasing CI execution time.

Expected Behavior

The uv cache keys should be scoped specifically to the [project.dependencies] and [project.optional-dependencies] sections of pyproject.toml. This ensures the cache is only invalidated when the actual dependency set changes, maximising cache hit rates and reducing CI pipeline execution time.

Acceptance Criteria

  • The uv cache keys are derived from only the dependency-relevant sections of pyproject.toml.
  • Cache hits are observed when non-dependency sections of pyproject.toml are modified.
  • The CI pipeline execution time is measurably reduced as a result of improved cache hit rates.

Supporting Information

  • Parent Epic: #1678 — CI Execution Time Optimization — Timeouts, Concurrency, and Coverage Artifact Sharing
  • The extraction script should parse pyproject.toml (TOML format) and output a stable, deterministic string of the dependency sections for hashing.

Subtasks

  • Write a script (e.g., scripts/extract_deps_hash.py) to extract [project.dependencies] and [project.optional-dependencies] from pyproject.toml and output a stable string for hashing
  • Update CI workflow(s) to use the output of this script as the uv cache key instead of hashFiles('pyproject.toml')
  • Verify cache hits occur when non-dependency fields in pyproject.toml are changed
  • Tests (Behave): Add scenario(s) verifying the cache key extraction script produces correct, stable output
  • Tests (Robot): Add integration test confirming CI cache behaviour with the new key strategy
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), 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 the Commit Message in Metadata exactly (chore(ci): optimize uv cache keys to hash only dependency sections), followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (chore/ci-uv-cache-key-optimization).
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `chore/ci-uv-cache-key-optimization` - **Commit Message**: `chore(ci): optimize uv cache keys to hash only dependency sections` - **Milestone**: v3.8.0 - **Parent Epic**: #1678 ## Background and Context The current CI pipeline uses `hashFiles('pyproject.toml')` as the cache key for `uv` packages. While this is a reasonable starting point, `pyproject.toml` contains far more than just dependency declarations (e.g., build configuration, tool settings, metadata). As a result, the cache is invalidated whenever *any* part of `pyproject.toml` changes — even changes completely unrelated to dependencies — causing unnecessary full re-installs and increasing CI execution time. ## Expected Behavior The `uv` cache keys should be scoped specifically to the `[project.dependencies]` and `[project.optional-dependencies]` sections of `pyproject.toml`. This ensures the cache is only invalidated when the actual dependency set changes, maximising cache hit rates and reducing CI pipeline execution time. ## Acceptance Criteria - The `uv` cache keys are derived from only the dependency-relevant sections of `pyproject.toml`. - Cache hits are observed when non-dependency sections of `pyproject.toml` are modified. - The CI pipeline execution time is measurably reduced as a result of improved cache hit rates. ## Supporting Information - Parent Epic: #1678 — CI Execution Time Optimization — Timeouts, Concurrency, and Coverage Artifact Sharing - The extraction script should parse `pyproject.toml` (TOML format) and output a stable, deterministic string of the dependency sections for hashing. ## Subtasks - [ ] Write a script (e.g., `scripts/extract_deps_hash.py`) to extract `[project.dependencies]` and `[project.optional-dependencies]` from `pyproject.toml` and output a stable string for hashing - [ ] Update CI workflow(s) to use the output of this script as the `uv` cache key instead of `hashFiles('pyproject.toml')` - [ ] Verify cache hits occur when non-dependency fields in `pyproject.toml` are changed - [ ] Tests (Behave): Add scenario(s) verifying the cache key extraction script produces correct, stable output - [ ] Tests (Robot): Add integration test confirming CI cache behaviour with the new key strategy - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), 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 the Commit Message in Metadata exactly (`chore(ci): optimize uv cache keys to hash only dependency sections`), followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`chore/ci-uv-cache-key-optimization`). - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-03 00:00:19 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

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