Skip to content

Feature: Add button to re-run failed jobs in Actions#36924

Open
bircni wants to merge 2 commits intogo-gitea:mainfrom
bircni:feature/rerun-failed-jobs
Open

Feature: Add button to re-run failed jobs in Actions#36924
bircni wants to merge 2 commits intogo-gitea:mainfrom
bircni:feature/rerun-failed-jobs

Conversation

@bircni
Copy link
Contributor

@bircni bircni commented Mar 18, 2026

Fixes #35997

Summary

Adds a "Re-run failed jobs" button to the Actions run view, matching the behaviour available on GitHub. When clicked, only failed jobs and their downstream dependents are rerun — passing jobs are left untouched.

  • Adds RerunFailedWorkflowRunJobs service function and GetFailedRerunJobs helper
  • Adds web route POST /{run}/rerun-failed and handler
  • Adds API endpoint POST /repos/{owner}/{repo}/actions/runs/{run}/rerun-failed-jobs
  • The button is only shown when the run is done and has at least one failed job; "Re-run all jobs" is shown alongside it

Screenshots

grafik

Open Questions

  • UI: dropdown button? Currently "Re-run failed jobs" and "Re-run all jobs" are two separate buttons shown side by side. Should they be combined into a single split/dropdown button (primary action = re-run failed, secondary = re-run all) to reduce visual clutter? --> yes
grafik

I tried to do my best to implement this and used Claude Code as assistance

Adds a "Re-run failed jobs" button to the Actions run view that reruns
only failed jobs and their downstream dependents, matching GitHub's
behaviour described in issue go-gitea#35997.

- Add `RerunFailedWorkflowRunJobs` service function
- Add `GetFailedRerunJobs` helper with full test coverage
- Add web route `POST /{run}/rerun-failed` and handler `RerunFailed`
- Add API route `POST /runs/{run}/rerun-failed-jobs`
- Show button only when the run is done and has at least one failed job
- Extract `checkRunRerunAllowed` guard shared by both web handlers
- Merge `validateRunForRerun` into `prepareRunRerun` (one function)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 18, 2026
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/frontend labels Mar 18, 2026
@bircni bircni marked this pull request as ready for review March 18, 2026 21:04
@bircni
Copy link
Contributor Author

bircni commented Mar 18, 2026

Added a drop down button --> see description

@bircni
Copy link
Contributor Author

bircni commented Mar 20, 2026

@wxiaoguang is anything missing?

@wxiaoguang
Copy link
Contributor

I can review for the code-level.

For feature&function level, it's better to ask Actions users to review (I don't use Actions)

@bircni
Copy link
Contributor Author

bircni commented Mar 20, 2026

I can review for the code-level.

For feature&function level, it's better to ask Actions users to review (I don't use Actions)

Would be great!!
Who is active for actions?

@bircni
Copy link
Contributor Author

bircni commented Mar 20, 2026

Just saw @lunny are you interested?

ctx.APIErrorInternal(err)
return
}
ctx.JSON(http.StatusCreated, convertedRun)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the "run" is still right for response.

It is outdated after RerunFailedWorkflowRunJobs

And GitHub doesn't respond either.

image

Comment on lines 241 to +249
resp.State.Run.CanDeleteArtifact = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
if resp.State.Run.CanRerun {
for _, job := range jobs {
if job.Status == actions_model.StatusFailure {
resp.State.Run.CanRerunFailed = true
break
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsDone(): s.In(StatusSuccess, StatusFailure, StatusCancelled, StatusSkipped)

What if job.Status is something like cancelled but not failure?

var jobsToRerun []*actions_model.ActionRunJob

for _, job := range allJobs {
if job.Status == actions_model.StatusFailure {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it right? What's the status of "job b" if it depends on "job a" and "job a" fails?

<button class="ui basic small compact button link-action" :data-url="`${run.link}/rerun-failed`">
{{ locale.rerun_failed }}
</button>
<div class="ui basic small compact dropdown icon button rerun-dropdown" @click.stop="showRerunMenu = !showRerunMenu">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ui.dropdown will be initialized automatically.

Does it really need @click.stop="showRerunMenu = !showRerunMenu"?

image

@lunny
Copy link
Member

lunny commented Mar 20, 2026

Just saw @lunny are you interested?

I will review it later. It's better if @Zettat123 could also review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/frontend modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button to restart all failed jobs

4 participants