Skip to content

Commit 3698d84

Browse files
committed
Fix workflow run event status while rerunning a failed job (go-gitea#35689)
The event reported a completion status instead of requested, therefore sent an email Backport go-gitea#35689
1 parent 4af1d58 commit 3698d84

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

routers/web/repo/actions/view.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ func Rerun(ctx *context_module.Context) {
425425
run.PreviousDuration = run.Duration()
426426
run.Started = 0
427427
run.Stopped = 0
428-
if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "previous_duration"); err != nil {
428+
run.Status = actions_model.StatusWaiting
429+
if err := actions_model.UpdateRun(ctx, run, "started", "stopped", "status", "previous_duration"); err != nil {
429430
ctx.ServerError("UpdateRun", err)
430431
return
431432
}

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)