deps: bump github.com/oapi-codegen/runtime from 1.6.0 to 1.7.0 #133
Workflow file for this run
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: Performance | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: [main] | |
| types: [labeled] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| concurrency: | |
| group: perf-api-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| go-benchmarks: | |
| name: Go Benchmarks | |
| if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'perf-test') | |
| runs-on: self-hosted | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Setup Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: '1.26.7' | |
| cache: true | |
| - name: Run benchmarks | |
| run: | | |
| go test -run='^$' -bench=. -benchmem -count=3 \ | |
| ./internal/service/flightcalc/... \ | |
| ./internal/service/currency/... \ | |
| ./internal/service/... \ | |
| | tee benchmark-results.txt | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: benchmark-results | |
| path: benchmark-results.txt | |
| k6-load-tests: | |
| name: k6 Load Tests | |
| if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'perf-test') | |
| runs-on: [self-hosted, docker-host] | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Install k6 | |
| run: | | |
| sudo gpg -k | |
| sudo gpg --no-default-keyring --keyring /usr/share/keyrings/k6-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C5AD17C747E3415A3642D57D77C6C491D6AC1D68 | |
| echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list | |
| sudo apt-get update | |
| sudo apt-get install -y k6 | |
| - name: Start performance stack | |
| run: docker compose -f docker-compose.perf.yaml up -d --build | |
| - name: Wait for API | |
| run: | | |
| for i in $(seq 1 60); do | |
| if curl -sf http://localhost:3334/health > /dev/null 2>&1; then | |
| echo "API is healthy" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| echo "API failed to start" | |
| docker compose -f docker-compose.perf.yaml logs api | |
| exit 1 | |
| - name: Seed performance data | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/seed.js --quiet | |
| - name: Run auth scenario | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/auth.js --summary-export=test/performance/results/auth.json || true | |
| - name: Run flights CRUD scenario | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/flights.js --summary-export=test/performance/results/flights.json || true | |
| - name: Run search scenario | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/search.js --summary-export=test/performance/results/search.json || true | |
| - name: Run dashboard scenario | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/dashboard.js --summary-export=test/performance/results/dashboard.json || true | |
| - name: Run exports scenario | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/exports.js --summary-export=test/performance/results/exports.json || true | |
| - name: Run spike test | |
| run: PERF_API_URL=http://localhost:3334 k6 run test/performance/scenarios/spike.js --summary-export=test/performance/results/spike.json || true | |
| - name: Generate k6 summary | |
| if: always() | |
| id: k6_summary | |
| run: | | |
| mkdir -p test/performance/results | |
| { | |
| echo "## k6 Load Test Results" | |
| echo "" | |
| echo "| Scenario | Requests | Error Rate | p95 | Status |" | |
| echo "|----------|----------|------------|-----|--------|" | |
| for f in test/performance/results/*.json; do | |
| [ -f "$f" ] || continue | |
| name=$(basename "$f" .json) | |
| reqs=$(python3 -c "import json; d=json.load(open('$f')); print(d.get('metrics',{}).get('http_reqs',{}).get('count',0))" 2>/dev/null || echo "?") | |
| err=$(python3 -c "import json; d=json.load(open('$f')); v=d.get('metrics',{}).get('http_req_failed',{}).get('value',0); print(f'{v*100:.2f}%')" 2>/dev/null || echo "?") | |
| p95=$(python3 -c "import json; d=json.load(open('$f')); v=d.get('metrics',{}).get('http_req_duration',{}).get('p(95)',0); print(f'{v:.1f}ms')" 2>/dev/null || echo "?") | |
| # Check if any thresholds were crossed | |
| crossed=$(python3 -c " | |
| import json | |
| d=json.load(open('$f')) | |
| thresholds = d.get('thresholds', {}) | |
| failed = any(not v.get('ok', True) for v in thresholds.values() if isinstance(v, dict)) | |
| print('Threshold crossed' if failed else 'Passed') | |
| " 2>/dev/null || echo "?") | |
| echo "| $name | $reqs | $err | $p95 | $crossed |" | |
| done | |
| } > test/performance/results/summary.md | |
| cat test/performance/results/summary.md >> "$GITHUB_STEP_SUMMARY" | |
| cat test/performance/results/summary.md | |
| - name: Comment k6 results on PR | |
| if: always() && github.event_name == 'pull_request' | |
| uses: marocchino/sticky-pull-request-comment@v3 | |
| with: | |
| header: k6-results | |
| path: test/performance/results/summary.md | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose -f docker-compose.perf.yaml down -v --remove-orphans |