From 98865d20f95b68f718932fefab249c3fe6ae17c2 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Wed, 15 May 2024 18:12:18 +0200 Subject: [PATCH] Use dedicated setup for Github CI with .env.ci --- .env.test => .env.ci | 6 ++---- .github/workflows/run-tests.yml | 7 +++---- greenweb/settings/testing.py | 8 +++++--- 3 files changed, 10 insertions(+), 11 deletions(-) rename .env.test => .env.ci (80%) diff --git a/.env.test b/.env.ci similarity index 80% rename from .env.test rename to .env.ci index 197e1c9b..2b9f39a8 100644 --- a/.env.test +++ b/.env.ci @@ -1,12 +1,10 @@ SECRET_KEY='some-development-secret' DATABASE_URL=mysql://root:just-for-github-actions@127.0.0.1:3306/greencheck +DATABASE_URL_READ_ONLY=mysql://root:just-for-github-actions@127.0.0.1:3306/greencheck +RABBITMQ_URL=amqp://guest:guest@localhost:5672/ MAILGUN_API_KEY="nope" DJANGO_SETTINGS_MODULE='greenweb.settings.testing' SENTRY_DSN="https://test@sentry.io/test" SENTRY_AUTH_TOKEN="nope" SENTRY_ORG="nope" PYTHONDONTWRITEBYTECODE=1 -RABBITMQ_URL=amqp://guest:guest@localhost:5672/ - -MAXMIND_USER_ID = 123456 -MAXMIND_LICENCE_KEY = "xxxxxxxxxxxxxxxx" diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a297e23a..77617b42 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -60,10 +60,9 @@ jobs: uv venv uv pip install -r requirements/requirements.linux.generated.txt - - name: Run tests + - name: Run tests, explictly using the python version of dotenv run: | source .venv/bin/activate - .venv/bin/dotenv -f .env.test run -- pytest + pytest env: - AWS_SHARED_CREDENTIALS_FILE: ${{ secrets.AWS_SHARED_CREDENTIALS_FILE }} - AWS_CONFIG_FILE: ${{ secrets.AWS_CONFIG_FILE }} + RUNNING_IN_CI: true diff --git a/greenweb/settings/testing.py b/greenweb/settings/testing.py index a30dd250..31333c87 100644 --- a/greenweb/settings/testing.py +++ b/greenweb/settings/testing.py @@ -1,4 +1,5 @@ from .common import * # noqa +import os INTERNAL_IPS = ["127.0.0.1"] ALLOWED_HOSTS.extend(["127.0.0.1", "localhost"]) # noqa @@ -30,7 +31,8 @@ ], } -# we replace this with the autogenerated address for a specific trello board in production -TRELLO_REGISTRATION_EMAIL_TO_BOARD_ADDRESS = "mail-to-board@localhost" +DRF_LOGGER_INTERVAL = 1 -DRF_LOGGER_INTERVAL=1 +if os.getenv("RUNNING_IN_CI", False): + # add the settings specifcally for CI in github actions + environ.Env.read_env(".env.ci") # noqa