MCPcopy
hub / github.com/stepci/stepci / renderSummary

Function renderSummary

src/lib/render.ts:176–197  ·  view source on GitHub ↗
(result: WorkflowResult['result'])

Source from the content-addressed store, hash-verified

174}
175
176export function renderSummary (result: WorkflowResult['result']) {
177 const passedTests = result.tests.filter(test => test.passed).length
178 const failedTests = result.tests.filter(test => !test.passed).length
179
180 const steps = result.tests.map(test => test.steps).flat()
181 const passedSteps = steps.filter(step => step.passed).length
182 const skippedSteps = steps.filter(step => step.skipped).length
183 const failedSteps = steps.filter(step => !step.passed).length
184
185 function colorIfNonZero(n: number, color: Chalk, text: string): string {
186 return n > 0 ? color.bold(text) : chalk.bold(text)
187 }
188
189 console.log(`\n${chalk.bold('Tests:')} ${colorIfNonZero(failedTests, chalk.redBright, failedTests + ' failed')}, ${colorIfNonZero(passedTests, chalk.greenBright, passedTests + ' passed')}, ${result.tests.length} total`)
190 console.log(`${chalk.bold('Steps:')} ${colorIfNonZero(failedSteps, chalk.redBright, failedSteps + ' failed')}, ${colorIfNonZero(skippedSteps, chalk.yellowBright, skippedSteps + ' skipped')}, ${colorIfNonZero(passedSteps, chalk.greenBright, passedSteps + ' passed')}, ${steps.length} total`)
191 console.log(`${chalk.bold('Time:')} ${result.duration / 1000}s, estimated ${(result.duration / 1000).toFixed(0)}s`)
192 console.log(`${chalk.bold('CO2:')} ${chalk.greenBright(result.co2.toFixed(5) + 'g')}`)
193 console.log(result.passed
194 ? chalk.greenBright(`\nWorkflow passed after ${result.duration / 1000}s`)
195 : chalk.redBright(`\nWorkflow failed after ${result.duration / 1000}s`)
196 )
197}
198
199export function renderFeedbackMessage () {
200 console.log(chalk.cyanBright(`Give us your feedback on ${chalk.underline('https://step.ci/feedback')}`))

Callers 1

index.tsFile · 0.90

Calls 1

colorIfNonZeroFunction · 0.85

Tested by

no test coverage detected