diff --git a/.gitea/workflows/test_pr.yml b/.gitea/workflows/test_pr.yml index 4be7bc2..0992795 100644 --- a/.gitea/workflows/test_pr.yml +++ b/.gitea/workflows/test_pr.yml @@ -34,30 +34,31 @@ jobs: - name: Start container (background) 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 run: | docker exec semapform-test python -c "import api_service; print('import ok')" - - name: Start server in container and smoke test HTTP - env: - PORT: 8001 + - name: Start server in container and smoke test HTTP (in-container) run: | - # start uvicorn inside the container (background) - docker exec -d semapform-test uv run uvicorn api_service:app --host 0.0.0.0 --port $PORT + # start the server inside the container + 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 - SECONDS=0 - until curl -sS "http://localhost:${PORT}/" -o /dev/null; do - sleep 1 - SECONDS=$((SECONDS+1)) - if [ $SECONDS -ge 20 ]; then - echo "server failed to respond within timeout" >&2 - docker logs semapform-test || true - exit 1 - fi - done + # perform an in-container HTTP check using Python stdlib (avoids requiring curl) + docker exec semapform-test python - << 'PY' + import time,urllib.request,sys + for _ in range(20): + try: + urllib.request.urlopen('http://127.0.0.1:8001/health', timeout=2) + print('ok') + sys.exit(0) + except Exception: + time.sleep(1) + print('failed') + sys.exit(1) + PY - name: Cleanup container if: always()