Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d3cf14

Browse files
authored
chore(python): support multiple codeowners in blunderbuss (#1951)
1 parent 223f39e commit 7d3cf14

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

synthtool/gcp/templates/python_library/.github/blunderbuss.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55
# team, please update `codeowner_team` in `.repo-metadata.json`.
66
{% if metadata['repo']['codeowner_team']|length -%}
77
assign_issues:
8-
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
8+
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
9+
- {{ codeowner }}
10+
{%- endfor %}
911

1012
assign_issues_by:
1113
- labels:
1214
- "samples"
1315
to:
1416
- googleapis/python-samples-reviewers
15-
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
17+
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
18+
- {{ codeowner }}
19+
{%- endfor %}
1620

1721
assign_prs:
18-
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
22+
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
23+
- {{ codeowner }}
24+
{%- endfor %}
1925
{% else %}
2026
assign_issues:
2127
- googleapis/python-core-client-libraries

tests/test_python_library.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def assert_valid_yaml(file):
178178
pytest.fail(f"unable to parse YAML: {file}")
179179

180180

181-
def test_library_blunderbuss():
181+
def test_library_blunderbuss_single_codeowner():
182182
t = templates.Templates(PYTHON_LIBRARY / ".github")
183183
result = t.render(
184184
"blunderbuss.yml",
@@ -188,6 +188,7 @@ def test_library_blunderbuss():
188188
config = yaml.safe_load(result)
189189
assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
190190
assert "googleapis/foo" in config["assign_issues"]
191+
assert "googleapis/foo" in config["assign_prs"]
191192
assert (
192193
"googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
193194
)
@@ -196,6 +197,28 @@ def test_library_blunderbuss():
196197
pytest.fail(f"unable to parse YAML: {result}")
197198

198199

200+
def test_library_blunderbuss_multiple_codeowner():
201+
t = templates.Templates(PYTHON_LIBRARY / ".github")
202+
result = t.render(
203+
"blunderbuss.yml",
204+
metadata={"repo": {"codeowner_team": "googleapis/foo googleapis/bar"}},
205+
).read_text()
206+
try:
207+
config = yaml.safe_load(result)
208+
assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
209+
assert "googleapis/foo" in config["assign_issues"]
210+
assert "googleapis/bar" in config["assign_issues"]
211+
assert "googleapis/foo" in config["assign_prs"]
212+
assert "googleapis/bar" in config["assign_prs"]
213+
assert (
214+
"googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
215+
)
216+
assert "googleapis/foo" in config["assign_issues_by"][0]["to"]
217+
assert "googleapis/bar" in config["assign_issues_by"][0]["to"]
218+
except yaml.YAMLError:
219+
pytest.fail(f"unable to parse YAML: {result}")
220+
221+
199222
def test_library_blunderbuss_no_codeowner():
200223
t = templates.Templates(PYTHON_LIBRARY / ".github")
201224
result = t.render(

0 commit comments

Comments
 (0)