Skip to content

Commit 1f4aec1

Browse files
authored
Merge pull request #359 from johndarmstrong/feature/comment-format
add terse comments to avoid GH issue body limits
2 parents bd37cb7 + 9e40283 commit 1f4aec1

File tree

7 files changed

+36
-13
lines changed

7 files changed

+36
-13
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ inputs:
5858
cache-seconds:
5959
description: 'The cache lifetime in seconds (must be greater than 300)'
6060
required: false
61+
comment-format:
62+
description: 'The format of the github comment "verbose" or "concise"'
63+
required: false
6164
runs:
6265
using: 'node16'
6366
main: 'dist/index.js'

dist/index.js

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/comment.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const renderEmoji = (diff: number): string => {
88
return '✅'
99
}
1010

11-
export const buildComment = ({results}: BuildCommentInputs): string => {
11+
export const buildComment = ({results, format}: BuildCommentInputs): string => {
1212
const html = results.map(result => {
1313
let plus = ''
1414
let arrow = ''
@@ -52,9 +52,16 @@ export const buildComment = ({results}: BuildCommentInputs): string => {
5252
coverage = result.coverage.toFixed(2)
5353
}
5454

55-
return `${table(
56-
tbody(tr(th(result.app), th(coverage, '%'), diffHtml))
57-
)} \n\n ${details(summary('Coverage Report'), htmlResults)} <br/>`
55+
switch (format) {
56+
case 'concise':
57+
return `${table(
58+
tbody(tr(th(result.app), th(coverage, '%'), diffHtml))
59+
)} <br/>`
60+
default:
61+
return `${table(
62+
tbody(tr(th(result.app), th(coverage, '%'), diffHtml))
63+
)} \n\n ${details(summary('Coverage Report'), htmlResults)} <br/>`
64+
}
5865
})
5966

6067
const title = `Code Coverage:<p></p>`

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ async function run(): Promise<void> {
2626
const gistProcessing = getBooleanInput('gist-processing')
2727
const gistToken = getInput('gist-token', {required: false}) || undefined
2828
const gistId = getInput('gist-id', {required: false}) || undefined
29+
const commentFormat =
30+
getInput('comment-format', {required: false}) || 'verbose'
2931

3032
if (gistProcessing) {
3133
if (!gistToken || !gistId) {
@@ -42,7 +44,8 @@ async function run(): Promise<void> {
4244
githubWorkspace,
4345
gistProcessing,
4446
gistToken,
45-
gistId
47+
gistId,
48+
commentFormat
4649
}
4750

4851
await main(mainInputs)

src/interfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface MainInputs {
1616
gistProcessing: boolean
1717
gistId?: string
1818
gistToken?: string
19+
commentFormat?: string
1920
}
2021

2122
export interface UpsertCommentInputs {
@@ -49,6 +50,7 @@ export interface ListCoverageFilesInputs {
4950

5051
export interface BuildCommentInputs {
5152
results: JcsMergedType[]
53+
format?: string
5254
}
5355

5456
export interface MergeFileListsInputs {

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const main = async ({
2020
githubWorkspace,
2121
gistProcessing,
2222
gistToken,
23-
gistId
23+
gistId,
24+
commentFormat
2425
}: MainInputs): Promise<JcsMergedType[]> => {
2526
try {
2627
// hiddenHeader to help identify any previous PR comments
@@ -48,7 +49,7 @@ export const main = async ({
4849
2
4950
)}`
5051
)
51-
commentBody = buildComment({results})
52+
commentBody = buildComment({results, format: commentFormat})
5253
hiddenHeader = hiddenHeaderForCoverage
5354
} else {
5455
logWarn(

0 commit comments

Comments
 (0)