This commit is contained in:
@@ -34,30 +34,31 @@ jobs:
|
|||||||
|
|
||||||
- name: Start container (background)
|
- name: Start container (background)
|
||||||
run: |
|
run: |
|
||||||
docker run -d --name semapform-test -p 8001:8001 semapform-api:test-pr sleep infinity
|
# do NOT bind the container port to the host to avoid port conflicts on the runner
|
||||||
|
docker run -d --name semapform-test semapform-api:test-pr sleep infinity
|
||||||
|
|
||||||
- name: Verify python module imports
|
- name: Verify python module imports
|
||||||
run: |
|
run: |
|
||||||
docker exec semapform-test python -c "import api_service; print('import ok')"
|
docker exec semapform-test python -c "import api_service; print('import ok')"
|
||||||
|
|
||||||
- name: Start server in container and smoke test HTTP
|
- name: Start server in container and smoke test HTTP (in-container)
|
||||||
env:
|
|
||||||
PORT: 8001
|
|
||||||
run: |
|
run: |
|
||||||
# start uvicorn inside the container (background)
|
# start the server inside the container
|
||||||
docker exec -d semapform-test uv run uvicorn api_service:app --host 0.0.0.0 --port $PORT
|
docker exec -d semapform-test uv run uvicorn api_service:app --host 0.0.0.0 --port 8001
|
||||||
|
|
||||||
# wait for up to 20s for the server to respond
|
# perform an in-container HTTP check using Python stdlib (avoids requiring curl)
|
||||||
SECONDS=0
|
docker exec semapform-test python - << 'PY'
|
||||||
until curl -sS "http://localhost:${PORT}/" -o /dev/null; do
|
import time,urllib.request,sys
|
||||||
sleep 1
|
for _ in range(20):
|
||||||
SECONDS=$((SECONDS+1))
|
try:
|
||||||
if [ $SECONDS -ge 20 ]; then
|
urllib.request.urlopen('http://127.0.0.1:8001/health', timeout=2)
|
||||||
echo "server failed to respond within timeout" >&2
|
print('ok')
|
||||||
docker logs semapform-test || true
|
sys.exit(0)
|
||||||
exit 1
|
except Exception:
|
||||||
fi
|
time.sleep(1)
|
||||||
done
|
print('failed')
|
||||||
|
sys.exit(1)
|
||||||
|
PY
|
||||||
|
|
||||||
- name: Cleanup container
|
- name: Cleanup container
|
||||||
if: always()
|
if: always()
|
||||||
|
|||||||
Reference in New Issue
Block a user