@@ -1126,8 +1126,16 @@ func Test_WebhookWorkflowRun(t *testing.T) {
11261126 testFunc : testWorkflowRunEventsOnRerun ,
11271127 },
11281128 {
1129- name : "WorkflowRunEventsOnCancellingAbandonedRun" ,
1130- testFunc : testWorkflowRunEventsOnCancellingAbandonedRun ,
1129+ name : "WorkflowRunEventsOnCancellingAbandonedRunAllJobsAbandoned" ,
1130+ testFunc : func (t * testing.T , webhookData * workflowRunWebhook ) {
1131+ testWorkflowRunEventsOnCancellingAbandonedRun (t , webhookData , true )
1132+ },
1133+ },
1134+ {
1135+ name : "WorkflowRunEventsOnCancellingAbandonedRunPartiallyAbandoned" ,
1136+ testFunc : func (t * testing.T , webhookData * workflowRunWebhook ) {
1137+ testWorkflowRunEventsOnCancellingAbandonedRun (t , webhookData , false )
1138+ },
11311139 },
11321140 }
11331141 for _ , obj := range testCases {
@@ -1420,7 +1428,7 @@ jobs:
14201428 assert .Len (t , webhookData .payloads , 3 )
14211429}
14221430
1423- func testWorkflowRunEventsOnCancellingAbandonedRun (t * testing.T , webhookData * workflowRunWebhook ) {
1431+ func testWorkflowRunEventsOnCancellingAbandonedRun (t * testing.T , webhookData * workflowRunWebhook , allJobsAbandoned bool ) {
14241432 defer test .MockVariableValue (& setting .Actions .AbandonedJobTimeout , 0 * time .Nanosecond )()
14251433
14261434 // 1. create a new webhook with special webhook for repo1
@@ -1435,7 +1443,7 @@ func testWorkflowRunEventsOnCancellingAbandonedRun(t *testing.T, webhookData *wo
14351443 for i := range runners {
14361444 runners [i ] = newMockRunner ()
14371445 runners [i ].registerAsRepoRunner (t , "user2" , repoName ,
1438- fmt .Sprintf ("mock-runner-1- %d" , i ), []string {"ubuntu-latest" }, false )
1446+ fmt .Sprintf ("mock-runner-%d" , i ), []string {"ubuntu-latest" }, false )
14391447 }
14401448
14411449 testAPICreateWebhookForRepo (t , session , "user2" , repoName , webhookData .URL , "workflow_run" )
@@ -1535,9 +1543,11 @@ jobs:
15351543
15361544 for _ , runner := range runners {
15371545 task := runner .fetchTask (t )
1538- runner .execTask (t , task , & mockTaskOutcome {
1539- result : runnerv1 .Result_RESULT_SUCCESS ,
1540- })
1546+ if ! allJobsAbandoned {
1547+ runner .execTask (t , task , & mockTaskOutcome {
1548+ result : runnerv1 .Result_RESULT_SUCCESS ,
1549+ })
1550+ }
15411551 }
15421552
15431553 // Add this sleep to ensure the func can find the tasks by timestamp.
0 commit comments