name: Run Python Tests permissions: contents: read on: workflow_call: jobs: build-and-test: runs-on: ubuntu-latest # 1) Start a MariaDB service container for tests services: # The label 'mariadb' becomes the hostname mariadb: image: mariadb:11.4 env: MARIADB_ROOT_PASSWORD: rootpw # This DB name now matches what your app expects MARIADB_DATABASE: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass # 2) Expose DB connection settings to steps env: # Use the service label 'mariadb' as the host MARIADB_HOST: mariadb MARIADB_PORT: "3306" # This is the internal port, which is correct # Match the database name from the service MARIADB_DB: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass steps: - name: Check out repository code uses: actions/checkout@v4 - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' - name: Add test dependencies to requirements run: | echo "pytest==8.4.2" >> ./7project/backend/requirements.txt echo "pytest-asyncio==1.2.0" >> ./7project/backend/requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r ./7project/backend/requirements.txt - name: Run Alembic migrations run: | alembic upgrade head working-directory: ./7project/backend - name: Run tests with pytest run: pytest working-directory: ./7project/backend