Skip to content

Commit

Permalink
Truncate long values in job summary table
Browse files Browse the repository at this point in the history
Fixes #343
  • Loading branch information
bigdaz committed Aug 17, 2022
1 parent 3309808 commit 1c1a43b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/demo-job-summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
run: |
./gradlew tasks --no-daemon
./gradlew help check
./gradlew wrapper --gradle-version 7.4.2 --gradle-distribution-sha256-sum 29e49b10984e585d8118b7d0bc452f944e386458df27371b49b4ac1dec4b7fda
- name: Fail groovy-dsl project
working-directory: .github/workflow-samples/groovy-dsl
continue-on-error: true
Expand Down
12 changes: 10 additions & 2 deletions src/job-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function writeSummaryTable(results: BuildResult[]): void {
function renderBuildResultRow(result: BuildResult): string {
return `
<tr>
<td>${result.rootProjectName}</td>
<td>${result.requestedTasks}</td>
<td>${truncateString(result.rootProjectName, 30)}</td>
<td>${truncateString(result.requestedTasks, 60)}</td>
<td align='center'>${result.gradleVersion}</td>
<td align='center'>${renderOutcome(result)}</td>
<td>${renderBuildScan(result)}</td>
Expand Down Expand Up @@ -92,3 +92,11 @@ function logSummaryTable(results: BuildResult[]): void {
}
core.info('============================')
}

function truncateString(str: string, maxLength: number): string {
if (str.length > maxLength) {
return `${str.slice(0, maxLength - 3)}...`
} else {
return str
}
}

0 comments on commit 1c1a43b

Please sign in to comment.