name: Run Python Tests permissions: contents: read on: workflow_call: jobs: build-and-test: runs-on: ubuntu-latest services: mariadb: image: mariadb:11.4 env: MARIADB_ROOT_PASSWORD: rootpw MARIADB_DATABASE: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass ports: - 3306:3306 options: >- --health-cmd="mariadb-admin ping -h 127.0.0.1 -u root -prootpw --silent" --health-interval=5s --health-timeout=2s --health-retries=20 env: MARIADB_HOST: 127.0.0.1 MARIADB_PORT: "3306" MARIADB_DB: group_project MARIADB_USER: appuser MARIADB_PASSWORD: apppass # Ensure the application uses MariaDB (async) during tests DATABASE_URL: mysql+asyncmy://appuser:apppass@127.0.0.1:3306/group_project 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