TEST-INFRA: [ci-execution-time] Implement caching for Nox virtual environments #7425

Open
opened 2026-04-10 19:12:49 +00:00 by HAL9000 · 3 comments
Owner

Metadata

  • Branch: task/ci-execution-time-nox-venv-caching
  • Commit Message: chore(ci): cache .nox virtual environments between CI runs to reduce setup time
  • Milestone: N/A — Backlog (see note below)
  • Parent Epic: #1678

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Summary

The CI pipeline does not cache the Nox virtual environments. This means that for every job, Nox has to create a new virtual environment and install all the dependencies from scratch. This is a major source of slowdowns, especially for jobs that have a large number of dependencies.

Current Behavior

Every CI job creates a fresh Nox virtual environment by installing all dependencies from scratch. This results in:

  • Significant time spent on pip install for every CI run, even when dependencies have not changed.
  • Increased CI execution time across all jobs that use Nox sessions.
  • Wasted runner resources re-downloading and re-installing identical dependency sets.

Expected Behavior

The .nox directory should be cached between CI runs using the actions/cache action. When dependencies have not changed (i.e., pyproject.toml and lock files are unchanged), the cached virtual environments should be restored, skipping the install step entirely.

Acceptance Criteria

  • The .nox directory is cached between CI runs using actions/cache.
  • The cache key is based on the OS, Python version, and a hash of pyproject.toml (and lock files if present).
  • The time to set up the Nox environment is significantly reduced on cache hits.
  • The overall CI execution time is measurably reduced.
  • The caching logic is documented with a comment in the workflow file.

Supporting Information

  • Related issues: #7421 (Run E2E tests on a less frequent schedule), #1678 (Epic: CI Execution Time Optimization).
  • The .nox directory is the standard location where Nox stores its virtual environments.
  • Cache invalidation should be triggered by changes to pyproject.toml or dependency lock files.

Subtasks

  • Review the current CI workflow (.forgejo/workflows/ci.yml) to identify all jobs that invoke Nox.
  • Add a actions/cache step before the Nox invocation in each relevant job, caching the .nox directory.
  • Define a cache key using ${{ runner.os }}-nox-${{ hashFiles('pyproject.toml') }} (or equivalent including lock files).
  • Add a restore-keys fallback for partial cache hits.
  • Add a comment in the workflow file explaining the caching strategy and cache key rationale.
  • Update features/ci_workflow_validation.feature to assert the cache step is present for Nox jobs.
  • Run nox (all default sessions), fix any errors.
  • Verify coverage >= 97% via nox -s coverage_report.

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, 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.
  • 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: new-issue-creator

## Metadata - **Branch**: `task/ci-execution-time-nox-venv-caching` - **Commit Message**: `chore(ci): cache .nox virtual environments between CI runs to reduce setup time` - **Milestone**: N/A — Backlog (see note below) - **Parent Epic**: #1678 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Summary The CI pipeline does not cache the Nox virtual environments. This means that for every job, Nox has to create a new virtual environment and install all the dependencies from scratch. This is a major source of slowdowns, especially for jobs that have a large number of dependencies. ## Current Behavior Every CI job creates a fresh Nox virtual environment by installing all dependencies from scratch. This results in: - Significant time spent on `pip install` for every CI run, even when dependencies have not changed. - Increased CI execution time across all jobs that use Nox sessions. - Wasted runner resources re-downloading and re-installing identical dependency sets. ## Expected Behavior The `.nox` directory should be cached between CI runs using the `actions/cache` action. When dependencies have not changed (i.e., `pyproject.toml` and lock files are unchanged), the cached virtual environments should be restored, skipping the install step entirely. ## Acceptance Criteria - [ ] The `.nox` directory is cached between CI runs using `actions/cache`. - [ ] The cache key is based on the OS, Python version, and a hash of `pyproject.toml` (and lock files if present). - [ ] The time to set up the Nox environment is significantly reduced on cache hits. - [ ] The overall CI execution time is measurably reduced. - [ ] The caching logic is documented with a comment in the workflow file. ## Supporting Information - Related issues: #7421 (Run E2E tests on a less frequent schedule), #1678 (Epic: CI Execution Time Optimization). - The `.nox` directory is the standard location where Nox stores its virtual environments. - Cache invalidation should be triggered by changes to `pyproject.toml` or dependency lock files. ## Subtasks - [ ] Review the current CI workflow (`.forgejo/workflows/ci.yml`) to identify all jobs that invoke Nox. - [ ] Add a `actions/cache` step before the Nox invocation in each relevant job, caching the `.nox` directory. - [ ] Define a cache key using `${{ runner.os }}-nox-${{ hashFiles('pyproject.toml') }}` (or equivalent including lock files). - [ ] Add a restore-keys fallback for partial cache hits. - [ ] Add a comment in the workflow file explaining the caching strategy and cache key rationale. - [ ] Update `features/ci_workflow_validation.feature` to assert the cache step is present for Nox jobs. - [ ] Run `nox` (all default sessions), fix any errors. - [ ] Verify coverage >= 97% via `nox -s coverage_report`. ## 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, 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. - 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: new-issue-creator
Author
Owner

Verified — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium.


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

✅ **Verified** — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Verified — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium.


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

✅ **Verified** — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Author
Owner

Verified — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium.


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

✅ **Verified** — CI optimization: Nox virtual environment caching. MoSCoW: Should-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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#7425
No description provided.