Skip to content

Commit ba3f83d

Browse files
Copilotmikepenz
andcommitted
Add report_url output with test report URLs
Co-authored-by: mikepenz <[email protected]>
1 parent 4e74f6f commit ba3f83d

File tree

7 files changed

+63
-8
lines changed

7 files changed

+63
-8
lines changed

__tests__/outputs.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {describe, it, expect} from 'vitest'
2+
import {CheckInfo} from '../src/annotator.js'
3+
4+
/**
5+
* Copyright 2024 Mike Penz
6+
*/
7+
8+
describe('report_url output', () => {
9+
it('should format single URL correctly', () => {
10+
const checkInfos: CheckInfo[] = [
11+
{
12+
name: 'Test Report 1',
13+
url: 'https://github.com/owner/repo/runs/123'
14+
}
15+
]
16+
17+
const reportUrls = checkInfos.map(info => info.url).join('\n')
18+
expect(reportUrls).toBe('https://github.com/owner/repo/runs/123')
19+
})
20+
21+
it('should format multiple URLs with newline separation', () => {
22+
const checkInfos: CheckInfo[] = [
23+
{
24+
name: 'Test Report 1',
25+
url: 'https://github.com/owner/repo/runs/123'
26+
},
27+
{
28+
name: 'Test Report 2',
29+
url: 'https://github.com/owner/repo/runs/456'
30+
},
31+
{
32+
name: 'Test Report 3',
33+
url: 'https://github.com/owner/repo/runs/789'
34+
}
35+
]
36+
37+
const reportUrls = checkInfos.map(info => info.url).join('\n')
38+
expect(reportUrls).toBe(
39+
'https://github.com/owner/repo/runs/123\nhttps://github.com/owner/repo/runs/456\nhttps://github.com/owner/repo/runs/789'
40+
)
41+
})
42+
43+
it('should handle empty checkInfos array', () => {
44+
const checkInfos: CheckInfo[] = []
45+
46+
const reportUrls = checkInfos.map(info => info.url).join('\n')
47+
expect(reportUrls).toBe('')
48+
})
49+
})

__tests__/table.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ describe('buildSummaryTables', () => {
141141

142142
// Check that the detail table doesn't include skipped tests
143143
const flatResults = detailTable.flat()
144-
const hasSkippedTests = flatResults.some(
145-
cell => typeof cell === 'string' && cell.includes('⚠️ skipped')
146-
)
144+
const hasSkippedTests = flatResults.some(cell => typeof cell === 'string' && cell.includes('⚠️ skipped'))
147145
expect(hasSkippedTests).toBe(false)
148146

149147
// Test with includeSkipped = true (should include skipped tests in detailed table)

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ outputs:
188188
description: 'The full table with all test results in a summary. In html format (as also constructed by GitHub for the summary).'
189189
flaky_summary:
190190
description: 'The full table with all flaky results in a summary. In html format (as also constructed by GitHub for the summary).'
191+
report_url:
192+
description: 'The URL(s) to the test report(s). If multiple reports are created, they are separated by newlines.'
191193
runs:
192194
using: 'node24'
193195
main: 'dist/index.js'

dist/index.js

Lines changed: 3 additions & 0 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/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ export async function run(): Promise<void> {
219219
core.setOutput('detailed_summary', buildTable(detailTable))
220220
core.setOutput('flaky_summary', buildTable(flakyTable))
221221

222+
// Set report URLs as output (newline-separated for multiple reports)
223+
const reportUrls = checkInfos.map(info => info.url).join('\n')
224+
core.setOutput('report_url', reportUrls)
225+
222226
if (failOnFailure && conclusion === 'failure') {
223227
core.setFailed(`❌ Tests reported ${mergedResult.failed} failures`)
224228
}

src/table.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function buildSummaryTables(
9292
table.push(row)
9393

9494
const annotations = testResult.globalAnnotations.filter(
95-
annotation =>
95+
annotation =>
9696
(includePassed || annotation.annotation_level !== 'notice') &&
9797
(includeSkipped || annotation.status !== 'skipped')
9898
)
@@ -170,9 +170,8 @@ function appendDetailsTable(
170170
): void {
171171
const colspan = includeTimeInSummary ? '3' : '2'
172172
const annotations = testResult.annotations.filter(
173-
annotation =>
174-
(includePassed || annotation.annotation_level !== 'notice') &&
175-
(includeSkipped || annotation.status !== 'skipped')
173+
annotation =>
174+
(includePassed || annotation.annotation_level !== 'notice') && (includeSkipped || annotation.status !== 'skipped')
176175
)
177176
if (annotations.length > 0) {
178177
detailsTable.push([{data: `<em>${testResult.name}</em>`, colspan}])

0 commit comments

Comments
 (0)