diff options
| -rw-r--r-- | .github/workflows/lint.yaml | 10 | ||||
| -rw-r--r-- | bot/__main__.py | 3 | ||||
| -rw-r--r-- | bot/constants.py | 1 | 
3 files changed, 12 insertions, 2 deletions
diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 14cfb702..2cbfc2f5 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -12,7 +12,7 @@ concurrency:  jobs:    lint: -    name: Run pre-commit & flake8 +    name: Run linting & tests      runs-on: ubuntu-latest      env:        # List of licenses that are compatible with the MIT License and @@ -86,6 +86,14 @@ jobs:            pip-licenses --allow-only="$ALLOWED_LICENSE" \              --package $(poetry export -f requirements.txt --without-hashes | sed "s/==.*//g" | tr "\n" " ") +      # Attempt to run the bot. Setting `IN_CI` to true, so bot.run() is never called. +      # This is to catch import and cog setup errors that may appear in PRs, to avoid crash loops if merged. +      - name: Attempt bot setup +        run: "python -m bot" +        env: +          USE_FAKEREDIS: true +          IN_CI: true +        # This step caches our pre-commit environment. To make sure we        # do create a new environment when our pre-commit setup changes,        # we create a cache key based on relevant factors. diff --git a/bot/__main__.py b/bot/__main__.py index 6889fe2b..0bf7b398 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -12,4 +12,5 @@ bot.add_check(whitelist_check(channels=WHITELISTED_CHANNELS, roles=STAFF_ROLES))  for ext in walk_extensions():      bot.load_extension(ext) -bot.run(Client.token) +if not Client.in_ci: +    bot.run(Client.token) diff --git a/bot/constants.py b/bot/constants.py index b4d7bc24..5d876d97 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -143,6 +143,7 @@ class Client(NamedTuple):      prefix = environ.get("PREFIX", ".")      token = environ.get("BOT_TOKEN")      debug = environ.get("BOT_DEBUG", "true").lower() == "true" +    in_ci = environ.get("IN_CI", "false").lower() == "true"      github_bot_repo = "https://github.com/python-discord/sir-lancebot"      # Override seasonal locks: 1 (January) to 12 (December)      month_override = int(environ["MONTH_OVERRIDE"]) if "MONTH_OVERRIDE" in environ else None  |