kanban-app/.github/workflows/backend.yml

69 lines
1.7 KiB
YAML

name: Backend CI
on:
push:
branches: [ main, develop ]
paths:
- 'backend/**'
- '.github/workflows/backend.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'backend/**'
- '.github/workflows/backend.yml'
jobs:
backend-test:
runs-on: [docker]
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
container:
image: nikolaik/python-nodejs:python3.12-nodejs24-alpine
options: --volume forgejo-pip-cache:/tmp/pip-cache
steps:
- uses: actions/checkout@v6
- name: Set up Python
run: |
python --version
- name: Install dependencies
run: |
cd backend
python -m pip install --upgrade pip
pip install --cache-dir /tmp/pip-cache -r requirements/dev.txt
- name: Debug cache
run: |
echo "Listing PIP cache files:"
pip cache dir
ls -la /tmp/pip-cache 2>/dev/null || echo "Cache dir empty or missing"
- name: Lint with flake8
run: |
cd backend
flake8 app tests --count --max-complexity=10 --max-line-length=127 --statistics --show-source
- name: Run tests
env:
TEST_DATABASE_URL: postgresql://test:test@postgres:5432/test_db
DATABASE_URL: postgresql://test:test@postgres:5432/test_db
SECRET_KEY: test-secret-key
JWT_SECRET_KEY: test-jwt-secret
FLASK_ENV: test
run: |
cd backend
pytest --cov=app --cov-report=xml --cov-report=term