Added full suite of tests & added testing to CI/CD

This commit is contained in:
c-d-p
2025-04-23 00:51:14 +02:00
parent e15a5c7612
commit be00f021ba
27 changed files with 1035 additions and 48 deletions

View File

@@ -19,8 +19,66 @@ on:
- cron: '0 3 * * 0'
jobs:
build-and-deploy:
# ========================================================================
# Job to run unit tests.
# ========================================================================
test:
name: Run Linters and Tests
runs-on: ubuntu-latest
steps:
# Checks out the repo under $GITHUB_WORKSPACE
- name: Checkout code
uses: actions/checkout@v4
# Sets up Python 3.12 environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
# Cache pip dependencies for faster reruns
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
working-directory: ./backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Lint with Ruff
working-directory: ./backend
run: |
ruff check .
- name: Check formatting with Black
working-directory: ./backend
run: |
black --check .
- name: Run Pytest
working-directory: ./backend
run: |
pytest
# ========================================================================
# Job to build and deploy the Docker image to mara.
# ========================================================================
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
needs: test # Ensure tests pass before deploying
# Only run this job if triggered by a push to main or manual dispatch/schedule
# This prevents it running for PRs (eventually)
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
steps:
# Checks out the repo under $GITHUB_WORKSPACE
- name: Checkout code