From a2b0e761cb6e61ec18c574479f267a009a638eae Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 18 Sep 2022 13:09:26 +0100 Subject: Support loading all extensions in CI --- bot/__main__.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bot/__main__.py') diff --git a/bot/__main__.py b/bot/__main__.py index 5bff1bef..9cf63dc5 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -33,6 +33,22 @@ async def _create_redis_session() -> RedisSession: raise StartupError(e) +async def test_bot_in_ci(bot: Bot) -> None: + """ + Attempt to import all extensions and then return. + + This is to ensure that all extensions can at least be + imported and have a setup function within our CI. + """ + from botcore.utils._extensions import walk_extensions + + from bot import exts + + for _ in walk_extensions(exts): + # walk_extensions does all the heavy lifting within the generator. + pass + + async def main() -> None: """Entry async method for starting the bot.""" allowed_roles = list({discord.Object(id_) for id_ in constants.MODERATION_ROLES}) @@ -62,7 +78,10 @@ async def main() -> None: channels=constants.WHITELISTED_CHANNELS, roles=constants.STAFF_ROLES, )) - await _bot.start(constants.Client.token) + if constants.Client.in_ci: + await test_bot_in_ci(_bot) + else: + await _bot.start(constants.Client.token) asyncio.run(main()) -- cgit v1.2.3