Skip to content

Commit 322cb04

Browse files
Fix workflow run event status while rerunning a failed job (#35689)
The event reported a completion status instead of requested, therefore sent an email
1 parent a7eceb5 commit 322cb04

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

routers/web/repo/actions/view.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ func Rerun(ctx *context_module.Context) {
432432
run.PreviousDuration = run.Duration()
433433
run.Started = 0
434434
run.Stopped = 0
435+
run.Status = actions_model.StatusWaiting
435436

436437
vars, err := actions_model.GetVariablesOfRun(ctx, run)
437438
if err != nil {

tests/integration/repo_webhook_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,14 +1418,23 @@ jobs:
14181418
assert.Equal(t, "user2/repo1", webhookData.payloads[1].Repo.FullName)
14191419

14201420
// Call rerun ui api
1421-
// Only a web UI API exists for cancelling workflow runs, so use the UI endpoint.
1421+
// Only a web UI API exists for rerunning workflow runs, so use the UI endpoint.
14221422
rerunURL := fmt.Sprintf("/user2/repo1/actions/runs/%d/rerun", webhookData.payloads[0].WorkflowRun.RunNumber)
14231423
req = NewRequestWithValues(t, "POST", rerunURL, map[string]string{
14241424
"_csrf": GetUserCSRFToken(t, session),
14251425
})
14261426
session.MakeRequest(t, req, http.StatusOK)
14271427

14281428
assert.Len(t, webhookData.payloads, 3)
1429+
1430+
// 5. Validate the third webhook payload
1431+
assert.Equal(t, "workflow_run", webhookData.triggeredEvent)
1432+
assert.Equal(t, "requested", webhookData.payloads[2].Action)
1433+
assert.Equal(t, "queued", webhookData.payloads[2].WorkflowRun.Status)
1434+
assert.Equal(t, repo1.DefaultBranch, webhookData.payloads[2].WorkflowRun.HeadBranch)
1435+
assert.Equal(t, commitID, webhookData.payloads[2].WorkflowRun.HeadSha)
1436+
assert.Equal(t, "repo1", webhookData.payloads[2].Repo.Name)
1437+
assert.Equal(t, "user2/repo1", webhookData.payloads[2].Repo.FullName)
14291438
}
14301439

14311440
func testWorkflowRunEventsOnCancellingAbandonedRun(t *testing.T, webhookData *workflowRunWebhook, allJobsAbandoned bool) {

0 commit comments

Comments
 (0)