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