@@ -54,11 +54,19 @@ async function testCancellationDetection(): Promise<void> {
5454 const apiClient = getApiClient ( ) ;
5555 const runId = getWorkflowRunID ( ) ;
5656 const attemptNumber = getWorkflowRunAttempt ( ) ;
57- const jobName = process . env [ "GITHUB_JOB " ] || "" ;
57+ const checkRunIdInput = process . env [ "INPUT_CHECK-RUN-ID " ] || "" ;
5858 const repositoryNwo = getRepositoryNwo ( ) ;
5959
60+ if ( ! checkRunIdInput ) {
61+ logger . warning (
62+ "[Cancellation Test] check-run-id input not provided, skipping" ,
63+ ) ;
64+ return ;
65+ }
66+
67+ const checkRunId = parseInt ( checkRunIdInput , 10 ) ;
6068 logger . info (
61- `[Cancellation Test] Querying jobs API for run ${ runId } , attempt ${ attemptNumber } , job " ${ jobName } " ` ,
69+ `[Cancellation Test] Querying jobs API for run ${ runId } , attempt ${ attemptNumber } , check_run_id ${ checkRunId } ` ,
6270 ) ;
6371
6472 const response = await apiClient . rest . actions . listJobsForWorkflowRunAttempt (
@@ -70,33 +78,35 @@ async function testCancellationDetection(): Promise<void> {
7078 } ,
7179 ) ;
7280
73- const currentJob = response . data . jobs . find ( ( j ) => j . name === jobName ) ;
81+ const jobs = response . data . jobs ;
82+ const currentJob = jobs . find ( ( j ) => j . id === checkRunId ) ;
7483
7584 if ( currentJob ) {
7685 logger . info (
7786 `[Cancellation Test] Current job status: ${ currentJob . status } , conclusion: ${ currentJob . conclusion } ` ,
7887 ) ;
7988
8089 // Log each step's status
81- for ( const step of currentJob . steps || [ ] ) {
90+ const steps = currentJob . steps || [ ] ;
91+ for ( const step of steps ) {
8292 logger . info (
8393 `[Cancellation Test] Step "${ step . name } ": status=${ step . status } , conclusion=${ step . conclusion } ` ,
8494 ) ;
8595 }
8696
8797 // Check if any step shows cancelled
88- const hasCancelledStep = currentJob . steps ? .some (
98+ const hasCancelledStep = steps . some (
8999 ( step ) => step . conclusion === "cancelled" ,
90100 ) ;
91101 logger . info (
92102 `[Cancellation Test] Has cancelled step: ${ hasCancelledStep } ` ,
93103 ) ;
94104 } else {
95105 logger . warning (
96- `[Cancellation Test] Could not find job with name " ${ jobName } " in API response` ,
106+ `[Cancellation Test] Could not find job with check_run_id ${ checkRunId } in API response` ,
97107 ) ;
98108 logger . info (
99- `[Cancellation Test] Available jobs: ${ response . data . jobs . map ( ( j ) => j . name ) . join ( ", " ) } ` ,
109+ `[Cancellation Test] Available jobs: ${ jobs . map ( ( j ) => ` ${ j . id } ( ${ j . name } )` ) . join ( ", " ) } ` ,
100110 ) ;
101111 }
102112 } catch ( error ) {
0 commit comments