diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 543106a..a813431 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ permissions: on: # Run on every push to the 'main' branch push: - branches: [ "main", "33-frontend-looks-like-logged-in-even-after-token-expires" ] + branches: [ "main" ] # Also run on every pull request that targets the 'main' branch pull_request: branches: [ "main" ] @@ -30,9 +30,9 @@ jobs: MARIADB_DATABASE: group_project # Using the DB name your app expects MARIADB_USER: appuser MARIADB_PASSWORD: apppass - # ADD THIS BLOCK BACK IN - # This forces the job to wait until the DB is - # actually responding before continuing. + ports: + - 3306:3306 + # Healthcheck ensures the job only starts when DB is ready options: >- --health-cmd="mysqladmin ping -h 127.0.0.1 -u root -prootpw --silent" --health-interval=5s @@ -40,9 +40,9 @@ jobs: --health-retries=20 # This is the job-level 'env' block - # It will be used by the 'alembic' step + # It will be used by all steps (alembic, pytest, etc.) env: - MARIADB_HOST: mariadb # Use the service label as the host + MARIADB_HOST: 127.0.0.1 MARIADB_PORT: "3306" MARIADB_DB: group_project MARIADB_USER: appuser @@ -73,7 +73,8 @@ jobs: # file that your pytest setup might be loading - name: Run tests with pytest env: - MARIADB_HOST: mariadb + MARIADB_HOST: 127.0.0.1 + MARIADB_PORT: "3306" MARIADB_DB: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass diff --git a/7project/backend/alembic/env.py b/7project/backend/alembic/env.py index ec52aab..f910b91 100644 --- a/7project/backend/alembic/env.py +++ b/7project/backend/alembic/env.py @@ -25,7 +25,8 @@ if not DATABASE_URL: SYNC_DATABASE_URL = DATABASE_URL.replace("+asyncmy", "+pymysql") -ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost" +host_env = os.getenv("MARIADB_HOST", "localhost") +ssl_enabled = host_env not in {"localhost", "127.0.0.1"} connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {} def run_migrations_offline() -> None: diff --git a/7project/backend/app/core/db.py b/7project/backend/app/core/db.py index 9c8cad7..1186352 100644 --- a/7project/backend/app/core/db.py +++ b/7project/backend/app/core/db.py @@ -19,7 +19,8 @@ from app.models.user import User from app.models.transaction import Transaction from app.models.categories import Category -ssl_enabled = os.getenv("MARIADB_HOST", "localhost") != "localhost" +host_env = os.getenv("MARIADB_HOST", "localhost") +ssl_enabled = host_env not in {"localhost", "127.0.0.1"} connect_args = {"ssl": {"ssl": True}} if ssl_enabled else {} engine = create_async_engine(