@@ -52,44 +52,48 @@ jobs:
5252 fail_ci_if_error : false
5353
5454 backend-tests :
55- name : Backend Tests
55+ name : Backend Tests (Python API)
5656 runs-on : ubuntu-latest
57- defaults :
58- run :
59- working-directory : ./backend
60- strategy :
61- matrix :
62- node-version : [18.x, 20.x]
6357 steps :
6458 - uses : actions/checkout@v4
6559
66- - uses : pnpm/action- setup@v4
60+ - uses : actions/ setup-python @v4
6761 with :
68- version : 10
62+ python-version : " 3.9"
63+ cache : " pip"
6964
70- - uses : actions/setup-node@v4
71- with :
72- node-version : ${{ matrix.node-version }}
73- cache : " pnpm "
65+ - run : |
66+ python -m pip install --upgrade pip
67+ pip install -r requirements.txt
68+ pip install pytest pytest-cov httpx
7469
75- # --- Lockfile Sync Check (added section) ---
76- - name : Check lockfile sync
77- run : |
78- pnpm install --frozen-lockfile || {
79- echo "❌ Lockfile is out of sync with package.json."
80- echo "Please run 'pnpm install' locally to update pnpm-lock.yaml and commit it."
81- exit 1
82- }
70+ - run : |
71+ # Test API startup and basic functionality
72+ python -c "
73+ import sys
74+ sys.path.append('.')
75+ try:
76+ import api.main
77+ print('✅ API module imports successfully')
78+ except Exception as e:
79+ print(f'❌ API import failed: {e}')
80+ sys.exit(1)
81+ "
8382
84- - run : pnpm test
85- - run : pnpm run test:coverage
83+ - run : |
84+ # Test API endpoints if test file exists
85+ if [ -f "test_api.py" ]; then
86+ python test_api.py
87+ else
88+ echo "No API test file found, skipping API tests"
89+ fi
8690
87- - uses : codecov/codecov-action@v4
88- with :
89- file : ./backend/coverage/lcov.info
90- flags : backend
91- name : backend-coverage
92- fail_ci_if_error : false
91+ - run : |
92+ # Compile check for all Python files
93+ python -m py_compile start_api.py
94+ python -m py_compile config.py
95+ find api - name "*.py" -exec python -m py_compile {} \;
96+ find src -name "*.py" -exec python -m py_compile {} \;
9397
9498 python-ml-tests :
9599 name : Python ML Pipeline Tests
@@ -126,6 +130,11 @@ jobs:
126130 steps :
127131 - uses : actions/checkout@v4
128132
133+ - uses : actions/setup-python@v4
134+ with :
135+ python-version : " 3.9"
136+ cache : " pip"
137+
129138 - uses : pnpm/action-setup@v4
130139 with :
131140 version : 10
@@ -135,35 +144,50 @@ jobs:
135144 node-version : " 20.x"
136145 cache : " pnpm"
137146
138- # --- Lockfile sync check before running app ---
139- - name : Check lockfile sync
140- run : |
141- pnpm install --frozen-lockfile || pnpm install --no-frozen-lockfile
142-
143- - name : Install backend dependencies
144- run : pnpm install
145- working-directory : backend
147+ # --- Install Python dependencies ---
148+ - run : |
149+ python -m pip install --upgrade pip
150+ pip install -r requirements.txt
146151
147- - run : pnpm --filter gopredict-backend start &
152+ # --- Start Python backend ---
153+ - run : |
154+ python start_api.py --host 0.0.0.0 --port 8000 &
155+ echo $! > backend.pid
148156 env:
149157 PORT: 8000
150- DATABASE_URL : ${{ secrets.DATABASE_URL }}
151- JWT_SECRET : ${{ secrets.JWT_SECRET }}
152- NODE_ENV : " development"
158+ ENVIRONMENT: "test"
153159
160+ # --- Wait for backend to be ready ---
154161 - run : |
155162 echo "Waiting for backend to be ready..."
156163 for i in {1..60}; do
157- if curl -fsS http://localhost:8000/api/ health >/dev/null; then
164+ if curl -fsS http://localhost:8000/health >/dev/null; then
158165 echo "Backend is up"; break; fi
159166 sleep 1
160167 done
161- curl -f http://localhost:8000/api/ health
168+ curl -f http://localhost:8000/health
162169
170+ # --- Install frontend dependencies ---
163171 - name : Install frontend dependencies
164172 run : pnpm install
165173 working-directory : frontend
166174
167- - run : pnpm --filter gopredict-frontend build
175+ # --- Build frontend ---
176+ - run : pnpm build
177+ working-directory : frontend
168178 env :
169179 VITE_API_URL : http://localhost:8000
180+
181+ # --- Test API endpoints ---
182+ - run : |
183+ # Test basic API endpoints
184+ curl -f http://localhost:8000/health
185+ curl -f http://localhost:8000/status
186+ curl -f http://localhost:8000/docs
187+
188+ # --- Cleanup ---
189+ - run : |
190+ if [ -f backend.pid ]; then
191+ kill $(cat backend.pid) || true
192+ rm backend.pid
193+ fi
0 commit comments