@@ -3,7 +3,12 @@ import {Annotation, TestResult} from './testParser.js'
33import * as github from '@actions/github'
44import { SummaryTableRow } from '@actions/core/lib/summary.js'
55import { context , GitHub } from '@actions/github/lib/utils.js'
6- import { buildTable } from './utils.js'
6+ import { buildLink , buildList , buildTable } from './utils.js'
7+
8+ export interface CheckInfo {
9+ name : string
10+ url : string
11+ }
712
813export async function annotateTestResult (
914 testResult : TestResult ,
@@ -14,7 +19,7 @@ export async function annotateTestResult(
1419 updateCheck : boolean ,
1520 annotateNotice : boolean ,
1621 jobName : string
17- ) : Promise < void > {
22+ ) : Promise < CheckInfo | undefined > {
1823 const annotations = testResult . globalAnnotations . filter (
1924 annotation => annotateNotice || annotation . annotation_level !== 'notice'
2025 )
@@ -53,6 +58,7 @@ export async function annotateTestResult(
5358 core . notice ( annotation . message , properties )
5459 }
5560 }
61+ return undefined // No check created, so no URL to return
5662 } else {
5763 // check status is being created, annotations are included in this (if not diasbled by "checkAnnotations")
5864 if ( updateCheck ) {
@@ -67,6 +73,7 @@ export async function annotateTestResult(
6773 core . debug ( JSON . stringify ( checks , null , 2 ) )
6874
6975 const check_run_id = checks . data . check_runs [ 0 ] . id
76+ const checkUrl = `https://github.com/${ github . context . repo . owner } /${ github . context . repo . repo } /runs/${ check_run_id } `
7077
7178 if ( checkAnnotations ) {
7279 core . info ( `ℹ️ - ${ testResult . checkName } - Updating checks (Annotations: ${ annotations . length } )` )
@@ -78,6 +85,11 @@ export async function annotateTestResult(
7885 core . info ( `ℹ️ - ${ testResult . checkName } - Updating checks (disabled annotations)` )
7986 await updateChecks ( octokit , check_run_id , title , testResult . summary , [ ] )
8087 }
88+
89+ return {
90+ name : testResult . checkName ,
91+ url : checkUrl
92+ }
8193 } else {
8294 const status : 'completed' | 'in_progress' | 'queued' | undefined = 'completed'
8395 // don't send annotations if disabled
@@ -98,7 +110,13 @@ export async function annotateTestResult(
98110 core . debug ( JSON . stringify ( createCheckRequest , null , 2 ) )
99111
100112 core . info ( `ℹ️ - ${ testResult . checkName } - Creating check (Annotations: ${ adjustedAnnotations . length } )` )
101- await octokit . rest . checks . create ( createCheckRequest )
113+ const checkResponse = await octokit . rest . checks . create ( createCheckRequest )
114+
115+ // Return the check URL for use in job summary
116+ return {
117+ name : testResult . checkName ,
118+ url : `https://github.com/${ github . context . repo . owner } /${ github . context . repo . repo } /runs/${ checkResponse . data . id } `
119+ }
102120 }
103121 }
104122}
@@ -127,7 +145,8 @@ async function updateChecks(
127145export async function attachSummary (
128146 table : SummaryTableRow [ ] ,
129147 detailsTable : SummaryTableRow [ ] ,
130- flakySummary : SummaryTableRow [ ]
148+ flakySummary : SummaryTableRow [ ] ,
149+ checkInfos : CheckInfo [ ] = [ ]
131150) : Promise < void > {
132151 if ( table . length > 0 ) {
133152 await core . summary . addTable ( table ) . write ( )
@@ -138,6 +157,16 @@ export async function attachSummary(
138157 if ( flakySummary . length > 1 ) {
139158 await core . summary . addTable ( flakySummary ) . write ( )
140159 }
160+
161+ // Add check links to the job summary if any checks were created
162+ if ( checkInfos . length > 0 ) {
163+ const links = checkInfos . map ( checkInfo => {
164+ return buildLink ( `View ${ checkInfo . name } ` , checkInfo . url )
165+ } )
166+ core . summary . addList ( links )
167+ }
168+ core . summary . addSeparator ( )
169+ core . summary . write ( )
141170}
142171
143172export function buildCommentIdentifier ( checkName : string [ ] ) : string {
@@ -150,7 +179,8 @@ export async function attachComment(
150179 updateComment : boolean ,
151180 table : SummaryTableRow [ ] ,
152181 detailsTable : SummaryTableRow [ ] ,
153- flakySummary : SummaryTableRow [ ]
182+ flakySummary : SummaryTableRow [ ] ,
183+ checkInfos : CheckInfo [ ] = [ ]
154184) : Promise < void > {
155185 if ( ! context . issue . number ) {
156186 core . warning ( `⚠️ Action requires a valid issue number (PR reference) to be able to attach a comment..` )
@@ -173,6 +203,16 @@ export async function attachComment(
173203 comment += '\n\n'
174204 comment += buildTable ( flakySummary )
175205 }
206+
207+ // Add check links to the job summary if any checks were created
208+ if ( checkInfos . length > 0 ) {
209+ const links = checkInfos . map ( checkInfo => {
210+ return buildLink ( `View ${ checkInfo . name } ` , checkInfo . url )
211+ } )
212+ comment += buildList ( links )
213+ comment += `\n\n`
214+ }
215+
176216 comment += `\n\n${ identifier } `
177217
178218 const priorComment = updateComment ? await findPriorComment ( octokit , identifier ) : undefined
0 commit comments