1+ name : CI - Test Frontend and Backend
2+
3+ on :
4+ push :
5+ branches : [ main, dev, develop ]
6+ pull_request :
7+ branches : [ main, dev, develop ]
8+ workflow_dispatch :
9+
10+ jobs :
11+ backend-tests :
12+ name : Backend Tests (Python)
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Set up Python 3.12
20+ uses : actions/setup-python@v4
21+ with :
22+ python-version : ' 3.12'
23+
24+ - name : Cache pip dependencies
25+ uses : actions/cache@v3
26+ with :
27+ path : ~/.cache/pip
28+ key : ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}
29+ restore-keys : |
30+ ${{ runner.os }}-pip-
31+
32+ - name : Install dependencies
33+ working-directory : ./backend
34+ run : |
35+ python -m pip install --upgrade pip
36+ pip install -r requirements.txt
37+
38+ - name : Lint with flake8
39+ working-directory : ./backend
40+ run : |
41+ # Stop the build if there are Python syntax errors or undefined names
42+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
43+ # Exit-zero treats all errors as warnings
44+ flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
45+
46+ - name : Check code formatting with black
47+ working-directory : ./backend
48+ run : |
49+ black --check .
50+
51+ - name : Run tests with pytest
52+ working-directory : ./backend
53+ run : |
54+ PYTHONPATH=. pytest --cov=. --cov-report=term-missing --cov-report=xml --verbose
55+
56+ - name : Upload coverage to Codecov
57+ uses : codecov/codecov-action@v3
58+ with :
59+ file : ./backend/coverage.xml
60+ flags : backend
61+ name : backend-coverage
62+ fail_ci_if_error : false
63+
64+ frontend-tests :
65+ name : Frontend Tests (Node.js)
66+ runs-on : ubuntu-latest
67+
68+ steps :
69+ - name : Checkout code
70+ uses : actions/checkout@v4
71+
72+ - name : Set up Node.js 20
73+ uses : actions/setup-node@v4
74+ with :
75+ node-version : ' 20'
76+ cache : ' npm'
77+ cache-dependency-path : frontend/package-lock.json
78+
79+ - name : Install dependencies
80+ working-directory : ./frontend
81+ run : npm ci
82+
83+ - name : Run tests with coverage
84+ working-directory : ./frontend
85+ run : npm run test:coverage
86+
87+ - name : Upload coverage to Codecov
88+ uses : codecov/codecov-action@v3
89+ with :
90+ file : ./frontend/coverage/coverage-final.json
91+ flags : frontend
92+ name : frontend-coverage
93+ fail_ci_if_error : false
94+
95+ # Optional: Build verification job
96+ build-verification :
97+ name : Build Verification
98+ runs-on : ubuntu-latest
99+ needs : [backend-tests, frontend-tests]
100+
101+ steps :
102+ - name : Checkout code
103+ uses : actions/checkout@v4
104+
105+ - name : Set up Node.js 20
106+ uses : actions/setup-node@v4
107+ with :
108+ node-version : ' 20'
109+ cache : ' npm'
110+ cache-dependency-path : frontend/package-lock.json
111+
112+ - name : Install frontend dependencies
113+ working-directory : ./frontend
114+ run : npm ci
115+
116+ - name : Build frontend
117+ working-directory : ./frontend
118+ run : npm run build
119+
120+ - name : Verify frontend build artifacts
121+ working-directory : ./frontend
122+ run : |
123+ if [ ! -d "dist" ]; then
124+ echo "Frontend build failed - no dist directory found"
125+ exit 1
126+ fi
127+ echo "Frontend build successful - dist directory exists"
128+ ls -la dist/
0 commit comments