Skip to content

Commit 97d6cd3

Browse files
henrikbrixandersendkalowsk
authored andcommitted
scripts: check_maintainers: add scripts for checking GitHub accounts
Add script for checking if maintainer and collaborator GitHub accounts exist. Signed-off-by: Henrik Brix Andersen <[email protected]>
1 parent a597fea commit 97d6cd3

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

scripts/check_maintainers.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright (c) 2024 Vestas Wind Systems A/S
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
import argparse
8+
import sys
9+
10+
from github_helpers import get_github_object
11+
from get_maintainer import Maintainers
12+
from github.GithubException import UnknownObjectException
13+
14+
def parse_args():
15+
parser = argparse.ArgumentParser(
16+
formatter_class=argparse.RawDescriptionHelpFormatter,
17+
description=__doc__, allow_abbrev=False)
18+
19+
parser.add_argument(
20+
"-m", "--maintainers",
21+
metavar="MAINTAINERS_FILE",
22+
help="Maintainers file to load. If not specified, MAINTAINERS.yml in "
23+
"the top-level repository directory is used, and must exist. "
24+
"Paths in the maintainers file will always be taken as relative "
25+
"to the top-level directory.")
26+
27+
return parser.parse_args()
28+
29+
def main() -> None:
30+
args = parse_args()
31+
zephyr_repo = get_github_object().get_repo('zephyrproject-rtos/zephyr')
32+
maintainers = Maintainers(args.maintainers)
33+
gh = get_github_object()
34+
gh_users = []
35+
notfound = []
36+
noncollabs = []
37+
38+
for area in maintainers.areas.values():
39+
gh_users = list(set(gh_users + area.maintainers + area.collaborators))
40+
41+
gh_users.sort()
42+
43+
print('Checking maintainer and collaborator user accounts on GitHub:')
44+
for gh_user in gh_users:
45+
try:
46+
print('.', end='', flush=True)
47+
gh.get_user(gh_user)
48+
49+
if not zephyr_repo.has_in_collaborators(gh_user):
50+
noncollabs.append(gh_user)
51+
except UnknownObjectException:
52+
notfound.append(gh_user)
53+
print('\n')
54+
55+
if notfound:
56+
print('The following GitHub user accounts do not exist:')
57+
print('\n'.join(notfound))
58+
else:
59+
print('No non-existing user accounts found')
60+
61+
if noncollabs:
62+
print('The following GitHub user accounts are not collaborators:')
63+
print('\n'.join(noncollabs))
64+
else:
65+
print('No non-collaborator user accounts found')
66+
67+
if notfound or noncollabs:
68+
sys.exit(1)
69+
70+
if __name__ == '__main__':
71+
main()

0 commit comments

Comments
 (0)