Skip to content

Commit 17a4828

Browse files
authored
Exclude frequenz-repo-config from dependabot grouping (#368)
Since we are still in development (at branch v0.x.x), breaking changes can be introduced by minor (and even patch) updates, blocking many dependabot PRs as updates of this library fail or need manual intervention. With this `frequenz-repo-config` updates will be done in a separate PR. Fixes #366.
2 parents e77f220 + 1f33af3 commit 17a4828

File tree

9 files changed

+324
-85
lines changed

9 files changed

+324
-85
lines changed

.github/dependabot.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,36 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# Group production and development (required and optional in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
28-
optional:
29-
dependency-type: "development"
29+
exclude-patterns:
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3033
update-types:
3134
- "minor"
32-
- "patch"
35+
exclude-patterns:
36+
- "async-solipsism"
37+
- "markdown-callouts"
38+
- "mkdocs-gen-files"
39+
- "mkdocs-literate-nav"
40+
- "mkdocstrings*"
41+
- "pydoclint"
42+
- "pytest-asyncio"
43+
mkdocstrings:
44+
patterns:
45+
- "mkdocstrings*"
3346

3447
- package-ecosystem: "github-actions"
3548
directory: "/"

RELEASE_NOTES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ But you might still need to adapt your code:
2626

2727
### Cookiecutter template
2828

29-
<!-- Here new features for cookiecutter specifically -->
29+
- Dependabot config now uses a new grouping that should make upgrades more smooth.
30+
31+
* We group patch updates as they should always work.
32+
* We also group minor updates, as it works too for most libraries, typically except libraries that don't have a stable release yet (v0.x.x branch), so we make some exceptions for them.
33+
* Major updates and dependencies excluded by the above groups are still managed, but they'll create one PR per dependency, as breakage is expected, so it might need manual intervention.
34+
* Finally, we group some dependencies that are related to each other, and usually needs to be updated together.
3035

3136
## Bug Fixes
3237

cookiecutter/migrate.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,107 @@ def main() -> None:
3232
"""Run the migration steps."""
3333
# Add a separation line like this one after each migration step.
3434
print("=" * 72)
35+
regroup_dependabot()
36+
print("=" * 72)
3537
print("Migration script finished. Remember to follow any manual instructions.")
3638
print("=" * 72)
3739

3840

41+
def regroup_dependabot() -> None:
42+
"""Use new dependabot groups to separate dependencies that break often."""
43+
print("Using new dependabot groups to separate dependencies that break often...")
44+
# Dependabot configuration file
45+
dependabot_file = Path(".github/dependabot.yml")
46+
47+
# Skip if the file doesn't exist
48+
if not dependabot_file.exists():
49+
manual_step(
50+
"Dependabot configuration file not found, not excluding "
51+
"frequenz-repo-config from group updates. Please consider adding a "
52+
"dependabot configuration file."
53+
)
54+
return
55+
56+
dependabot_content = dependabot_file.read_text(encoding="utf-8")
57+
58+
new_groups = """\
59+
# We group patch updates as they should always work.
60+
# We also group minor updates, as it works too for most libraries,
61+
# typically except libraries that don't have a stable release yet (v0.x.x
62+
# branch), so we make some exceptions for them.
63+
# Major updates and dependencies excluded by the above groups are still
64+
# managed, but they'll create one PR per dependency, as breakage is
65+
# expected, so it might need manual intervention.
66+
# Finally, we group some dependencies that are related to each other, and
67+
# usually need to be updated together.
68+
groups:
69+
patch:
70+
update-types:
71+
- "patch"
72+
exclude-patterns:
73+
# pydoclint has shipped breaking changes in patch updates often
74+
- "pydoclint"
75+
minor:
76+
update-types:
77+
- "minor"
78+
exclude-patterns:
79+
- "async-solipsism"
80+
- "frequenz-repo-config*"
81+
- "markdown-callouts"
82+
- "mkdocs-gen-files"
83+
- "mkdocs-literate-nav"
84+
- "mkdocstrings*"
85+
- "pydoclint"
86+
- "pytest-asyncio"
87+
# We group repo-config updates as it uses optional dependencies that are
88+
# considered different dependencies otherwise, and will create one PR for
89+
# each if we don't group them.
90+
repo-config:
91+
patterns:
92+
- "frequenz-repo-config*"
93+
mkdocstrings:
94+
patterns:
95+
- "mkdocstrings*"
96+
"""
97+
98+
marker = " open-pull-requests-limit: 10"
99+
if marker not in dependabot_content:
100+
manual_step(
101+
f"Could not file marker ({marker!r}) in {dependabot_file}, "
102+
"can't update automatically. Please consider using these new groups "
103+
"in the dependabot configuration file:"
104+
)
105+
return
106+
107+
text_to_replace = ""
108+
found_marker = False
109+
for line in dependabot_content.splitlines():
110+
if line == marker:
111+
found_marker = True
112+
continue
113+
if not found_marker:
114+
continue
115+
if line == "" and found_marker:
116+
break
117+
text_to_replace += line + "\n"
118+
119+
if not text_to_replace:
120+
manual_step(
121+
"Could not find the text to replace with the new depenndabot "
122+
"groups. Please consider using these new groups in the dependabot "
123+
"configuration file:"
124+
)
125+
return
126+
127+
replace_file_contents_atomically(
128+
dependabot_file,
129+
text_to_replace,
130+
new_groups,
131+
count=1,
132+
content=dependabot_content,
133+
)
134+
135+
39136
def apply_patch(patch_content: str) -> None:
40137
"""Apply a patch using the patch utility."""
41138
subprocess.run(["patch", "-p1"], input=patch_content.encode(), check=True)

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

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,46 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# We group production and development ("optional" in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
28-
optional:
29-
dependency-type: "development"
29+
exclude-patterns:
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3033
update-types:
3134
- "minor"
32-
- "patch"
35+
exclude-patterns:
36+
- "async-solipsism"
37+
{%- if cookiecutter.type == "api" %}
38+
- "frequenz-api-common"
39+
{%- endif %}
40+
- "frequenz-repo-config*"
41+
- "markdown-callouts"
42+
- "mkdocs-gen-files"
43+
- "mkdocs-literate-nav"
44+
- "mkdocstrings*"
45+
- "pydoclint"
46+
- "pytest-asyncio"
47+
# We group repo-config updates as it uses optional dependencies that are
48+
# considered different dependencies otherwise, and will create one PR for
49+
# each if we don't group them.
50+
repo-config:
51+
patterns:
52+
- "frequenz-repo-config*"
53+
mkdocstrings:
54+
patterns:
55+
- "mkdocstrings*"
3356

3457
- package-ecosystem: "github-actions"
3558
directory: "/"

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/.github/dependabot.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,43 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# We group production and development ("optional" in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
28-
optional:
29-
dependency-type: "development"
29+
exclude-patterns:
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3033
update-types:
3134
- "minor"
32-
- "patch"
35+
exclude-patterns:
36+
- "async-solipsism"
37+
- "frequenz-repo-config*"
38+
- "markdown-callouts"
39+
- "mkdocs-gen-files"
40+
- "mkdocs-literate-nav"
41+
- "mkdocstrings*"
42+
- "pydoclint"
43+
- "pytest-asyncio"
44+
# We group repo-config updates as it uses optional dependencies that are
45+
# considered different dependencies otherwise, and will create one PR for
46+
# each if we don't group them.
47+
repo-config:
48+
patterns:
49+
- "frequenz-repo-config*"
50+
mkdocstrings:
51+
patterns:
52+
- "mkdocstrings*"
3353

3454
- package-ecosystem: "github-actions"
3555
directory: "/"

tests_golden/integration/test_cookiecutter_generation/api/frequenz-api-test/.github/dependabot.yml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,44 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# We group production and development ("optional" in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
28-
optional:
29-
dependency-type: "development"
29+
exclude-patterns:
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3033
update-types:
3134
- "minor"
32-
- "patch"
35+
exclude-patterns:
36+
- "async-solipsism"
37+
- "frequenz-api-common"
38+
- "frequenz-repo-config*"
39+
- "markdown-callouts"
40+
- "mkdocs-gen-files"
41+
- "mkdocs-literate-nav"
42+
- "mkdocstrings*"
43+
- "pydoclint"
44+
- "pytest-asyncio"
45+
# We group repo-config updates as it uses optional dependencies that are
46+
# considered different dependencies otherwise, and will create one PR for
47+
# each if we don't group them.
48+
repo-config:
49+
patterns:
50+
- "frequenz-repo-config*"
51+
mkdocstrings:
52+
patterns:
53+
- "mkdocstrings*"
3354

3455
- package-ecosystem: "github-actions"
3556
directory: "/"

tests_golden/integration/test_cookiecutter_generation/app/frequenz-app-test/.github/dependabot.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,43 @@ updates:
1313
versioning-strategy: auto
1414
# Allow up to 10 open pull requests for updates to dependency versions
1515
open-pull-requests-limit: 10
16-
# We group production and development ("optional" in the context of
17-
# pyproject.toml) dependency updates when they are patch and minor updates,
18-
# so we end up with less PRs being generated.
19-
# Major updates are still managed, but they'll create one PR per
20-
# dependency, as major updates are expected to be breaking, it is better to
21-
# manage them individually.
16+
# We group patch updates as they should always work.
17+
# We also group minor updates, as it works too for most libraries,
18+
# typically except libraries that don't have a stable release yet (v0.x.x
19+
# branch), so we make some exceptions for them.
20+
# Major updates and dependencies excluded by the above groups are still
21+
# managed, but they'll create one PR per dependency, as breakage is
22+
# expected, so it might need manual intervention.
23+
# Finally, we group some dependencies that are related to each other, and
24+
# usually need to be updated together.
2225
groups:
23-
required:
24-
dependency-type: "production"
26+
patch:
2527
update-types:
26-
- "minor"
2728
- "patch"
28-
optional:
29-
dependency-type: "development"
29+
exclude-patterns:
30+
# pydoclint has shipped breaking changes in patch updates often
31+
- "pydoclint"
32+
minor:
3033
update-types:
3134
- "minor"
32-
- "patch"
35+
exclude-patterns:
36+
- "async-solipsism"
37+
- "frequenz-repo-config*"
38+
- "markdown-callouts"
39+
- "mkdocs-gen-files"
40+
- "mkdocs-literate-nav"
41+
- "mkdocstrings*"
42+
- "pydoclint"
43+
- "pytest-asyncio"
44+
# We group repo-config updates as it uses optional dependencies that are
45+
# considered different dependencies otherwise, and will create one PR for
46+
# each if we don't group them.
47+
repo-config:
48+
patterns:
49+
- "frequenz-repo-config*"
50+
mkdocstrings:
51+
patterns:
52+
- "mkdocstrings*"
3353

3454
- package-ecosystem: "github-actions"
3555
directory: "/"

0 commit comments

Comments
 (0)