@@ -7,6 +7,8 @@ import { readJsonFile, resolveFromRepo, writeJsonFile } from "./io.js";
77interface CommandSnapshot {
88 command : string ;
99 exitCode : number ;
10+ stdout : string ;
11+ stderr : string ;
1012}
1113
1214interface WriteQualityArtifactsInput {
@@ -84,12 +86,33 @@ function toMarkdown(report: QualityReport): string {
8486 `- outcome: ${ report . spec . outcome } ` ,
8587 `- summary: ${ report . spec . summary } ` ,
8688 `- build baseline/current: ${ String ( report . spec . comparedCommands . build . baselineExitCode ?? "n/a" ) } -> ${ report . spec . comparedCommands . build . currentExitCode } ` ,
89+ `- build stderr lines baseline/current: ${ String ( report . spec . comparedCommands . build . baselineStderrLines ?? "n/a" ) } -> ${ report . spec . comparedCommands . build . currentStderrLines } ` ,
8790 validationSection ,
8891 `- baseline store: ${ report . spec . target . baselineStorePath } ` ,
92+ report . spec . highlights . length > 0 ? "- highlights:" : "- highlights: none" ,
93+ ...report . spec . highlights . map ( ( entry ) => ` - ${ entry } ` ) ,
8994 ""
9095 ] . join ( "\n" ) ;
9196}
9297
98+ function countLines ( text : string ) : number {
99+ const normalized = text . trim ( ) ;
100+ if ( normalized . length === 0 ) {
101+ return 0 ;
102+ }
103+
104+ return normalized . split ( / \r ? \n / ) . length ;
105+ }
106+
107+ function firstUsefulLine ( text : string ) : string | undefined {
108+ const line = text
109+ . split ( / \r ? \n / )
110+ . map ( ( entry ) => entry . trim ( ) )
111+ . find ( ( entry ) => entry . length > 0 ) ;
112+
113+ return line ;
114+ }
115+
93116export async function writeQualityArtifacts ( input : WriteQualityArtifactsInput ) : Promise < QualityReportOutcome > {
94117 const { run, app, build, validation } = input ;
95118 const target = resolveQualityTarget ( run , app ) ;
@@ -111,8 +134,21 @@ export async function writeQualityArtifacts(input: WriteQualityArtifactsInput):
111134 } ,
112135 target,
113136 commands : {
114- build,
115- validation
137+ build : {
138+ command : build . command ,
139+ exitCode : build . exitCode ,
140+ stdoutLines : countLines ( build . stdout ) ,
141+ stderrLines : countLines ( build . stderr )
142+ } ,
143+ validation :
144+ typeof validation !== "undefined"
145+ ? {
146+ command : validation . command ,
147+ exitCode : validation . exitCode ,
148+ stdoutLines : countLines ( validation . stdout ) ,
149+ stderrLines : countLines ( validation . stderr )
150+ }
151+ : undefined
116152 }
117153 }
118154 } ;
@@ -173,16 +209,30 @@ export async function writeQualityArtifacts(input: WriteQualityArtifactsInput):
173209 comparedCommands : {
174210 build : {
175211 baselineExitCode : baselineForCompare ?. spec . commands . build . exitCode ,
176- currentExitCode : build . exitCode
212+ currentExitCode : build . exitCode ,
213+ baselineStdoutLines : baselineForCompare ?. spec . commands . build . stdoutLines ,
214+ currentStdoutLines : countLines ( build . stdout ) ,
215+ baselineStderrLines : baselineForCompare ?. spec . commands . build . stderrLines ,
216+ currentStderrLines : countLines ( build . stderr )
177217 } ,
178218 validation :
179219 typeof validation !== "undefined"
180220 ? {
181221 baselineExitCode : baselineForCompare ?. spec . commands . validation ?. exitCode ,
182- currentExitCode : validation . exitCode
222+ currentExitCode : validation . exitCode ,
223+ baselineStdoutLines : baselineForCompare ?. spec . commands . validation ?. stdoutLines ,
224+ currentStdoutLines : countLines ( validation . stdout ) ,
225+ baselineStderrLines : baselineForCompare ?. spec . commands . validation ?. stderrLines ,
226+ currentStderrLines : countLines ( validation . stderr )
183227 }
184228 : undefined
185- }
229+ } ,
230+ highlights : [
231+ firstUsefulLine ( build . stderr ) ? `build stderr: ${ firstUsefulLine ( build . stderr ) } ` : undefined ,
232+ typeof validation !== "undefined" && firstUsefulLine ( validation . stderr )
233+ ? `validation stderr: ${ firstUsefulLine ( validation . stderr ) } `
234+ : undefined
235+ ] . filter ( ( entry ) : entry is string => typeof entry === "string" )
186236 }
187237 } ;
188238
0 commit comments