Add load testing job to GitHub Actions CI pipeline (FRE-4931)

- Add load-test job to ci.yml that runs after docker-build on push to main
- Create combined load test runner (scripts/load-test/run-all.sh) for all services
- Create k6 load test scripts for api, darkwatch, spamshield, and voiceprint
- Add shared k6 utilities (lib/common.js)
- Update load-test.yml to support all services and report artifacts
- Configure k6 cloud output and P99 threshold validation
- Generate load test report as CI artifact

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-05-09 09:16:36 -04:00
parent 98b01bf48f
commit a804cab431
8 changed files with 439 additions and 13 deletions

View File

@@ -177,3 +177,54 @@ jobs:
env:
TF_VAR_hibp_api_key: ${{ secrets.HIBP_API_KEY }}
TF_VAR_resend_api_key: ${{ secrets.RESEND_API_KEY }}
load-test:
name: Load Test
runs-on: ubuntu-latest
needs: [lint, typecheck, test, docker-build]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
environment: staging
steps:
- uses: actions/checkout@v4
- name: Install k6
run: |
curl -s https://github.com/grafana/k6/releases/download/v0.50.0/k6-linux-amd64.tar.gz -L | tar xz
sudo mv k6 /usr/local/bin/
k6 version
- name: Run combined load tests
run: |
chmod +x scripts/load-test/run-all.sh
./scripts/load-test/run-all.sh
env:
LOAD_TEST_BASE_URL: ${{ secrets.LOAD_TEST_BASE_URL || 'http://localhost:3000' }}
API_TOKEN: ${{ secrets.LOAD_TEST_API_TOKEN || 'test-token' }}
TARGET_RPS: ${{ vars.LOAD_TEST_TARGET_RPS || '500' }}
DURATION: ${{ vars.LOAD_TEST_DURATION || '300s' }}
K6_CLOUD_TOKEN: ${{ secrets.K6_CLOUD_TOKEN || '' }}
K6_CLOUD_PROJECT_ID: ${{ vars.K6_CLOUD_PROJECT_ID || '' }}
- name: Upload load test report
if: always()
uses: actions/upload-artifact@v4
with:
name: load-test-report-${{ github.sha }}
path: scripts/load-test/reports/
retention-days: 30
- name: Check P99 thresholds
if: always()
run: |
if [ -f scripts/load-test/reports/threshold-results.json ]; then
FAILURES=$(jq -r '.metrics | to_entries[] | select(.value.passes == false) | .key' scripts/load-test/reports/threshold-results.json)
if [ -n "$FAILURES" ]; then
echo "❌ P99 threshold failures:"
echo "$FAILURES"
exit 1
else
echo "✅ All P99 thresholds passed"
fi
else
echo "No threshold results file found"
fi