[AUTO-INF-1] ci: move uv cache step before pip install to enable uv/nox bootstrap caching #10037

Open
opened 2026-04-16 13:53:05 +00:00 by HAL9000 · 0 comments
Owner

Summary

In every CI job, uv and nox are installed via pip install -q uv nox before the actions/cache step for the uv package cache is configured. This ordering means the uv bootstrap itself is never cached — uv and nox are re-downloaded and re-installed from PyPI on every single job invocation, adding 5–15 seconds of overhead per job across all 9 Python-based CI jobs.

Current State

In .forgejo/workflows/ci.yml, every job follows this pattern:

- name: Install uv and nox
  run: |
    pip install -q uv==${{ env.UV_VERSION }} nox   # ← runs BEFORE cache is set up

- name: Cache uv packages
  uses: actions/cache@v3
  with:
    path: ~/.cache/uv
    key: uv-${{ hashFiles('pyproject.toml') }}
    restore-keys: |
      uv-

Because the cache step comes after the install step, the cache is only used for packages installed by uv (project dependencies), not for uv or nox themselves. The pip install uv nox step always runs from scratch.

Proposed Improvement

Reorder the steps so the cache is restored before the pip install, and add ~/.cache/pip to the cache path so the pip-installed uv/nox wheels are also cached:

- name: Cache pip and uv packages
  uses: actions/cache@v3
  with:
    path: |
      ~/.cache/pip
      ~/.cache/uv
    key: uv-${{ env.UV_VERSION }}-${{ hashFiles('pyproject.toml') }}
    restore-keys: |
      uv-${{ env.UV_VERSION }}-
      uv-

- name: Install uv and nox
  run: |
    pip install -q uv==${{ env.UV_VERSION }} nox

This change should be applied consistently across all jobs in ci.yml and nightly-quality.yml. The cache key includes UV_VERSION to ensure cache invalidation when the uv version pin changes.

Expected Impact

  • Time saved: ~5–15 seconds × 9 Python jobs = 45–135 seconds per CI run on cache hits
  • Consistency: The nightly quality workflow (nightly-quality.yml) uses a slightly different install pattern (uv pip install --system nox) — this issue also covers aligning that workflow to use the same cache strategy
  • No quality regression: No checks are disabled or weakened; only the ordering and cache scope are adjusted

Duplicate Check

  • Searched open issues (all 123 pages) for keywords: "uv cache", "pip cache", "CI timing", "CI speed", "CI performance", "workflow optimization", "pipeline optimization", "bootstrap", "AUTO-INF"
  • Searched closed issues (all 77 pages) for same keywords
  • Searched for AUTO-INF worker issues across all pages
  • Result: No duplicates found — zero matches for "CI Timing" across all open and closed issue pages

Automated by CleverAgents Bot
Supervisor: Test Infrastructure Pool | Agent: test-infra-pool-supervisor
Worker: [AUTO-INF-1] CI Timing Analysis


Automated by CleverAgents Bot
Agent: new-issue-creator

## Summary In every CI job, `uv` and `nox` are installed via `pip install -q uv nox` **before** the `actions/cache` step for the uv package cache is configured. This ordering means the uv bootstrap itself is never cached — uv and nox are re-downloaded and re-installed from PyPI on every single job invocation, adding 5–15 seconds of overhead per job across all 9 Python-based CI jobs. ## Current State In `.forgejo/workflows/ci.yml`, every job follows this pattern: ```yaml - name: Install uv and nox run: | pip install -q uv==${{ env.UV_VERSION }} nox # ← runs BEFORE cache is set up - name: Cache uv packages uses: actions/cache@v3 with: path: ~/.cache/uv key: uv-${{ hashFiles('pyproject.toml') }} restore-keys: | uv- ``` Because the cache step comes **after** the install step, the cache is only used for packages installed by uv (project dependencies), not for uv or nox themselves. The `pip install uv nox` step always runs from scratch. ## Proposed Improvement Reorder the steps so the cache is restored **before** the pip install, and add `~/.cache/pip` to the cache path so the pip-installed uv/nox wheels are also cached: ```yaml - name: Cache pip and uv packages uses: actions/cache@v3 with: path: | ~/.cache/pip ~/.cache/uv key: uv-${{ env.UV_VERSION }}-${{ hashFiles('pyproject.toml') }} restore-keys: | uv-${{ env.UV_VERSION }}- uv- - name: Install uv and nox run: | pip install -q uv==${{ env.UV_VERSION }} nox ``` This change should be applied consistently across all jobs in `ci.yml` and `nightly-quality.yml`. The cache key includes `UV_VERSION` to ensure cache invalidation when the uv version pin changes. ## Expected Impact - **Time saved**: ~5–15 seconds × 9 Python jobs = **45–135 seconds per CI run** on cache hits - **Consistency**: The nightly quality workflow (`nightly-quality.yml`) uses a slightly different install pattern (`uv pip install --system nox`) — this issue also covers aligning that workflow to use the same cache strategy - **No quality regression**: No checks are disabled or weakened; only the ordering and cache scope are adjusted ### Duplicate Check - Searched open issues (all 123 pages) for keywords: "uv cache", "pip cache", "CI timing", "CI speed", "CI performance", "workflow optimization", "pipeline optimization", "bootstrap", "AUTO-INF" - Searched closed issues (all 77 pages) for same keywords - Searched for AUTO-INF worker issues across all pages - Result: No duplicates found — zero matches for "CI Timing" across all open and closed issue pages --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure Pool | Agent: test-infra-pool-supervisor Worker: [AUTO-INF-1] CI Timing Analysis --- **Automated by CleverAgents Bot** Agent: new-issue-creator
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.

Dependencies

No dependencies set.

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