Repository navigation
Add a hidden github-annotations command for the uploader action - #1265
trunk-io[bot] merged 2 commits into
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dylan/trunk-19074-no-tests-exit-code #1265 +/- ##
========================================================================
+ Coverage 82.40% 85.62% +3.21%
========================================================================
Files 85 86 +1
Lines 18919 19235 +316
========================================================================
+ Hits 15591 16470 +879
+ Misses 3328 2765 -563 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TylerJang27
left a comment
There was a problem hiding this comment.
nit: would like to see an example annotation of this in action
`trunk-analytics-cli github-annotations --summary-file <path>` reads the summary that --summary-output-file wrote and prints GitHub Actions workflow commands saying why the run failed. The analytics-uploader action calls it when the CLI exits non-zero, so the CLI words the failure and the action never reads the summary's format. - Exits 0 only when it printed an annotation. A summary with nothing to say, or one it can't read, exits 1 so the action falls back to its own message. - Runs before Sentry, logging and the renderer start, so stdout carries only the workflow commands. - Follows the text summary: an error that blocks quarantining is the only annotation; any other upload error is a warning; then the outcome. Each failure that wasn't quarantined gets its own annotation with its file, up to 9, since GitHub shows 10 errors per step. - The wording is shared with the text summary through constants in report/text.rs, including the "failed without running tests" line. To read the file back, the report types derive Deserialize, ExitCode reads a number back as its named code (or PassedThrough), and json::from_str rejects a schemaVersion newer than it knows. Refs TRUNK-19074 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r schemas that still parse
- Report::{schema, to_json, write_file}, and Summary::read_file plus FromStr, replace json::* free functions.
- A newer schemaVersion only fails when the summary doesn't parse; one that does is read with a warning.
- An unknown error kind from a newer CLI reads as OTHER instead of failing the whole summary.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e01cff0 to
0b056b4
Compare
|
@TylerJang27 here's what On GitHub this renders as one run-level error, then one error per failed test. Each test error is titled Roughly how it renders (a mockup of the Annotations box on the run's summary page, with the escapes decoded)
|
|
😎 Stack merged successfully - details. |
Stacked on #1253. Part of TRUNK-19074.
Adds the hidden
github-annotationscommand that trunk-io/analytics-uploader#153 calls. It reads the summary--summary-output-filewrote (#1246) and prints GitHub Actions annotations saying why the run failed. The CLI words the failure, and the action never reads the summary's format.Interface (what #153 assumes).
trunk-analytics-cli github-annotations --summary-file <path>, hidden from--help.%, CR and LF in messages; also:and,infile/title).Cli::parse()moves to the top ofmain(), before Sentry init. Parsing spawns nothing, so the "init Sentry before threads" rule still holds.What it says. It follows
render_upload:::warning::before the outcome.--disable-quarantining, or turned off in Trunk). Then one annotation per failed test, withfile=when known,title=suite/name, up to 20 lines of the failure message and its Trunk link. At most 9 tests are annotated, since GitHub shows 10 errors per step; the headline says when there are more.type: "ERROR"): the same lines asrender_error, minus the exit code line.The wording comes from constants in
report/text.rsthat the text summary now uses too, so the two can't drift.Reading the summary back.
Deserialize.ExitCodereads a number back as its named code, orPassedThroughfor anything else.json::from_str/json::read_filereturn an ownedjson::Summary. AschemaVersionnewer than the CLI knows is an error rather than a guess.Choices worth a look.
ExitCode::Failure(1), not a new documented code. The command is hidden and only the action calls it, so a new variant would only add noise to--helpand the schema.Testing.
cli/tests/summary/github.rs: each outcome, escaping, the 9-annotation cap, both error paths, the schema-version check, the round trip, and two that run the binary (prints and exits 0; exits 1 with empty stdout for a passing run and for a missing file).cargo test -p trunk-analytics-cli -p test_report -p constants: all pass except the three Swift xunit tests intests/upload.rs, which fail the same way on the base branch locally.cargo clippy -p trunk-analytics-cli --tests: no new warnings.cargo fmt --all --check: clean.🤖 Generated with Claude Code