mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 06:57:47 +01:00
75 lines
2.1 KiB
YAML
75 lines
2.1 KiB
YAML
name: Run Python Tests
|
|
permissions:
|
|
contents: read
|
|
|
|
# -----------------
|
|
# --- Triggers ----
|
|
# -----------------
|
|
# This section defines when the workflow will run.
|
|
on:
|
|
# Run on every push to the 'main' branch
|
|
push:
|
|
branches: [ "main", "33-frontend-looks-like-logged-in-even-after-token-expires" ]
|
|
# Also run on every pull request that targets the 'main' branch
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
# -----------------
|
|
# ------ Jobs -----
|
|
# -----------------
|
|
# A workflow is made up of one or more jobs that can run in parallel or sequentially.
|
|
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
|
|
# 'ports' and 'options' are removed.
|
|
# GitHub Actions will use the image's default healthcheck.
|
|
|
|
# 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 -----
|
|
# -----------------
|
|
steps:
|
|
# ... (your steps remain the same) ...
|
|
|
|
- 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: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r 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 |