tools: Verify that all integrations have bot avatars.

This commit is contained in:
Puneeth Chaganti 2020-04-21 22:31:54 +05:30 committed by Tim Abbott
parent 18ae06404b
commit d5f5a99b07
3 changed files with 23 additions and 3 deletions

View File

@ -21,6 +21,7 @@ set -x
./tools/test-migrations
./tools/setup/optimize-svg
./tools/setup/generate_integration_bots_avatars.py --check-missing
# In CI, we only test links we control in test-documentation to avoid flakes
./tools/test-documentation --skip-external-links
./tools/test-help-documentation --skip-external-links

View File

@ -14,7 +14,9 @@ import django
django.setup()
import argparse
import io
import cairosvg
from PIL import Image
@ -53,12 +55,27 @@ def create_integration_bot_avatar(logo_path: str) -> None:
with open(bot_avatar_path, 'wb') as f:
f.write(avatar)
def generate_integration_bots_avatars() -> None:
def generate_integration_bots_avatars(check_missing: bool=False) -> None:
missing = set()
for webhook in WEBHOOK_INTEGRATIONS:
logo_path = webhook.get_logo_path()
if not logo_path:
continue
create_integration_bot_avatar(static_path(logo_path))
if check_missing:
bot_avatar_path = static_path(webhook.DEFAULT_BOT_AVATAR_PATH.format(name=webhook.name))
if not os.path.isfile(bot_avatar_path):
missing.add(webhook.name)
else:
create_integration_bot_avatar(static_path(logo_path))
if missing:
print('Bot avatars are missing for these webhooks: {}.\n'
'Run ./tools/setup/generate_integration_bots_avatars.py '
'to generate them.'.format(', '.join(missing)))
sys.exit(1)
if __name__ == '__main__':
generate_integration_bots_avatars()
parser = argparse.ArgumentParser()
parser.add_argument('--check-missing', action='store_true')
options = parser.parse_args()
generate_integration_bots_avatars(options.check_missing)

View File

@ -45,6 +45,8 @@ run ./tools/test-backend --include-webhooks $FORCEARG
run ./tools/test-migrations
# Not running SVG optimizing since it's low-churn
# run ./tools/setup/optimize-svg
# Not running missing bot avatar detection since it's low churn
# ./tools/setup/generate_integration_bots_avatars.py --check-missing
# Not running documentation tests since it takes 20s and only tests documentation
# run ./tools/test-documentation
run ./tools/test-help-documentation $FORCEARG