diff --git a/.github/workflows/performance-monitor.yml b/.github/workflows/performance-monitor.yml index db34cd61..9fc613dc 100644 --- a/.github/workflows/performance-monitor.yml +++ b/.github/workflows/performance-monitor.yml @@ -47,16 +47,29 @@ jobs: - name: Run benchmarks id: benchmark run: | - npx tsx scripts/ci/benchmark-performance.ts > benchmark-results.json 2>&1 || true + npx tsx scripts/ci/benchmark-performance.ts > benchmark-results.json 2>benchmark-progress.log || true + cat benchmark-progress.log + echo "--- JSON output ---" cat benchmark-results.json - name: Upload results + if: always() uses: actions/upload-artifact@v4 with: name: benchmark-results-${{ github.sha }} - path: benchmark-results.json + path: | + benchmark-results.json + benchmark-progress.log retention-days: 90 + - name: Validate benchmark JSON + run: | + if ! jq empty benchmark-results.json 2>/dev/null; then + echo "ERROR: benchmark-results.json is not valid JSON" + cat benchmark-results.json + exit 1 + fi + - name: Check for regressions id: check run: | diff --git a/scripts/ci/benchmark-performance.ts b/scripts/ci/benchmark-performance.ts index d0112cb6..4023ccfe 100644 --- a/scripts/ci/benchmark-performance.ts +++ b/scripts/ci/benchmark-performance.ts @@ -9,6 +9,10 @@ * - Docker network creation time * * Outputs structured JSON with mean, median, p95, p99 per metric. + * + * IMPORTANT: stdout/stderr contract: + * - stdout (console.log): JSON result only — consumed by the CI workflow via redirect to file + * - stderr (console.error): progress messages and diagnostics — kept separate so JSON stays valid */ import { execSync, ExecSyncOptions } from "child_process";