Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(python): support multiple codeowners in blunderbuss #1951

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions synthtool/gcp/templates/python_library/.github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
# team, please update `codeowner_team` in `.repo-metadata.json`.
{% if metadata['repo']['codeowner_team']|length -%}
assign_issues:
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
- {{ codeowner }}
{%- endfor %}

assign_issues_by:
- labels:
- "samples"
to:
- googleapis/python-samples-reviewers
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
- {{ codeowner }}
{%- endfor %}

assign_prs:
- {{ metadata['repo']['codeowner_team'].replace("@","") }}
{%- for codeowner in metadata['repo']['codeowner_team'].replace("@","").split(" ") %}
- {{ codeowner }}
{%- endfor %}
{% else %}
assign_issues:
- googleapis/python-core-client-libraries
Expand Down
25 changes: 24 additions & 1 deletion tests/test_python_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def assert_valid_yaml(file):
pytest.fail(f"unable to parse YAML: {file}")


def test_library_blunderbuss():
def test_library_blunderbuss_single_codeowner():
t = templates.Templates(PYTHON_LIBRARY / ".github")
result = t.render(
"blunderbuss.yml",
Expand All @@ -188,6 +188,7 @@ def test_library_blunderbuss():
config = yaml.safe_load(result)
assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
assert "googleapis/foo" in config["assign_issues"]
assert "googleapis/foo" in config["assign_prs"]
assert (
"googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
)
Expand All @@ -196,6 +197,28 @@ def test_library_blunderbuss():
pytest.fail(f"unable to parse YAML: {result}")


def test_library_blunderbuss_multiple_codeowner():
t = templates.Templates(PYTHON_LIBRARY / ".github")
result = t.render(
"blunderbuss.yml",
metadata={"repo": {"codeowner_team": "googleapis/foo googleapis/bar"}},
).read_text()
try:
config = yaml.safe_load(result)
assert "googleapis/python-core-client-libraries" not in config["assign_issues"]
assert "googleapis/foo" in config["assign_issues"]
assert "googleapis/bar" in config["assign_issues"]
assert "googleapis/foo" in config["assign_prs"]
assert "googleapis/bar" in config["assign_prs"]
assert (
"googleapis/python-samples-reviewers" in config["assign_issues_by"][0]["to"]
)
assert "googleapis/foo" in config["assign_issues_by"][0]["to"]
assert "googleapis/bar" in config["assign_issues_by"][0]["to"]
except yaml.YAMLError:
pytest.fail(f"unable to parse YAML: {result}")


def test_library_blunderbuss_no_codeowner():
t = templates.Templates(PYTHON_LIBRARY / ".github")
result = t.render(
Expand Down
Loading