Skip to content

Commit 114b79b

Browse files
committed
Update noxfile
1 parent a8d069a commit 114b79b

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

noxfile.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ def lint(session: nox.Session) -> None:
6060

6161
def _cleanup(session: nox.Session) -> None:
6262
"""Remove this session's virtualenv to save disk space in CI."""
63-
venv_dir = session.virtualenv.location
64-
if venv_dir and pathlib.Path(venv_dir).exists():
65-
shutil.rmtree(venv_dir, ignore_errors=True)
66-
session.log(f"Cleaned up {venv_dir}")
67-
shutil.rmtree(pathlib.Path("~/.cache").expanduser(), ignore_errors=True)
68-
# Clean GitHub Actions temp cache
69-
gha_temp = pathlib.Path("/home/runner/work/_temp/setup-uv-cache")
70-
if gha_temp.exists():
71-
shutil.rmtree(gha_temp, ignore_errors=True)
72-
session.log(f"Cleaned GitHub Actions uv temp cache at {gha_temp}")
63+
version = session.python
64+
if version != "3.13": # keep cache for last run
65+
venv_dir = session.virtualenv.location
66+
if venv_dir and pathlib.Path(venv_dir).exists():
67+
shutil.rmtree(venv_dir, ignore_errors=True)
68+
session.log(f"Cleaned up {venv_dir}")
69+
shutil.rmtree(pathlib.Path("~/.cache").expanduser(), ignore_errors=True)
70+
gha_temp = pathlib.Path("/home/runner/work/_temp/setup-uv-cache")
71+
if gha_temp.exists():
72+
shutil.rmtree(gha_temp, ignore_errors=True)
73+
session.log(f"Cleaned GitHub Actions uv temp cache at {gha_temp}")
7374

7475

7576
def _run_tests(
@@ -90,7 +91,6 @@ def _run_tests(
9091
"uv",
9192
"run",
9293
"--no-dev",
93-
"--no-cache",
9494
"--group",
9595
"test",
9696
*install_args,
@@ -106,6 +106,8 @@ def _run_tests(
106106
def tests(session: nox.Session) -> None:
107107
"""Run the test suite."""
108108
_run_tests(session)
109+
if os.environ.get("CI"):
110+
_cleanup(session)
109111

110112

111113
@nox.session(reuse_venv=True, venv_backend="uv", python=PYTHON_ALL_VERSIONS)
@@ -119,6 +121,8 @@ def minimums(session: nox.Session) -> None:
119121
)
120122
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
121123
session.run("uv", "tree", "--frozen", env=env)
124+
if os.environ.get("CI"):
125+
_cleanup(session)
122126

123127

124128
@nox.session(reuse_venv=True)

0 commit comments

Comments
 (0)