|
| 1 | +name: E2E Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + e2e-tests: |
| 11 | + name: E2E Tests with Bruno |
| 12 | + runs-on: ubuntu-latest |
| 13 | + timeout-minutes: 30 |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout example service |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.12' |
| 23 | + |
| 24 | + - name: Install uv |
| 25 | + uses: astral-sh/setup-uv@v4 |
| 26 | + with: |
| 27 | + enable-cache: true |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: uv sync |
| 31 | + |
| 32 | + - name: Start service in background |
| 33 | + run: | |
| 34 | + uv run uvicorn main:app --host 127.0.0.1 --port 3003 & |
| 35 | + echo $! > service.pid |
| 36 | + echo "Service started with PID $(cat service.pid)" |
| 37 | +
|
| 38 | + - name: Checkout oicana repository (for Bruno tests) |
| 39 | + uses: actions/checkout@v4 |
| 40 | + with: |
| 41 | + repository: oicana/oicana |
| 42 | + path: oicana |
| 43 | + |
| 44 | + - name: Setup Node.js for Bruno CLI |
| 45 | + uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: '20' |
| 48 | + |
| 49 | + - name: Install Bruno CLI |
| 50 | + run: npm install -g @usebruno/cli |
| 51 | + |
| 52 | + - name: Wait for service to be ready |
| 53 | + run: | |
| 54 | + echo "Waiting for service on port 3003..." |
| 55 | + timeout=60 |
| 56 | + elapsed=0 |
| 57 | + while ! curl -f http://localhost:3003/templates 2>/dev/null; do |
| 58 | + if [ $elapsed -ge $timeout ]; then |
| 59 | + echo "Service did not start within ${timeout} seconds" |
| 60 | + if [ -f service.pid ]; then |
| 61 | + echo "Service PID: $(cat service.pid)" |
| 62 | + ps aux | grep $(cat service.pid) || echo "Service process not found" |
| 63 | + fi |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | + echo "Waiting... (${elapsed}s/${timeout}s)" |
| 67 | + sleep 2 |
| 68 | + elapsed=$((elapsed + 2)) |
| 69 | + done |
| 70 | + echo "Service is ready!" |
| 71 | +
|
| 72 | + - name: Run Bruno E2E tests |
| 73 | + working-directory: oicana/e2e-tests/bruno |
| 74 | + run: bru run --env fastapi --reporter-html results.html |
| 75 | + |
| 76 | + - name: Upload test results |
| 77 | + if: always() |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: test-results |
| 81 | + path: oicana/e2e-tests/bruno/results.html |
| 82 | + retention-days: 30 |
| 83 | + |
| 84 | + - name: Stop service |
| 85 | + if: always() |
| 86 | + run: | |
| 87 | + if [ -f service.pid ]; then |
| 88 | + PID=$(cat service.pid) |
| 89 | + echo "Stopping service with PID $PID" |
| 90 | + kill $PID || true |
| 91 | + # Wait for graceful shutdown |
| 92 | + sleep 5 |
| 93 | + # Force kill if still running |
| 94 | + kill -9 $PID 2>/dev/null || true |
| 95 | + fi |
0 commit comments