Skip to content

Commit 9bee852

Browse files
committed
chore(ci): stabilize backend container and enable API startup before pytest
1 parent 6144c7d commit 9bee852

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,48 @@ jobs:
6666
6767
- name: 🔁 Alembic upgrade
6868
working-directory: backend
69+
env:
70+
DATABASE_URL: ${{ env.DATABASE_URL }}
6971
run: alembic upgrade head
7072

73+
- name: 🚀 Start API (background)
74+
working-directory: backend
75+
env:
76+
DATABASE_URL: ${{ env.DATABASE_URL }}
77+
run: |
78+
nohup .venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000 > uvicorn.log 2>&1 &
79+
echo $! > uvicorn.pid
80+
sleep 1
81+
82+
- name: ⏳ Wait for readiness
83+
run: |
84+
for i in {1..60}; do
85+
curl -fsS http://127.0.0.1:8000/api/ready && exit 0
86+
sleep 1
87+
done
88+
echo "❌ API not ready on :8000" >&2
89+
echo "----- uvicorn.log (tail) -----"
90+
sed -n '1,200p' backend/uvicorn.log || true
91+
exit 1
92+
7193
- name: 🧪 Pytest
7294
working-directory: backend
95+
env:
96+
DATABASE_URL: ${{ env.DATABASE_URL }}
7397
run: pytest -q
7498

75-
- name: 🩺 Health smoke
99+
- name: 📜 Show API log on failure
100+
if: failure()
76101
working-directory: backend
77102
run: |
78-
.venv/bin/uvicorn app.main:app --port 8000 &
79-
for i in {1..30}; do
80-
curl -fsS http://localhost:8000/api/health && exit 0
81-
sleep 2
82-
done
83-
echo "❌ Health endpoint not ready" >&2; exit 1
103+
echo "----- uvicorn.log (tail) -----"
104+
tail -n 200 uvicorn.log || true
84105
85-
- name: 🧹 Cleanup UVicorn (always)
106+
- name: 🧹 Cleanup (always)
86107
if: always()
87-
run: pkill -f "uvicorn" || true
108+
run: |
109+
if [ -f backend/uvicorn.pid ]; then kill "$(cat backend/uvicorn.pid)" 2>/dev/null || true; fi
110+
docker rm -f workmate-db 2>/dev/null || true
88111
89112
90113
frontend:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ backend/logs/
3333

3434
# Ignore local configs
3535
*.local
36+
37+
tree.txt
38+
notes-gpt.txt

0 commit comments

Comments
 (0)