Skip to content

Commit

Permalink
[ci] Roll out teams-tagging to everyone
Browse files Browse the repository at this point in the history
This removes the check for opted-in users from apache#10317, making it so anyone can attach their names without having to also opt-in. Also included is a script to generate the list of owners from `CONTRIBUTING.md` which was used to update apache#10317.
  • Loading branch information
driazati committed Mar 23, 2022
1 parent 5679bd2 commit c209241
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 19 deletions.
19 changes: 0 additions & 19 deletions tests/scripts/github_tag_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,6 @@ def fetch_issue(github: GitHubRepo, issue_number: int):
return r


def find_rollout_users(r: Dict[str, Any]):
issue = r["data"]["repository"]["issue"]
body = issue["body"]
for line in body.split("\n"):
line = line.strip()
if line.startswith("[temporary] opt-in: "):
line = line[len("[temporary] opt-in: ") :]
return find_ccs("cc " + line)

return []


def parse_teams(r: Dict[str, Any], issue_number: int) -> Dict[str, str]:
"""
Fetch an issue and parse out series of tagged people from the issue body
Expand Down Expand Up @@ -209,9 +197,6 @@ def gen_cc_line(users):

# Fetch the list of teams
teams = parse_teams(issue_data, issue_number=int(args.team_issue))
# When rolling out this tool it is limited to certain users, so find that list
rollout_users = find_rollout_users(issue_data)
print(f"[slow rollout] Limiting to opted-in users: {rollout_users}")

print(f"Found these teams in issue #{args.team_issue}\n{json.dumps(teams, indent=2)}")

Expand All @@ -236,10 +221,6 @@ def gen_cc_line(users):
tags = [t.lower() for t in tags]
print(f"Found tags: {tags}")

if author not in rollout_users:
print(f"Author {author} is not opted in, quitting")
exit(0)

# Update the PR or issue based on tags in the title and GitHub tags
to_cc = [teams.get(t, []) for t in tags]
to_cc = list(set(item for sublist in to_cc for item in sublist))
Expand Down
62 changes: 62 additions & 0 deletions tests/scripts/list_topic_owners.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import argparse
import re
import json
from collections import defaultdict

from cmd_utils import REPO_ROOT

CONTRIBUTORS = REPO_ROOT / "CONTRIBUTORS.md"


if __name__ == "__main__":
help = "List out users by team from CONTRIBUTORS.md"
parser = argparse.ArgumentParser(description=help)
parser.add_argument("--format", default="github", help="'github' or 'json' for output")
args = parser.parse_args()

with open(CONTRIBUTORS) as f:
content = f.readlines()

parse_line = False
all_topics = defaultdict(lambda: [])
for line in content:
if line.strip().startswith("## Committers"):
parse_line = True
elif line.strip().startswith("##"):
parse_line = False

if parse_line and line.startswith("- ["):
line = line.strip()
m = re.search("github.com\/(.*?)\).* - (.*)", line)
user = m.groups()[0]
topics = [t.lower().strip() for t in m.groups()[1].split(",")]
for t in topics:
all_topics[t].append(user)

all_topics = dict(all_topics)
if args.format == "json":
print(json.dumps(all_topics, indent=2))
else:
items = sorted(all_topics.items(), key=lambda x: x[0])
for topic, users in items:
users = [f"@{user}" for user in users]
users = " ".join(users)
print(f"- {topic} {users}")

0 comments on commit c209241

Please sign in to comment.