|
| 1 | +name: CI |
| 2 | +description: Basic CI just to ensure that example keeps working after dependency updates |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ main, master ] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-and-smoke-test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + timeout-minutes: 10 |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Python |
| 19 | + uses: actions/setup-python@v4 |
| 20 | + with: |
| 21 | + python-version: '3.14' |
| 22 | + |
| 23 | + - name: Install system dependencies |
| 24 | + run: | |
| 25 | + sudo apt-get update && sudo apt-get install -y libsqlite3-dev |
| 26 | +
|
| 27 | + - name: Install Python dependencies |
| 28 | + run: | |
| 29 | + python -m pip install --upgrade pip |
| 30 | + pip install --no-cache-dir -r requirements.txt |
| 31 | +
|
| 32 | + - name: Compile apywire container |
| 33 | + run: python src/app.py --compile |
| 34 | + |
| 35 | + - name: Start application (uvicorn) |
| 36 | + run: | |
| 37 | + nohup python -m uvicorn src.app:create_app --factory --host 127.0.0.1 --port 8000 > /tmp/uvicorn.log 2>&1 & |
| 38 | + echo $! > /tmp/uvicorn.pid |
| 39 | +
|
| 40 | + - name: Wait for HTTP endpoint |
| 41 | + run: | |
| 42 | + for i in $(seq 1 30); do |
| 43 | + if curl -sS http://127.0.0.1:8000/ >/dev/null 2>&1; then |
| 44 | + echo "service is up"; break |
| 45 | + fi |
| 46 | + echo "waiting for service... ($i/30)"; sleep 1 |
| 47 | + done |
| 48 | + curl -sS http://127.0.0.1:8000/ || (tail -n +1 /tmp/uvicorn.log && exit 1) |
| 49 | +
|
| 50 | + - name: Verify JSON response |
| 51 | + run: | |
| 52 | + python - <<'PY' |
| 53 | + import sys, json, urllib.request |
| 54 | + expected = {"message": "Hello World!"} |
| 55 | + try: |
| 56 | + with urllib.request.urlopen("http://127.0.0.1:8000/") as r: |
| 57 | + actual = json.load(r) |
| 58 | + except Exception as e: |
| 59 | + print("Request failed:", e); sys.exit(2) |
| 60 | + if actual != expected: |
| 61 | + print("Response mismatch: expected=%r actual=%r" % (expected, actual)) |
| 62 | + sys.exit(1) |
| 63 | + print("Response matches expected") |
| 64 | + PY |
| 65 | +
|
| 66 | + - name: Cleanup |
| 67 | + if: always() |
| 68 | + run: | |
| 69 | + if [ -f /tmp/uvicorn.pid ]; then kill "$(cat /tmp/uvicorn.pid)" || true; fi |
| 70 | + sleep 1 |
| 71 | + tail -n +1 /tmp/uvicorn.log || true |
0 commit comments