Publish python example #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: E2E Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| e2e-tests: | |
| name: E2E Tests with Bruno | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout example service | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Start service in background | |
| run: | | |
| uv run uvicorn main:app --host 127.0.0.1 --port 3003 & | |
| echo $! > service.pid | |
| echo "Service started with PID $(cat service.pid)" | |
| - name: Checkout oicana repository (for Bruno tests) | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: oicana/oicana | |
| path: oicana | |
| - name: Setup Node.js for Bruno CLI | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Bruno CLI | |
| run: npm install -g @usebruno/cli | |
| - name: Wait for service to be ready | |
| run: | | |
| echo "Waiting for service on port 3003..." | |
| timeout=60 | |
| elapsed=0 | |
| while ! curl -f http://localhost:3003/templates 2>/dev/null; do | |
| if [ $elapsed -ge $timeout ]; then | |
| echo "Service did not start within ${timeout} seconds" | |
| if [ -f service.pid ]; then | |
| echo "Service PID: $(cat service.pid)" | |
| ps aux | grep $(cat service.pid) || echo "Service process not found" | |
| fi | |
| exit 1 | |
| fi | |
| echo "Waiting... (${elapsed}s/${timeout}s)" | |
| sleep 2 | |
| elapsed=$((elapsed + 2)) | |
| done | |
| echo "Service is ready!" | |
| - name: Run Bruno E2E tests | |
| working-directory: oicana/e2e-tests/bruno | |
| run: bru run --env fastapi --reporter-html results.html | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: oicana/e2e-tests/bruno/results.html | |
| retention-days: 30 | |
| - name: Stop service | |
| if: always() | |
| run: | | |
| if [ -f service.pid ]; then | |
| PID=$(cat service.pid) | |
| echo "Stopping service with PID $PID" | |
| kill $PID || true | |
| # Wait for graceful shutdown | |
| sleep 5 | |
| # Force kill if still running | |
| kill -9 $PID 2>/dev/null || true | |
| fi |