Skip to content

Commit 03914dc

Browse files
authored
Merge pull request #396 from opensafely-core/aw/renovate
Prepare for switching to Renovate
2 parents 87d9b91 + 808a211 commit 03914dc

5 files changed

Lines changed: 25 additions & 118 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

DEVELOPERS.md

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -66,54 +66,18 @@ just docker/build-for-os-cli
6666

6767
## Dependency management
6868
Dependencies are managed with `uv`.
69-
70-
### Overview
7169
See the [uv documentation](https://docs.astral.sh/uv/concepts/projects/dependencies) for details on usage.
72-
Commands for adding, removing or modifying constraints of dependencies will automatically respect the
73-
global timestamp cutoff specified in the `pyproject.toml`:
74-
```toml
75-
[tool.uv]
76-
exclude-newer = "YYYY-MM-DDTHH:MM:SSZ"
77-
```
70+
7871
Changes to dependencies should be made via `uv` commands, or by modifying `pyproject.toml` directly followed by
7972
[locking and syncing](https://docs.astral.sh/uv/concepts/projects/sync/) via `uv` or `just` commands like
8073
`just devenv` or `just upgrade-all`. You should not modify `uv.lock` manually.
8174

8275
Note that `uv.lock` must be reproducible from `pyproject.toml`. Otherwise, `just check` will fail.
83-
If `just check` errors saying that the timestamps must match, you might have modified one file but not the other:
76+
If `just check` errors, you might have modified one file but not the other:
8477
- If you modified `pyproject.toml`, you must update `uv.lock` via `uv lock` / `just upgrade-all` or similar.
8578
- If you did not modify `pyproject.toml` but have changes in `uv.lock`, you should revert the changes to `uv.lock`,
8679
modify `pyproject.toml` as you require, then run `uv lock` to update `uv.lock`.
8780

88-
The timestamp cutoff should usually be set to midnight UTC of a past date.
89-
In general, the date is expected to be between 7 and 14 days ago as a result of automated weekly dependency updates.
90-
91-
If you require a package version that is newer than the cutoff allows, you can either manually bump the global cutoff
92-
date or add a package-specific timestamp cutoff. Both options are described below.
93-
94-
### Manually bumping the cutoff date
95-
The cutoff timestamp can be modified to a more recent date either manually in the `pyproject.toml`
96-
or with `just bump-uv-cutoff <days-ago>`.
97-
For example, to set the cutoff to today's date and upgrade all dependencies, run:
98-
```
99-
just bump-uv-cutoff 0
100-
just upgrade-all
101-
```
102-
103-
### Adding a package-specific timestamp cutoff
104-
It is possible to specify a package-specific timestamp cutoff in addition to the global cutoff.
105-
This should be done in the `pyproject.toml` to ensure reproducible installs;
106-
see the [uv documentation](https://docs.astral.sh/uv/reference/settings/#exclude-newer-package) for details.
107-
If set, the package-specific cutoff will take precedence over the global cutoff regardless of which one is more recent.
108-
109-
You should not set a package-specific cutoff that is older than the global cutoff - use a version
110-
constraint instead.
111-
If there is good reason to set a package-specific cutoff that is more recent than the global cutoff,
112-
**care should be taken to ensure that the package-specific cutoff is manually removed once it is over 7 days old**,
113-
as otherwise future automated updates of that package will be indefinitely blocked.
114-
Currently no automated tooling is in place to enforce removal of stale package-specific cutoffs.
115-
116-
11781
## Tagging a new version
11882

11983
OpenSAFELY SQL Runner follows [Semantic Versioning, v2.0.0][2].

justfile

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,20 @@ install-precommit:
3333
upgrade-package package: && uvmirror devenv
3434
uv lock --upgrade-package {{ package }}
3535

36-
# Upgrade all packages to the latest versions as of the cutoff in pyproject.toml
37-
upgrade-all: && uvmirror devenv
38-
uv lock --upgrade
36+
# Upgrade all packages to the latest versions
37+
upgrade-all cooldown="7 days ago": && devenv
38+
uv lock --upgrade --exclude-newer "{{ cooldown }}"
3939

4040
# update the uv mirror requirements file
4141
uvmirror file="requirements.uvmirror.txt":
4242
rm -f {{ file }}
4343
uv export --format requirements-txt --frozen --no-hashes --all-groups --all-extras > {{ file }}
4444

45-
# Move the cutoff date in pyproject.toml to N days ago (default: 7) at midnight UTC
46-
bump-uv-cutoff days="7":
47-
#!/usr/bin/env -S uvx --with tomlkit python3.13
48-
# Note we specify the python version here and we don't care if it's different to
49-
# the .python-version; we need 3.11+ for the datetime code used.
50-
51-
import datetime
52-
import tomlkit
53-
54-
with open("pyproject.toml", "rb") as f:
55-
content = tomlkit.load(f)
56-
57-
new_datetime = (
58-
datetime.datetime.now(datetime.UTC) - datetime.timedelta(days=int("{{ days }}"))
59-
).replace(hour=0, minute=0, second=0, microsecond=0)
60-
new_timestamp = new_datetime.strftime("%Y-%m-%dT%H:%M:%SZ")
61-
if existing_timestamp := content["tool"]["uv"].get("exclude-newer"):
62-
if new_datetime < datetime.datetime.fromisoformat(existing_timestamp):
63-
print(
64-
f"Existing cutoff {existing_timestamp} is more recent than {new_timestamp}, not updating."
65-
)
66-
exit(0)
67-
content["tool"]["uv"]["exclude-newer"] = new_timestamp
68-
69-
with open("pyproject.toml", "w") as f:
70-
tomlkit.dump(content, f)
71-
7245
# This is the default input command to update-dependencies action
7346
# https://github.com/bennettoxford/update-dependencies-action
7447

75-
# Bump the timestamp cutoff to midnight UTC 7 days ago and upgrade all dependencies
76-
update-dependencies: bump-uv-cutoff upgrade-all
48+
# recipe is used for doing lockfileMaintenance via update-dependencies action, until min release age is respected fo uv
49+
update-dependencies: upgrade-all && uvmirror
7750

7851
# *args is variadic, 0 or more. This allows us to do `just test -k match`, for example.
7952

@@ -128,14 +101,10 @@ check:
128101
check-lockfile:
129102
#!/usr/bin/env bash
130103
set -euo pipefail
131-
# Make sure dates in pyproject.toml and uv.lock are in sync
104+
# Make sure lockfile is reproducible from pyproject.toml
132105
unset UV_EXCLUDE_NEWER
133106
rc=0
134-
uv lock --check || rc=$?
135-
if test "$rc" != "0" ; then
136-
echo "Timestamp cutoffs in uv.lock must match those in pyproject.toml. See DEVELOPERS.md for details and hints." >&2
137-
exit $rc
138-
fi
107+
uv lock --check
139108
140109
# Fix formatting, import sort ordering, and justfile
141110
fix:

pyproject.toml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
requires-python = ">=3.14"
77

88
dependencies = [
9-
"pymssql",
10-
"structlog",
11-
"sqlglot",
9+
"pymssql<=2.3.13",
10+
"sqlglot<=30.6.0",
11+
"structlog<=25.5.0",
1212
]
1313

1414
[tool.coverage.run]
@@ -56,17 +56,11 @@ extend-ignore = [
5656
]
5757
isort.lines-after-imports = 2
5858

59-
# Note: any `exclude-newer-package` timestamps should be removed if > 7 days old
60-
# See https://github.com/opensafely-core/repo-template/blob/main/DEVELOPERS.md for details
61-
[tool.uv]
62-
exclude-newer = "2026-04-29T00:00:00Z"
63-
exclude-newer-package = {}
64-
6559
[dependency-groups]
6660
dev = [
67-
"coverage",
68-
"docker",
69-
"pre-commit",
70-
"pytest",
71-
"ruff",
61+
"coverage<=7.13.5",
62+
"docker<=7.1.0",
63+
"pre-commit<=4.6.0",
64+
"pytest<=9.0.3",
65+
"ruff<=0.15.12",
7266
]

uv.lock

Lines changed: 8 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)