chore(deps): bump express-rate-limit from 7.5.1 to 8.5.2 in /services/tts #952
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 Tests | |
| on: | |
| pull_request: | |
| branches: [main, develop] | |
| push: | |
| branches: [main] | |
| schedule: | |
| # Run nightly at 2 AM UTC | |
| - cron: "0 2 * * *" | |
| workflow_dispatch: | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| backend-performance: | |
| name: Backend Performance Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: predictiq_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build API service | |
| working-directory: services/api | |
| run: cargo build --release | |
| - name: Run database migrations | |
| working-directory: services/api | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/predictiq_test | |
| run: | | |
| cargo install sqlx-cli --no-default-features --features postgres | |
| sqlx migrate run | |
| - name: Start API server | |
| working-directory: services/api | |
| env: | |
| DATABASE_URL: postgresql://postgres:postgres@localhost:5432/predictiq_test | |
| REDIS_URL: redis://localhost:6379 | |
| RUST_LOG: info | |
| run: | | |
| cargo run --release & | |
| echo $! > api.pid | |
| sleep 10 | |
| - name: Wait for API to be ready | |
| run: | | |
| timeout 30 bash -c 'until curl -f http://localhost:8080/health; do sleep 1; done' | |
| - 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 C5AD17C747E3415A3642D57D77C6C491D6AC1D69 | |
| 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 k6 | |
| - name: Run smoke tests | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/smoke-test-raw.json backend/k6/smoke-test.js | |
| - name: Run load tests | |
| if: github.event_name != 'pull_request' | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/load-test-raw.json backend/k6/load-test.js | |
| - name: Run cache tests | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/cache-test-raw.json backend/k6/cache-test.js | |
| - name: Run blockchain data endpoints load test | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/blockchain-load-test-raw.json backend/k6/blockchain-load-test.js | |
| - name: Run rate limit tests | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/rate-limit-test-raw.json backend/k6/rate-limit-test.js | |
| - name: Run stress tests (nightly only) | |
| if: github.event_name == 'schedule' | |
| working-directory: performance | |
| env: | |
| API_URL: http://localhost:8080 | |
| run: k6 run --out json=backend/reports/stress-test-raw.json backend/k6/stress-test.js | |
| - name: Generate performance report | |
| if: always() | |
| working-directory: performance | |
| run: | | |
| npm install | |
| node scripts/generate-report.js | |
| - name: Upload performance reports | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: performance-reports | |
| path: performance/backend/reports/ | |
| retention-days: 30 | |
| - name: Check performance thresholds | |
| if: always() | |
| working-directory: performance | |
| run: | | |
| if [ -f backend/reports/load-test-summary.json ]; then | |
| node -e " | |
| const data = require('./backend/reports/load-test-summary.json'); | |
| const p95 = data.metrics.http_req_duration.values['p(95)']; | |
| const errorRate = data.metrics.http_req_failed.values.rate; | |
| console.log('Performance Metrics:'); | |
| console.log('P95 Response Time:', p95.toFixed(2), 'ms'); | |
| console.log('Error Rate:', (errorRate * 100).toFixed(2), '%'); | |
| if (p95 > 200) { | |
| console.error('❌ P95 response time exceeds 200ms threshold'); | |
| process.exit(1); | |
| } | |
| if (errorRate > 0.001) { | |
| console.error('❌ Error rate exceeds 0.1% threshold'); | |
| process.exit(1); | |
| } | |
| console.log('✅ All performance thresholds met'); | |
| " | |
| fi | |
| - name: Comment PR with results | |
| if: github.event_name == 'pull_request' && always() | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = 'performance/backend/reports/smoke-test-summary.json'; | |
| if (fs.existsSync(path)) { | |
| const data = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| const metrics = data.metrics; | |
| const comment = `## 🚀 Performance Test Results | |
| **Smoke Test Summary:** | |
| - Total Requests: ${metrics.http_reqs.values.count} | |
| - Avg Response Time: ${metrics.http_req_duration.values.avg.toFixed(2)}ms | |
| - P95 Response Time: ${metrics.http_req_duration.values['p(95)'].toFixed(2)}ms | |
| - Error Rate: ${(metrics.http_req_failed.values.rate * 100).toFixed(2)}% | |
| **Status:** ${metrics.http_req_duration.values['p(95)'] < 200 && metrics.http_req_failed.values.rate < 0.001 ? '✅ PASS' : '❌ FAIL'} | |
| [View detailed report](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| `; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } | |
| - name: Stop API server | |
| if: always() | |
| run: | | |
| if [ -f services/api/api.pid ]; then | |
| kill $(cat services/api/api.pid) || true | |
| fi | |
| contract-benchmarks: | |
| name: Smart Contract Benchmarks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rs/toolchain@v1 | |
| with: | |
| toolchain: stable | |
| override: true | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install Soroban CLI | |
| run: cargo install --locked soroban-cli --version 20.0.0 | |
| - name: Run contract benchmarks | |
| working-directory: contracts/predict-iq | |
| run: | | |
| cargo bench --bench gas_benchmark -- --save-baseline main | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: contract-benchmarks | |
| path: contracts/predict-iq/target/criterion/ | |
| retention-days: 30 | |
| - name: Compare with baseline | |
| if: github.event_name == 'pull_request' | |
| working-directory: contracts/predict-iq | |
| run: | | |
| if [ -d "target/criterion/baseline" ]; then | |
| cargo bench --bench gas_benchmark -- --baseline main | |
| fi | |
| performance-regression: | |
| name: Performance Regression Detection | |
| runs-on: ubuntu-latest | |
| needs: [backend-performance] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download current results | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: performance-reports | |
| path: performance/backend/reports/ | |
| - name: Checkout baseline branch | |
| continue-on-error: true | |
| run: | | |
| git fetch origin main:main | |
| git show main:.performance-baselines/ > /dev/null 2>&1 && \ | |
| git show main:.performance-baselines/ | tar -xz -C . || \ | |
| echo "No baselines found on main branch" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "18" | |
| - name: Compare results against baseline | |
| working-directory: performance | |
| run: | | |
| node scripts/compare-results.js --branch main --threshold 10 | |
| - name: Upload regression report | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: regression-report | |
| path: performance/backend/reports/regression-report.md | |
| retention-days: 30 | |
| - name: Comment PR with regression report | |
| if: always() | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = 'performance/backend/reports/regression-report.md'; | |
| if (fs.existsSync(path)) { | |
| const report = fs.readFileSync(path, 'utf8'); | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: report | |
| }); | |
| } | |
| - name: Fail if regression detected | |
| if: failure() | |
| run: | | |
| echo "❌ Performance regression detected. Check the PR comment for details." | |
| exit 1 | |
| save-performance-baseline: | |
| name: Save Performance Baseline | |
| runs-on: ubuntu-latest | |
| needs: [backend-performance] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download performance results | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: performance-reports | |
| path: performance/backend/reports/ | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "18" | |
| - name: Save baseline for main branch | |
| working-directory: performance | |
| run: | | |
| node scripts/compare-results.js --save-baseline --branch main | |
| - name: Commit and push baselines | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if [ -n "$(git status --porcelain .performance-baselines/)" ]; then | |
| git add .performance-baselines/ | |
| git commit -m "chore: update performance baselines for main branch" | |
| git push origin main | |
| else | |
| echo "No baseline changes to commit" | |
| fi |