1- name : Backend Tests
1+ name : Backend CI
22
33on :
44 push :
5+ branches : [ main, dev ]
6+ paths :
7+ - " backend/**"
8+ - " .github/workflows/backend-ci.yml"
59 pull_request :
10+ branches : [ main, dev ]
11+ paths :
12+ - " backend/**"
13+ - " .github/workflows/backend-ci.yml"
614
715permissions :
816 contents : read
917
1018jobs :
1119 test :
1220 runs-on : ubuntu-latest
21+
22+ env :
23+ DJANGO_SETTINGS_MODULE : config.settings.local
24+ POSTGRES_DB : fashio_test_db
25+ POSTGRES_USER : fashio_test_user
26+ POSTGRES_PASSWORD : fashio_test_password
27+ POSTGRES_HOST : localhost
28+ POSTGRES_PORT : 5432
29+ JWT_SECRET : test-jwt-secret-key-for-ci-pipeline
30+
31+ defaults :
32+ run :
33+ working-directory : backend
1334
1435 services :
1536 postgres :
1637 image : postgres:16-alpine
1738 env :
18- POSTGRES_USER : ${{ vars.POSTGRES_USER || 'fashio_admin' }}
19- POSTGRES_PASSWORD : ${{ secrets.POSTGRES_PASSWORD || 'local_test_password' }}
20- POSTGRES_DB : ${{ vars.POSTGRES_DB || 'fashio_db' }}
39+ POSTGRES_DB : fashio_test_db
40+ POSTGRES_USER : fashio_test_user
41+ POSTGRES_PASSWORD : fashio_test_password
2142 ports :
2243 - 5432:5432
2344 options : >-
2445 --health-cmd pg_isready
25- --health-interval 10s
46+ --health-interval 5s
2647 --health-timeout 5s
2748 --health-retries 5
2849
2950 steps :
3051 - name : Checkout source code
3152 uses : actions/checkout@v4
3253
33- - name : Install uv and set up python
54+ - name : Install uv and enable caching
3455 uses : astral-sh/setup-uv@v5
3556 with :
3657 version : " latest"
3758 enable-cache : true
3859 cache-dependency-lock-file : " backend/uv.lock"
3960
40- - name : Install dependencies
41- working-directory : backend
61+ - name : Ensure Python 3.12 is installed
62+ run : uv python install 3.12
63+
64+ - name : Install project dependencies
4265 run : uv sync --frozen
4366
44- - name : Run flake8
45- working-directory : backend
46- run : |
47- uv run flake8 . --exclude=.venv --count --select=E9,F63,F7,F82 --show-source --statistics
48- uv run flake8 . --exclude=.venv --count --exit-zero --max-complexity=10 --max-line-length=119 --statistics
67+ - name : Lint code with Ruff
68+ run : uv run ruff check .
4969
50- - name : Run black check
51- working-directory : backend
52- run : uvx black --check --verbose .
70+ - name : Check code formatting with Ruff
71+ run : uv run ruff format --check .
5372
54- - name : Run pytest
55- working-directory : backend
73+ - name : Run Pytest suite
5674 run : uv run pytest
0 commit comments