Skip to content

Commit c293cdd

Browse files
authored
Upgrade to labeler 5.0.0 (#211)
This also fix the matching rules, that were broken, probably because the version before 5.0.0 didn't support the flexible glob matching or it was misused. Fixes #194.
2 parents 2796030 + 8996308 commit c293cdd

File tree

15 files changed

+329
-200
lines changed

15 files changed

+329
-200
lines changed

.github/labeler.yml

Lines changed: 80 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,74 +6,100 @@
66
# For more details on the configuration please see:
77
# https://github.com/marketplace/actions/labeler
88

9-
"part:docs":
10-
- any:
11-
- "**/*.md"
12-
- "docs/**"
13-
- "examples/**"
14-
- LICENSE
15-
all:
16-
- "!tests*/**"
9+
"part:doc":
10+
- all:
11+
- changed-files:
12+
- any-glob-to-any-file:
13+
- "**/*.md"
14+
- "docs/**"
15+
- "examples/**"
16+
- LICENSE
17+
- all-globs-to-all-files:
18+
- "!tests*/**"
19+
- "!cookiecutter/{{cookiecutter.github_repo_name}}/**"
1720

1821
"part:tests":
19-
- "**/conftest.py"
20-
- "tests*/**"
22+
- all:
23+
- changed-files:
24+
- any-glob-to-any-file:
25+
- "**/conftest.py"
26+
- "tests*/**"
27+
- all-globs-to-all-files:
28+
- "!.github/**"
29+
- "!cookiecutter/{{cookiecutter.github_repo_name}}/**"
2130

2231
"part:tooling":
23-
- any:
24-
- "**/*.ini"
25-
- "**/*.toml"
26-
- "**/*.yaml"
27-
- "**/*.yml"
28-
- "**/conftest.py"
29-
- ".editorconfig"
30-
- ".git*"
31-
- ".git*/**"
32-
- CODEOWNERS
33-
- MANIFEST.in
34-
- noxfile.py
35-
all:
36-
- "!tests*/**"
32+
- all:
33+
- changed-files:
34+
- any-glob-to-any-file:
35+
- "**/*.ini"
36+
- "**/*.toml"
37+
- "**/*.yaml"
38+
- "**/*.yml"
39+
- "**/conftest.py"
40+
- ".editorconfig"
41+
- ".git*"
42+
- ".git*/**"
43+
- CODEOWNERS
44+
- MANIFEST.in
45+
- noxfile.py
46+
- all-globs-to-all-files:
47+
- "!.github/**"
48+
- "!tests*/**"
49+
- "!cookiecutter/{{cookiecutter.github_repo_name}}/**"
3750

3851
"part:ci":
39-
- any:
40-
- "**/.github/*labeler.*"
41-
- "**/.github/dependabot.*"
42-
- "**/.github/workflows/*"
43-
all:
44-
- "!tests*/**"
52+
- all:
53+
- changed-files:
54+
- any-glob-to-any-file:
55+
- ".github/**"
56+
- all-globs-to-all-files:
57+
- "!**/*.md"
4558

4659
"part:cookiecutter":
47-
- any:
48-
- "cookiecutter/**"
49-
all:
50-
- "!tests/**"
51-
- "!tests_golden/**"
60+
- all:
61+
- changed-files:
62+
- any-glob-to-any-file:
63+
- "cookiecutter*"
64+
- "cookiecutter*/**"
65+
- all-globs-to-all-files:
66+
- "!cookiecutter/{{cookiecutter.github_repo_name}}/**"
67+
68+
"part:template":
69+
- changed-files:
70+
- any-glob-to-any-file:
71+
- "cookiecutter/{{cookiecutter.github_repo_name}}/**"
5272

5373
"part:mkdocs":
54-
- any:
55-
- "**/docs/*.py"
56-
- "**/mkdocs.*"
57-
- "src/frequenz/repo/config/mkdocs*"
58-
all:
59-
- "!tests*/**"
74+
- all:
75+
- changed-files:
76+
- any-glob-to-any-file:
77+
- "**/mkdocs.*"
78+
- "docs/**/*.py"
79+
- "src/frequenz/repo/config/mkdocs*"
80+
- "src/frequenz/repo/config/mkdocs*/**"
81+
- all-globs-to-all-files:
82+
- "!.github/**"
83+
- "!tests*/**"
84+
- "!cookiecutter/{{cookiecutter.github_repo_name}}/**"
6085

6186
"part:nox":
62-
- any:
63-
- "**/noxfile.py"
87+
- changed-files:
88+
- any-glob-to-any-file:
89+
- "noxfile.py"
90+
- "src/frequenz/repo/config/nox*"
6491
- "src/frequenz/repo/config/nox/**"
65-
all:
66-
- "!tests*/**"
92+
93+
"part:pytest":
94+
- changed-files:
95+
- any-glob-to-any-file:
96+
- "src/frequenz/repo/config/pytest*"
97+
- "src/frequenz/repo/config/pytest*/**"
6798

6899
"part:protobuf":
69-
- any:
100+
- changed-files:
101+
- any-glob-to-any-file:
70102
- "src/frequenz/repo/config/setuptools/grpc*"
103+
- "src/frequenz/repo/config/setuptools/grpc*/**"
71104
- "src/frequenz/repo/config/protobuf*"
72-
all:
73-
- "!tests*/**"
74-
75-
"part:pytest":
76-
- any:
77-
- "src/frequenz/repo/config/pytest"
78-
all:
79-
- "!tests*/**"
105+
- "src/frequenz/repo/config/protobuf*/**"

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# only use hashes to pick the action to execute (instead of tags or branches).
1919
# For more details read:
2020
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
21-
uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # 4.3.0
21+
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # 5.0.0
2222
with:
2323
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2424
dot: true

RELEASE_NOTES.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ To upgrade without regenerating the project, you can follow these steps:
2424

2525
Go to the repository settings -> **Rules** -> **Rulesets** -> **Protect version branches** -> **Bypass list** -> **Add bypass** -> Select **Maintain** role and change the dropdown bypass rule to use **Pull requests** instead of **Always**.
2626

27+
- The `labeler` action was upgraded to 5.0.0. This needs a new configuration file.
28+
29+
If you haven't diverged much from the default configuration (and you are not using exclusion rules), you can update the configuration file by running this script in the root of your repository:
30+
31+
```python
32+
import sys
33+
lines = []
34+
state = "looking"
35+
with open(".github/labeler.yml", encoding="utf-8") as fin:
36+
for line in fin:
37+
if "changed-files:" in line:
38+
sys.stderr.write("Already fixed, aborting...\n")
39+
sys.exit(1)
40+
match state:
41+
case "looking":
42+
if not line.startswith(("#", " ", "\t")) and line.rstrip().endswith(":"):
43+
line = f"{line} - changed-files:\n - any-glob-to-any-file:\n"
44+
state = "in-label"
45+
case "in-label":
46+
if not line.lstrip().startswith("-"):
47+
state = "looking"
48+
else:
49+
line = f" {line}"
50+
lines.append(line)
51+
with open(".github/labeler.yml", "w", encoding="utf-8") as fout:
52+
fout.writelines(lines)
53+
```
54+
55+
This will update the file in place, you can inspect the changes with `git diff`.
56+
2757
## New Features
2858
2959
<!-- Here goes the main new features and examples or instructions on how to use them -->
@@ -32,6 +62,7 @@ To upgrade without regenerating the project, you can follow these steps:
3262
3363
- Some checks that are already performed by `flake8` are now disabled in `pylint` to avoid double reporting.
3464
- The repository ruleset `Protect version branches` has been updated to allow repository maintainers to skip protection rules in PRs.
65+
- The `labeler` action was upgraded to 5.0.0, which allows for more complex matching rules.
3566
3667
## Bug Fixes
3768

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

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,58 @@
1010
# For example:
1111
#
1212
# "part:module":
13-
# - "src/frequenz/{{cookiecutter.type}}/{{cookiecutter.name | as_identifier}}/module/**"
13+
# - changed-files:
14+
# - any-glob-to-any-file:
15+
# - "src/frequenz/{{cookiecutter.type}}/{{cookiecutter.name | as_identifier}}/module/**"
1416
#
1517
# "part:other":
16-
# - "src/frequenz/{{cookiecutter.type}}/{{cookiecutter.name | as_identifier}}/other/**"
18+
# - changed-files:
19+
# - any-glob-to-any-file:
20+
# - "src/frequenz/{{cookiecutter.type}}/{{cookiecutter.name | as_identifier}}/other/**"
1721
#
1822
# # For excluding some files (in this example, label "part:complicated"
1923
# # everything inside src/ with a .py suffix, except for src/__init__.py)
2024
# "part:complicated":
21-
# - any:
22-
# - "src/**/*.py"
2325
# - all:
24-
# - "!src/__init__.py"
26+
# - changed-files:
27+
# - any-glob-to-any-file:
28+
# - "src/**/*.py"
29+
# - all-glob-to-all-file:
30+
# - "!src/__init__.py"
2531
#
2632
# Please have in mind that that the part:xxx labels need to
2733
# be created in the GitHub repository.
2834

2935
"part:docs":
30-
- "**/*.md"
31-
- "docs/**"
32-
- "examples/**"
33-
- LICENSE
36+
- changed-files:
37+
- any-glob-to-any-file:
38+
- "**/*.md"
39+
- "docs/**"
40+
- "examples/**"
41+
- LICENSE
3442

3543
"part:tests":
36-
- "**/conftest.py"
44+
- changed-files:
45+
- any-glob-to-any-file:
46+
- "**/conftest.py"
3747
{%- if cookiecutter.type == "api" %}
38-
- "pytests/**"
48+
- "pytests/**"
3949
{%- else %}
40-
- "tests/**"
50+
- "tests/**"
4151
{%- endif %}
4252

4353
"part:tooling":
44-
- "**/*.ini"
45-
- "**/*.toml"
46-
- "**/*.yaml"
47-
- "**/*.yml"
48-
- "**/conftest.py"
49-
- ".editorconfig"
50-
- ".git*"
51-
- ".git*/**"
52-
- "docs/*.py"
53-
- CODEOWNERS
54-
- MANIFEST.in
55-
- noxfile.py
54+
- changed-files:
55+
- any-glob-to-any-file:
56+
- "**/*.ini"
57+
- "**/*.toml"
58+
- "**/*.yaml"
59+
- "**/*.yml"
60+
- "**/conftest.py"
61+
- ".editorconfig"
62+
- ".git*"
63+
- ".git*/**"
64+
- "docs/*.py"
65+
- CODEOWNERS
66+
- MANIFEST.in
67+
- noxfile.py

cookiecutter/{{cookiecutter.github_repo_name}}/.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
# only use hashes to pick the action to execute (instead of tags or branches).
2020
# For more details read:
2121
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
22-
uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # 4.3.0
22+
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # 5.0.0
2323
with:
2424
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2525
dot: true

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

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,54 @@
1010
# For example:
1111
#
1212
# "part:module":
13-
# - "src/frequenz/actor/test/module/**"
13+
# - changed-files:
14+
# - any-glob-to-any-file:
15+
# - "src/frequenz/actor/test/module/**"
1416
#
1517
# "part:other":
16-
# - "src/frequenz/actor/test/other/**"
18+
# - changed-files:
19+
# - any-glob-to-any-file:
20+
# - "src/frequenz/actor/test/other/**"
1721
#
1822
# # For excluding some files (in this example, label "part:complicated"
1923
# # everything inside src/ with a .py suffix, except for src/__init__.py)
2024
# "part:complicated":
21-
# - any:
22-
# - "src/**/*.py"
2325
# - all:
24-
# - "!src/__init__.py"
26+
# - changed-files:
27+
# - any-glob-to-any-file:
28+
# - "src/**/*.py"
29+
# - all-glob-to-all-file:
30+
# - "!src/__init__.py"
2531
#
2632
# Please have in mind that that the part:xxx labels need to
2733
# be created in the GitHub repository.
2834

2935
"part:docs":
30-
- "**/*.md"
31-
- "docs/**"
32-
- "examples/**"
33-
- LICENSE
36+
- changed-files:
37+
- any-glob-to-any-file:
38+
- "**/*.md"
39+
- "docs/**"
40+
- "examples/**"
41+
- LICENSE
3442

3543
"part:tests":
36-
- "**/conftest.py"
37-
- "tests/**"
44+
- changed-files:
45+
- any-glob-to-any-file:
46+
- "**/conftest.py"
47+
- "tests/**"
3848

3949
"part:tooling":
40-
- "**/*.ini"
41-
- "**/*.toml"
42-
- "**/*.yaml"
43-
- "**/*.yml"
44-
- "**/conftest.py"
45-
- ".editorconfig"
46-
- ".git*"
47-
- ".git*/**"
48-
- "docs/*.py"
49-
- CODEOWNERS
50-
- MANIFEST.in
51-
- noxfile.py
50+
- changed-files:
51+
- any-glob-to-any-file:
52+
- "**/*.ini"
53+
- "**/*.toml"
54+
- "**/*.yaml"
55+
- "**/*.yml"
56+
- "**/conftest.py"
57+
- ".editorconfig"
58+
- ".git*"
59+
- ".git*/**"
60+
- "docs/*.py"
61+
- CODEOWNERS
62+
- MANIFEST.in
63+
- noxfile.py

tests_golden/integration/test_cookiecutter_generation/actor/frequenz-actor-test/.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# only use hashes to pick the action to execute (instead of tags or branches).
1919
# For more details read:
2020
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
21-
uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # 4.3.0
21+
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # 5.0.0
2222
with:
2323
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2424
dot: true

0 commit comments

Comments
 (0)