Skip to content

Commit 31940ff

Browse files
authored
feat: groups for dependabot (#348)
* ci: group dependabot updates Signed-off-by: Henry Schreiner <[email protected]> * feat: grouped updates for Dependabot Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 46f8858 commit 31940ff

File tree

5 files changed

+51
-3
lines changed

5 files changed

+51
-3
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "daily"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ for family, grp in itertools.groupby(collected.checks.items(), key=lambda x: x[1
348348
- [`GH200`](https://learn.scientific-python.org/development/guides/gha-basic#GH200): Maintained by Dependabot
349349
- [`GH210`](https://learn.scientific-python.org/development/guides/gha-basic#GH210): Maintains the GitHub action versions with Dependabot
350350
- [`GH211`](https://learn.scientific-python.org/development/guides/gha-basic#GH211): Do not pin core actions as major versions
351+
- [`GH212`](https://learn.scientific-python.org/development/guides/gha-basic#GH212): Require GHA update grouping
351352

352353
### MyPy
353354
- [`MY100`](https://learn.scientific-python.org/development/guides/style#MY100): Uses MyPy (pyproject config)

docs/pages/guides/gha_basic.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,20 @@ updates:
142142
directory: "/"
143143
schedule:
144144
interval: "weekly"
145+
groups:
146+
actions:
147+
patterns:
148+
- "*"
145149
```
146150

147151
This will check to see if there are updates to the action weekly, and will make
148152
a PR if there are updates, including the changelog and commit summary in the PR.
149153
If you select a name like `v1`, this should only look for updates of the same
150154
form (since April 2022) - there is no need to restrict updates for "moving tag"
151-
updates anymore {% rr PY006 %}. You can also use SHA's and dependabot will
152-
respect that too.
155+
updates anymore {% rr GH211 %}. You can also use SHA's and dependabot will
156+
respect that too. And `groups` will combine actions updates {% rr GH212 %},
157+
which is both cleaner and sometimes required for dependent actions, like
158+
`upload-artifact`/`download-artifact`.
153159

154160
You can use this for other ecosystems too, including Python.
155161

src/sp_repo_review/checks/github.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ def check(dependabot: dict[str, Any]) -> bool:
149149
- package-ecosystem: "github-actions"
150150
directory: "/"
151151
schedule:
152-
interval: "weekly"
152+
interval: "weekly"
153+
groups:
154+
actions:
155+
patterns:
156+
- "*"
153157
```
154158
"""
155159
for ecosystem in dependabot.get("updates", []):
@@ -179,5 +183,34 @@ def check(dependabot: dict[str, Any]) -> bool:
179183
return True
180184

181185

186+
class GH212(GitHub):
187+
"Require GHA update grouping"
188+
189+
requires = {"GH200", "GH210"}
190+
url = mk_url("gha-basic")
191+
192+
@staticmethod
193+
def check(dependabot: dict[str, Any]) -> bool:
194+
"""
195+
Projects should group their updates to avoid extra PRs and stay in sync.
196+
This is now supported by dependabot since June 2023.
197+
198+
```yaml
199+
groups:
200+
actions:
201+
patterns:
202+
- "*"
203+
```
204+
"""
205+
206+
for ecosystem in dependabot.get("updates", []):
207+
if (
208+
ecosystem.get("package-ecosystem", "") == "github-actions"
209+
and "groups" not in ecosystem
210+
):
211+
return False
212+
return True
213+
214+
182215
def repo_review_checks() -> dict[str, GitHub]:
183216
return {p.__name__: p() for p in GitHub.__subclasses__()}

{{cookiecutter.project_name}}/.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

0 commit comments

Comments
 (0)