Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate long values in job summary table #87

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/demo-job-summary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
./gradlew tasks --no-daemon
./gradlew help check
./gradlew wrapper --gradle-version 8.7 --gradle-distribution-sha256-sum 544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
- name: Fail groovy-dsl project
working-directory: .github/workflow-samples/groovy-dsl
continue-on-error: true
Expand Down
12 changes: 10 additions & 2 deletions sources/src/job-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ function renderSummaryTable(results: BuildResult[]): string {
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 @@ -157,3 +157,11 @@ function shouldAddJobSummary(option: params.JobSummaryOption, buildResults: Buil
return buildResults.some(result => result.buildFailed)
}
}

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