|
| 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: Setup .NET |
| 20 | + uses: actions/setup-dotnet@v4 |
| 21 | + with: |
| 22 | + dotnet-version: '8.0.x' |
| 23 | + |
| 24 | + - name: Build service |
| 25 | + run: dotnet build -c Release |
| 26 | + |
| 27 | + - name: Start service in background |
| 28 | + run: | |
| 29 | + dotnet run --no-build -c Release & |
| 30 | + echo $! > service.pid |
| 31 | + echo "Service started with PID $(cat service.pid)" |
| 32 | +
|
| 33 | + - name: Checkout oicana repository (for Bruno tests) |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + repository: oicana/oicana |
| 37 | + path: oicana |
| 38 | + |
| 39 | + - name: Setup Node.js for Bruno CLI |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '20' |
| 43 | + |
| 44 | + - name: Install Bruno CLI |
| 45 | + run: npm install -g @usebruno/cli |
| 46 | + |
| 47 | + - name: Wait for service to be ready |
| 48 | + run: | |
| 49 | + echo "Waiting for service on port 3002..." |
| 50 | + timeout=60 |
| 51 | + elapsed=0 |
| 52 | + while ! curl -f http://localhost:3002/templates 2>/dev/null; do |
| 53 | + if [ $elapsed -ge $timeout ]; then |
| 54 | + echo "Service did not start within ${timeout} seconds" |
| 55 | + if [ -f service.pid ]; then |
| 56 | + echo "Service PID: $(cat service.pid)" |
| 57 | + ps aux | grep $(cat service.pid) || echo "Service process not found" |
| 58 | + fi |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | + echo "Waiting... (${elapsed}s/${timeout}s)" |
| 62 | + sleep 2 |
| 63 | + elapsed=$((elapsed + 2)) |
| 64 | + done |
| 65 | + echo "Service is ready!" |
| 66 | +
|
| 67 | + - name: Run Bruno E2E tests |
| 68 | + working-directory: oicana/e2e-tests/bruno |
| 69 | + run: bru run --env aspnet --reporter-html results.html |
| 70 | + |
| 71 | + - name: Upload test results |
| 72 | + if: always() |
| 73 | + uses: actions/upload-artifact@v4 |
| 74 | + with: |
| 75 | + name: test-results |
| 76 | + path: oicana/e2e-tests/bruno/results.html |
| 77 | + retention-days: 30 |
| 78 | + |
| 79 | + - name: Stop service |
| 80 | + if: always() |
| 81 | + run: | |
| 82 | + if [ -f service.pid ]; then |
| 83 | + PID=$(cat service.pid) |
| 84 | + echo "Stopping service with PID $PID" |
| 85 | + kill $PID || true |
| 86 | + # Wait for graceful shutdown |
| 87 | + sleep 5 |
| 88 | + # Force kill if still running |
| 89 | + kill -9 $PID 2>/dev/null || true |
| 90 | + fi |
0 commit comments