diff --git a/.github/pr_validation.py b/.github/pr_validation.py index 92c4c94fb..c689cce99 100644 --- a/.github/pr_validation.py +++ b/.github/pr_validation.py @@ -20,13 +20,13 @@ ] VERIFIED_TWITTER_ACCOUNTS = { - 'https://twitter.com/m417z': 'https://github.com/m417z', - 'https://twitter.com/AhmedWalid605': 'https://github.com/ahmed605', - 'https://twitter.com/learn_more': 'https://github.com/learn-more', - 'https://twitter.com/realgam3': 'https://github.com/realgam3', - 'https://twitter.com/teknixstuff': 'https://github.com/teknixstuff', - 'https://twitter.com/kawaipure': 'https://github.com/kawapure', - 'https://twitter.com/TorutheRedFox': 'https://github.com/TorutheRedFox', + 'https://github.com/m417z': 'm417z', + 'https://github.com/ahmed605': 'AhmedWalid605', + 'https://github.com/learn-more': 'learn_more', + 'https://github.com/realgam3': 'realgam3', + 'https://github.com/teknixstuff': 'teknixstuff', + 'https://github.com/kawapure': 'kawaipure', + 'https://github.com/TorutheRedFox': 'TorutheRedFox', } MOD_METADATA_PARAMS = { @@ -114,7 +114,7 @@ def get_mod_file_metadata(path: Path, file: TextIO): if not any(key in x for x in MOD_METADATA_PARAMS.values()): warnings += add_warning( - path, line_number, f'@{key} is not a valid metadata parameter' + path, line_number, f'{key} is not a valid metadata parameter' ) continue @@ -133,7 +133,7 @@ def get_mod_file_metadata(path: Path, file: TextIO): else: if (key, language) in properties: warnings += add_warning( - path, line_number, f'@{key} must be specified only once' + path, line_number, f'{key} must be specified only once' ) continue @@ -158,10 +158,10 @@ def validate_metadata(path: Path, expected_author: str): expected = f'https://github.com/{expected_author}' if value != expected: warnings += add_warning( - path, line_number, f'Expected @{key[0]} to be "{expected}"' + path, line_number, f'Expected {key[0]} to be "{expected}"' ) else: - warnings += add_warning(path, 1, f'Missing @{key[0]}') + warnings += add_warning(path, 1, f'Missing {key[0]}') key = ('id', None) if key in properties: @@ -169,37 +169,42 @@ def validate_metadata(path: Path, expected_author: str): expected = path.name.removesuffix('.cpp').removesuffix('.wh') if value != expected: warnings += add_warning( - path, line_number, f'Expected the id to be "{expected}"' + path, line_number, f'Expected {key[0]} to be "{expected}"' ) if not re.fullmatch(r'([0-9a-z]+-)*[0-9a-z]+', value): warnings += add_warning( - path, line_number, '@id must contain only letters, numbers and dashes' + path, + line_number, + f'{key[0]} must contain only letters, numbers and dashes', ) if len(value) < 8 or len(value) > 50: warnings += add_warning( - path, line_number, '@id must be between 8 and 50 characters' + path, line_number, f'{key[0]} must be between 8 and 50 characters' ) else: - warnings += add_warning(path, 1, f'Missing @{key[0]}') + warnings += add_warning(path, 1, f'Missing {key[0]}') key = ('version', None) if key in properties: value, line_number = properties[key] if not re.fullmatch(r'([0-9]+\.)*[0-9]+', value): warnings += add_warning( - path, line_number, 'Version must contain only numbers and dots' + path, line_number, f'{key[0]} must contain only numbers and dots' ) else: - warnings += add_warning(path, 1, f'Missing @{key[0]}') + warnings += add_warning(path, 1, f'Missing {key[0]}') key = ('twitter', None) if key in properties: value, line_number = properties[key] - if github is None or VERIFIED_TWITTER_ACCOUNTS.get(value) != github: + expected = github and VERIFIED_TWITTER_ACCOUNTS.get(github) + if not expected or not re.fullmatch( + r'https://(twitter|x)\.com/' + re.escape(expected), value + ): warnings += add_warning( - path, line_number, f'@{key[0]} requires manual verification' + path, line_number, f'{key[0]} requires manual verification' ) key = ('compilerOptions', None) @@ -207,12 +212,12 @@ def validate_metadata(path: Path, expected_author: str): value, line_number = properties[key] if not re.fullmatch(r'((-[lD]\S+|-Wl,--export-all-symbols)\s+)+', value + ' '): warnings += add_warning( - path, line_number, 'Compiler options require manual verification' + path, line_number, f'{key[0]} require manual verification' ) key = ('author', None) if key not in properties: - warnings += add_warning(path, 1, f'Missing @{key[0]}') + warnings += add_warning(path, 1, f'Missing {key[0]}') # Validate that this file has the required extensions if ''.join(path.suffixes) != '.wh.cpp':