Skip to content

Commit f6318c7

Browse files
committed
SYnc check with main
1 parent d842b0a commit f6318c7

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

members_check.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
MEMBER_INFO = 'https://whimsy.apache.org/public/member-info.json'
2929
MEMBERS_MD ='content/foundation/members.md'
3030

31-
def main():
31+
def main(failOnWarn=False):
3232
member_info = requests.get(MEMBER_INFO).json()
3333
members = member_info['members']
3434
ex_members = member_info['ex_members']
3535
errors = 0
36+
warnings = 0
3637
with open(MEMBERS_MD, 'r', encoding='utf-8') as md:
3738
section = None
3839
for line in md:
@@ -61,25 +62,38 @@ def main():
6162
name = parts.pop(0).strip()
6263
if section == 'members':
6364
if not availid in members:
65+
level = ''
6466
if availid in ex_members:
6567
status = f"is listed in Whimsy with status '{ex_members.get(availid)}'"
68+
warnings += 1
69+
level = 'WARNING'
6670
else:
6771
status = "was not found in Whimsy"
68-
errors += 1
69-
print(f"'{availid}' ({name}) is listed in the 'members' section of `content/foundation/members.md`, but {status}")
72+
errors += 1
73+
level = 'ERROR'
74+
print(f"{level}: '{availid}' ({name}) is listed in the 'members' section of `content/foundation/members.md`, but {status}")
7075
elif section == 'emeritus':
7176
if availid != '?' and not availid in ex_members:
7277
if availid in members:
7378
status = "is listed in Whimsy as an ASF Member"
79+
warnings += 1
80+
level = 'WARNING'
7481
else:
7582
status = "was not found in Whimsy"
76-
print(f"'{availid}' ({name}) is listed in the 'emeritus' section of `content/foundation/members.md`, but {status}")
77-
errors += 1
83+
errors += 1
84+
level = 'ERROR'
85+
print(f"{level}: '{availid}' ({name}) is listed in the 'emeritus' section of `content/foundation/members.md`, but {status}")
86+
print(f"Detected {errors} error(s) and {warnings} warnings. ")
7887
if errors > 0:
79-
print(f"Detected {errors} error(s). ")
88+
print("Errors detected, failing")
8089
sys.exit(1)
90+
elif warnings > 0:
91+
if failOnWarn:
92+
print("Warnings detected, failing")
93+
else:
94+
print("Warnings detected")
8195
else:
82-
print("No errors detected")
96+
print("No errors or warnings detected")
8397

8498
if __name__ == '__main__':
85-
main()
99+
main(len(sys.argv) >1 and sys.argv[1] == 'failOnWarn')

0 commit comments

Comments
 (0)