-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (94 loc) · 2.8 KB
/
Copy pathpython.yml
File metadata and controls
107 lines (94 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Python FastAPI CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
ruff:
name: Ruff checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install Ruff
run: python -m pip install --upgrade ruff
- name: Check Python syntax and names
run: |
ruff check . \
--output-format=github \
--select E9,F63,F7,F82
deploy-smoke-test:
name: Uvicorn startup test
needs: ruff
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements.txt
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip check
- name: Start Uvicorn and test setup status
env:
SCHOOLGPT_AUTH_SECRET_KEY: schoolgpt-ci-secret-key
SCHOOLGPT_CORS_ORIGINS: '["http://127.0.0.1"]'
run: |
set -euo pipefail
rm -f config/runtime_setup.json
uvicorn app:app \
--host 127.0.0.1 \
--port 8000 \
>uvicorn.log 2>&1 &
UVICORN_PID=$!
cleanup() {
kill "${UVICORN_PID}" 2>/dev/null || true
wait "${UVICORN_PID}" 2>/dev/null || true
}
trap cleanup EXIT
for attempt in {1..30}; do
if curl --fail --silent --show-error \
http://127.0.0.1:8000/api/setup/status \
--output setup-status.json
then
break
fi
if ! kill -0 "${UVICORN_PID}" 2>/dev/null; then
echo "Uvicorn exited unexpectedly."
cat uvicorn.log
exit 1
fi
sleep 2
done
if [ ! -f setup-status.json ]; then
echo "Uvicorn did not respond within 60 seconds."
cat uvicorn.log
exit 1
fi
echo "Setup status response:"
cat setup-status.json
echo
python - <<'PY'
import json
from pathlib import Path
response = json.loads(
Path("setup-status.json").read_text(encoding="utf-8")
)
assert response == {"is_configured": False}, (
f"Unexpected setup status: {response}"
)
print("Uvicorn startup and setup status checks passed.")
PY