Skip to content

Commit 57ec022

Browse files
committed
Replace dependabot with renovate
1 parent 17daee5 commit 57ec022

File tree

5 files changed

+134
-29
lines changed

5 files changed

+134
-29
lines changed

.github/dependabot.yml

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

renovate.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"lockFileMaintenance": {
7+
"description": "Keep uv.lock up to date, merging if tests pass",
8+
"enabled": true,
9+
"automerge": true
10+
},
11+
"pre-commit": {
12+
"enabled": true
13+
},
14+
"packageRules": [
15+
{
16+
"description": "Disable python version as that is managed by python-copier-template",
17+
"matchManagers": [
18+
"pyenv"
19+
],
20+
"enabled": false
21+
},
22+
{
23+
"description": "Group non-major github action updates",
24+
"groupName": "GitHub Actions",
25+
"matchUpdateTypes": [
26+
"patch",
27+
"minor"
28+
],
29+
"matchManagers": [
30+
"github-actions"
31+
]
32+
}
33+
]
34+
}

template/renovate.json.jinja

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
],
6+
"lockFileMaintenance": {
7+
"description": "Keep uv.lock up to date, merging if tests pass",
8+
"enabled": true,
9+
"automerge": true
10+
},
11+
"packageRules": [
12+
{
13+
"description": "Disable python version as that is managed by python-copier-template",
14+
"matchManagers": [
15+
"pyenv"
16+
],
17+
"enabled": false
18+
},
19+
{
20+
"description": "Disable github actions that are managed by python-copier-template",
21+
"matchPackageNames": [
22+
"actions/checkout",
23+
"astral-sh/setup-uv",
24+
"actions/upload-artifact",
25+
"actions/download-artifact",
26+
"softprops/action-gh-release",
27+
"codecov/codecov-action"{% if docker %},
28+
"docker/setup-buildx-action",
29+
"docker/login-action",
30+
"docker/build-push-action",
31+
"docker/metadata-action"{% endif %}{% if pypi %},
32+
"pypa/gh-action-pypi-publish"{% endif %}{% if sphinx %},
33+
"peaceiris/actions-gh-pages"{% endif %}
34+
],
35+
"matchManagers": [
36+
"github-actions"
37+
],
38+
"enabled": false
39+
}
40+
]
41+
}

template/{% if git_platform=="github.com" %}.github{% endif %}/dependabot.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test_example.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import functools
2+
import json
23
import shlex
34
import subprocess
5+
import tomllib
46
from collections.abc import Callable
57
from pathlib import Path
68

@@ -327,3 +329,60 @@ def test_catalog_info(tmp_path: Path):
327329
"owner": "group:default/daq",
328330
},
329331
}
332+
333+
334+
@pytest.mark.parametrize(
335+
"override",
336+
[
337+
{},
338+
{"docker": True},
339+
{"docker": True, "docker_debug": True},
340+
{"pypi": True},
341+
{"docs_type": "sphinx"},
342+
],
343+
)
344+
def test_renovate_actions_match_what_is_shipped(override: dict, tmp_path: Path):
345+
# Generate a project with the given answers
346+
answers = {
347+
"docker": False,
348+
"docker_debug": False,
349+
"pypi": False,
350+
"docs_type": "README",
351+
}
352+
answers.update(override)
353+
copy_project(tmp_path, **answers)
354+
# Find the GitHub actions ignored by renovate
355+
renovate_config_path = tmp_path / "renovate.json"
356+
renovate_config = json.loads(renovate_config_path.read_text())
357+
config_github_actions = set(renovate_config["packageRules"][1]["matchPackageNames"])
358+
# Find the GitHub actions actually used in the workflows
359+
used_github_actions = set[str]()
360+
for workflow_file in (tmp_path / ".github" / "workflows").glob("*.yml"):
361+
workflow = yaml.safe_load(workflow_file.read_text())
362+
for job in workflow.get("jobs", {}).values():
363+
for step in job.get("steps", []):
364+
action = step.get("uses")
365+
if action:
366+
used_github_actions.add(action.split("@")[0])
367+
# Check they match
368+
assert used_github_actions == config_github_actions
369+
370+
371+
def test_python_versions_match(tmp_path: Path):
372+
copy_project(tmp_path)
373+
# Grab the python versions from ci.yml
374+
ci_yaml = tmp_path / ".github" / "workflows" / "ci.yml"
375+
workflow = yaml.safe_load(ci_yaml.read_text())
376+
python_versions = workflow["jobs"]["test"]["strategy"]["matrix"]["python-version"]
377+
# Check .python-version is the first of these
378+
python_version_file = tmp_path / ".python-version"
379+
min_version = python_version_file.read_text().strip()
380+
assert python_versions[0] == min_version
381+
# Check pyproject.toml has correct requires-python and classifiers
382+
pyproject_toml = tomllib.loads((tmp_path / "pyproject.toml").read_text())
383+
assert pyproject_toml["project"]["requires-python"] == f">={min_version}"
384+
for version in python_versions:
385+
assert (
386+
f"Programming Language :: Python :: {version}"
387+
in pyproject_toml["project"]["classifiers"]
388+
)

0 commit comments

Comments
 (0)