From cc54166e15229e5186c63c763e1be30409d5d617 Mon Sep 17 00:00:00 2001 From: daz Date: Mon, 1 Apr 2024 11:45:34 -0600 Subject: [PATCH] Truncate long values in job summary table Fixes #35 --- .github/workflows/demo-job-summary.yml | 1 + sources/src/job-summary.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/demo-job-summary.yml b/.github/workflows/demo-job-summary.yml index 3049d76..7850e93 100644 --- a/.github/workflows/demo-job-summary.yml +++ b/.github/workflows/demo-job-summary.yml @@ -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 diff --git a/sources/src/job-summary.ts b/sources/src/job-summary.ts index e4a52dc..6ea0f77 100644 --- a/sources/src/job-summary.ts +++ b/sources/src/job-summary.ts @@ -96,8 +96,8 @@ function renderSummaryTable(results: BuildResult[]): string { function renderBuildResultRow(result: BuildResult): string { return ` - ${result.rootProjectName} - ${result.requestedTasks} + ${truncateString(result.rootProjectName, 30)} + ${truncateString(result.requestedTasks, 60)} ${result.gradleVersion} ${renderOutcome(result)} ${renderBuildScan(result)} @@ -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 + } +}