-
Notifications
You must be signed in to change notification settings - Fork 37
chore(deps)!: 7-day dependency cooldown (uv exclude-newer + CI assert) #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
edfa207
74a8a5c
61d9505
7b92cbd
ea645df
a4ffe46
40d71b3
7facf57
151c63d
44133f5
956dde4
2b61256
0ac135c
0edbd8c
7a0fd9d
c2fe731
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||||||||||
| """Hard rule: the dependency cooldown — never resolve to a release younger than | ||||||||||||||||||||||
| a 7-day window. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| `[tool.uv] exclude-newer` in pyproject caps every `uv lock` at a fixed timestamp. | ||||||||||||||||||||||
| This test fails if that timestamp is ever within the last 7 days, so the lock can | ||||||||||||||||||||||
| never include a brand-new (and thus less-vetted) release. When you intentionally | ||||||||||||||||||||||
| take dependency updates, advance `exclude-newer` to a date still >= 7 days in the | ||||||||||||||||||||||
| past. A genuinely urgent (e.g. security) fix younger than the cap is allowed only | ||||||||||||||||||||||
| via an explicit, commented `[tool.uv.exclude-newer-package]` override. | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| from __future__ import annotations | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import datetime | ||||||||||||||||||||||
| import tomllib | ||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| COOLDOWN_DAYS = 7 | ||||||||||||||||||||||
| _PYPROJECT = Path(__file__).resolve().parents[1] / "pyproject.toml" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def test_uv_exclude_newer_enforces_dependency_cooldown() -> None: | ||||||||||||||||||||||
| cfg = tomllib.loads(_PYPROJECT.read_text(encoding="utf-8")) | ||||||||||||||||||||||
| raw = cfg.get("tool", {}).get("uv", {}).get("exclude-newer") | ||||||||||||||||||||||
| assert raw, ( | ||||||||||||||||||||||
| "[tool.uv] exclude-newer is missing from pyproject.toml — it enforces the " | ||||||||||||||||||||||
| f"{COOLDOWN_DAYS}-day dependency cooldown and must be set." | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| cutoff = datetime.datetime.fromisoformat(str(raw).replace("Z", "+00:00")) | ||||||||||||||||||||||
| if cutoff.tzinfo is None: | ||||||||||||||||||||||
| cutoff = cutoff.replace(tzinfo=datetime.UTC) | ||||||||||||||||||||||
| age = datetime.datetime.now(datetime.UTC) - cutoff | ||||||||||||||||||||||
| assert age >= datetime.timedelta(days=COOLDOWN_DAYS), ( | ||||||||||||||||||||||
| f"[tool.uv] exclude-newer ({raw}) is only {age.days}d old; the dependency " | ||||||||||||||||||||||
| f"cooldown requires it to be >= {COOLDOWN_DAYS} days in the past. Bump it " | ||||||||||||||||||||||
| f"to an older date (>= {COOLDOWN_DAYS}d ago) when taking dependency updates." | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The test guards
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in
Comment on lines
+50
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In environments that still have uv 0.7.x, this new table is an unknown
[tool.uv]key:uv sync --lockedreportsunknown field exclude-newer-package, ignores the lockfile cutoff as removed, and tries to re-resolve from PyPI instead of installing the committed lock. Since the repo only requires users to haveuvand does not settool.uv.required-version, local setup and any older CI image can fail or bypass the intended cooldown; pin/install a uv version that supports per-package cutoffs before relying on this syntax.Useful? React with 👍 / 👎.