Skip to content

Expose Last Successful Poll Timestamp #38

Expose Last Successful Poll Timestamp

Expose Last Successful Poll Timestamp #38

Workflow file for this run

name: Stress Tests
on:
pull_request:
paths:
- 'listener/src/services/**'
- 'listener/src/__tests__/stress.test.ts'
- 'listener/src/utils/benchmark-utils.ts'
push:
branches:
- main
- staging
schedule:
# Run nightly at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
report_path:
description: 'Custom path for test report'
required: false
default: 'reports/stress-test-report.json'
jobs:
stress-tests:
name: Run Stress Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
cache-dependency-path: listener/package-lock.json
- name: Install dependencies
working-directory: listener
run: npm ci
- name: Create reports directory
run: mkdir -p listener/reports
- name: Run stress tests
working-directory: listener
run: npm run stress-test -- --report ${{ github.event.inputs.report_path || 'reports/stress-test-report.json' }}
continue-on-error: true
- name: Display test summary
if: always()
working-directory: listener
run: |
if [ -f reports/stress-test-report.json ]; then
echo "## Stress Test Summary"
cat reports/stress-test-report.json | jq -r '.summary | "Total Tests: \(.totalTests)\nPassed: \(.passed)\nFailed: \(.failed)\nDuration: \(.totalDuration)ms"'
else
echo "No test report generated"
fi
- name: Upload stress test report
if: always()
uses: actions/upload-artifact@v4
with:
name: stress-test-report-${{ github.run_number }}
path: listener/reports/stress-test-report.json
retention-days: 30
- name: Check test results
working-directory: listener
run: |
if [ -f reports/stress-test-report.json ]; then
FAILED=$(cat reports/stress-test-report.json | jq -r '.summary.failed')
if [ "$FAILED" -gt 0 ]; then
echo "❌ $FAILED stress test(s) failed"
exit 1
else
echo "✅ All stress tests passed"
fi
else
echo "❌ Test report not found"
exit 1
fi
- name: Comment PR with results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const reportPath = 'listener/reports/stress-test-report.json';
if (!fs.existsSync(reportPath)) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## 🔥 Stress Test Results\n\n❌ Test report generation failed. Check workflow logs for details.'
});
return;
}
const report = JSON.parse(fs.readFileSync(reportPath, 'utf8'));
const statusIcon = report.summary.failed === 0 ? '✅' : '❌';
const durationMinutes = (report.summary.totalDuration / 1000 / 60).toFixed(2);
const comment = `## 🔥 Stress Test Results ${statusIcon}
**Summary:**
- Total Tests: ${report.summary.totalTests}
- Passed: ✅ ${report.summary.passed}
- Failed: ❌ ${report.summary.failed}
- Duration: ${durationMinutes} minutes
- Success Rate: ${((report.summary.passed / report.summary.totalTests) * 100).toFixed(2)}%
**Environment:**
- Node: ${report.environment.nodeVersion}
- Platform: ${report.environment.platform}
- CPUs: ${report.environment.cpus}
- Memory: ${report.environment.totalMemory}
**Test Results:**
${report.testResults.slice(0, 10).map(t => `- ${t.passed ? '✅' : '❌'} ${t.testName}`).join('\n')}
${report.testResults.length > 10 ? `\n... and ${report.testResults.length - 10} more tests` : ''}
📊 Full report available in workflow artifacts.`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
performance-baseline:
name: Compare Against Baseline
runs-on: ubuntu-latest
needs: stress-tests
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download current report
uses: actions/download-artifact@v4
with:
name: stress-test-report-${{ github.run_number }}
path: ./current-report
- name: Get baseline report from main branch
run: |
git checkout main -- listener/reports/stress-test-baseline.json || echo "No baseline found"
- name: Compare performance
run: |
if [ -f listener/reports/stress-test-baseline.json ] && [ -f current-report/stress-test-report.json ]; then
echo "## Performance Comparison"
echo "Comparing current results against baseline..."
# Extract key metrics and compare
# This is a placeholder - implement actual comparison logic
echo "Baseline and current reports found. Manual comparison recommended."
else
echo "Baseline report not found. This will become the new baseline if merged."
fi