Skip to content

feat(cli): add --output-format json to upload and validate - #1277

Merged
trunk-io[bot] merged 1 commit into
dylan/trunk-22404-print-the-cli-summary-on-stdout-and-remove-endoutputfrom
dylan/trunk-22405-add-output-format-json-to-upload-and-validate
Nov 4, 2026
Merged

trunk-io[bot] merged 1 commit into
dylan/trunk-22404-print-the-cli-summary-on-stdout-and-remove-endoutputfrom
dylan/trunk-22405-add-output-format-json-to-upload-and-validate

Conversation

@dfrankland

Copy link
Copy Markdown
Member

Part of TRUNK-18881. Closes TRUNK-22405. Stacked on #1273 (which is stacked on #1266).

--output-format json (or TRUNK_OUTPUT_FORMAT=json) on upload and validate prints the summary on stdout as the same JSON that --summary-output-file writes, so it can be piped into other tools.

  • The flag is in its own OutputFormatArgs, used only by upload and validate. test doesn't get it: it includes UploadArgs, and its test command writes to stdout.
  • In JSON mode stdout carries only the JSON. Logs, notices and progress stay on stderr. The JSON is printed after the renderer has finished.
  • A run that fails outright still prints its JSON error object on stdout (and its text error on stderr).
  • Exit codes don't change.
  • The summary schema now covers the validate report ("type": "VALIDATE"), so summary-output-schema describes it too.

A run stopped by SIGINT/SIGTERM prints nothing on stdout, as in text mode.

Tests

New integration tests in cli/tests check that stdout parses as JSON (and matches --summary-output-file), that the exit code and exitCode agree, and that logs, notices and a progress message (mock API slowed to 3s) go to stderr, for upload, a failed upload via TRUNK_OUTPUT_FORMAT, and validate with and without errors.

🤖 Generated with Claude Code

@trunk-staging-io

trunk-staging-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

Failed Test Failure Summary Logs
pending_quarantine_test should be quarantined when run with variant A test marked as pending was expected to fail but unexpectedly passed. Logs ↗︎
variant_quarantine_test should be quarantined when run with variant The quarantine test failed because it expected 2 + 2 to equal 5, but the result was 4. Logs ↗︎

View Full Report ↗︎ ⋅ Docs

@codecov-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.91837% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.94%. Comparing base (f5fd8c5) to head (4e5a468).

Files with missing lines Patch % Lines
cli/src/main.rs 95.91% 2 Missing ⚠️
Additional details and impacted files
@@                                            Coverage Diff                                             @@
##           dylan/trunk-22404-print-the-cli-summary-on-stdout-and-remove-endoutput    #1277      +/-   ##
==========================================================================================================
+ Coverage                                                                   82.75%   85.94%   +3.19%     
==========================================================================================================
  Files                                                                          85       85              
  Lines                                                                       19105    19258     +153     
==========================================================================================================
+ Hits                                                                        15811    16552     +741     
+ Misses                                                                       3294     2706     -588     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dfrankland
dfrankland force-pushed the dylan/trunk-22405-add-output-format-json-to-upload-and-validate branch from f3d1ce1 to 4e5a468 Compare November 4, 2026 18:34
@trunk-io

trunk-io Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

😎 Stack merged successfully - details.

`--output-format json` (or `TRUNK_OUTPUT_FORMAT=json`) prints the summary on
stdout as the same JSON that `--summary-output-file` writes, instead of the
text summary. Logs, notices and progress stay on stderr, and a run that fails
outright prints its JSON error object on stdout. Exit codes don't change.

The flag lives in its own args struct used only by `upload` and `validate`:
`test` includes `UploadArgs`, and its test command writes to stdout.

The summary schema now covers the validate report (`"type": "VALIDATE"`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dfrankland
dfrankland force-pushed the dylan/trunk-22405-add-output-format-json-to-upload-and-validate branch from 4e5a468 to 66bbf52 Compare November 4, 2026 19:55
@trunk-io
trunk-io Bot merged commit b664845 into main Nov 4, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants