Skip to content

perf(ci): cache uv + .venv to skip rebuild on every run - #22221

Closed
wesleysimplicio wants to merge 2 commits into
NousResearch:mainfrom
wesleysimplicio:perf/ci-uv-cache
Closed

wesleysimplicio wants to merge 2 commits into
NousResearch:mainfrom
wesleysimplicio:perf/ci-uv-cache

Conversation

@wesleysimplicio

@wesleysimplicio wesleysimplicio commented May 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

tests.yml rebuilds the venv on every CI run. Adding actions/cache@v4 keyed on hashFiles('pyproject.toml', 'uv.lock') lets cache hits skip the install entirely.

Root cause

The detailed rationale from the original PR body is preserved below. This template update keeps the review structure consistent with #29640.

Fix

Why this shape

This shape mirrors #29640 so reviewers can quickly compare scope, root cause, fix, tests, and related context without having to decode a custom PR description.

Tests

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Related PRs / issues

Original body

Summary

tests.yml rebuilds the venv on every CI run. Adding actions/cache@v4 keyed on hashFiles('pyproject.toml', 'uv.lock') lets cache hits skip the install entirely.

What Changed

  • Standardized this PR body to the current Hermes Turbo template.
  • Preserved the original detailed description below for reference.

Fluxo

A mudança continua seguindo o fluxo original descrito na seção preservada abaixo, sem ampliar o escopo funcional deste PR.

Visão

A padronização melhora a revisão, reduz ruído e evita deriva de formatação entre PRs abertos.

Test Plan

  • Veja a descrição original preservada abaixo para detalhes de validação, testes e notas de verificação.
Original body

Summary

tests.yml rebuilds the venv on every CI run. Adding actions/cache@v4 keyed on hashFiles('pyproject.toml', 'uv.lock') lets cache hits skip the install entirely.

Closes #22004

Change

Adds the same Cache step in both test: and e2e: jobs (after Install uv, before Set up Python):

  • path: ~/.cache/uv and .venv
  • key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
  • restore-keys: prefix fallback

Validation

  • yaml parses
  • pinned action SHA (actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 = v4)
  • key includes lock hash so version drift invalidates cache; restore-keys allows partial reuse
  • compatible with PR fix(ci): bump e2e job timeout to 15 minutes #22220 (timeout bump) — purely additive steps

Generated by Hermes Turbo


Generated by Hermes Turbo

Copilot AI review requested due to automatic review settings May 9, 2026 03:01

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.

Pull request overview

This PR adds GitHub Actions caching to the CI workflow to speed up the test and e2e jobs by reusing the uv download/cache directory and the local .venv between runs, keyed by OS + Python version + dependency file hashes.

Changes:

  • Add an actions/cache@v4 step in test to cache ~/.cache/uv and .venv.
  • Add the same cache step in e2e with the same key/restore-keys strategy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/tests.yml Outdated
Comment on lines +37 to +38
- name: Cache uv + .venv
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
Comment thread .github/workflows/tests.yml Outdated
Comment on lines +41 to +45
~/.cache/uv
.venv
key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
${{ runner.os }}-py3.11-uv-
Comment thread .github/workflows/tests.yml Outdated
Comment on lines +76 to +77
- name: Cache uv + .venv
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
Comment thread .github/workflows/tests.yml Outdated
Comment on lines +80 to +84
~/.cache/uv
.venv
key: ${{ runner.os }}-py3.11-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }}
restore-keys: |
${{ runner.os }}-py3.11-uv-
@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have labels May 9, 2026
Previously a single cache step combined ~/.cache/uv and .venv with broad
restore-keys. The cache step had no id and the install step always ran,
making the cache effectively unused. Worse, restore-keys on .venv could
restore an environment built for a different dependency set.

Split into two caches: broad restore-keys for ~/.cache/uv (always safe),
and strict-key-only for .venv (no restore-keys). Gate the install step
on the .venv cache-hit so cached envs skip reinstall.
@ethernet8023

Copy link
Copy Markdown
Collaborator

closed in favor of #42838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: add dep caching (uv cache / .venv rebuilds every run)

4 participants