Skip to content

Commit 990682f

Browse files
Mossakaclaude
andauthored
fix: separate stderr from stdout in benchmark to prevent invalid JSON (#1764)
* fix: separate stderr from stdout in benchmark to prevent invalid JSON The benchmark run step used `2>&1` which mixed stderr progress logs into benchmark-results.json, making downstream jq parsing silently fail. Now stderr goes to benchmark-progress.log, and a JSON validation step catches any corruption early. Closes #1757 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: move artifact upload before JSON validation with if: always() Address Copilot review: ensure artifacts are uploaded even when validation fails, so logs are available for debugging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a025d9f commit 990682f

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.github/workflows/performance-monitor.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,29 @@ jobs:
4747
- name: Run benchmarks
4848
id: benchmark
4949
run: |
50-
npx tsx scripts/ci/benchmark-performance.ts > benchmark-results.json 2>&1 || true
50+
npx tsx scripts/ci/benchmark-performance.ts > benchmark-results.json 2>benchmark-progress.log || true
51+
cat benchmark-progress.log
52+
echo "--- JSON output ---"
5153
cat benchmark-results.json
5254
5355
- name: Upload results
56+
if: always()
5457
uses: actions/upload-artifact@v4
5558
with:
5659
name: benchmark-results-${{ github.sha }}
57-
path: benchmark-results.json
60+
path: |
61+
benchmark-results.json
62+
benchmark-progress.log
5863
retention-days: 90
5964

65+
- name: Validate benchmark JSON
66+
run: |
67+
if ! jq empty benchmark-results.json 2>/dev/null; then
68+
echo "ERROR: benchmark-results.json is not valid JSON"
69+
cat benchmark-results.json
70+
exit 1
71+
fi
72+
6073
- name: Check for regressions
6174
id: check
6275
run: |

scripts/ci/benchmark-performance.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
* - Docker network creation time
1010
*
1111
* Outputs structured JSON with mean, median, p95, p99 per metric.
12+
*
13+
* IMPORTANT: stdout/stderr contract:
14+
* - stdout (console.log): JSON result only — consumed by the CI workflow via redirect to file
15+
* - stderr (console.error): progress messages and diagnostics — kept separate so JSON stays valid
1216
*/
1317

1418
import { execSync, ExecSyncOptions } from "child_process";

0 commit comments

Comments
 (0)