feat: Add Actions API rerun endpoints for runs and jobs#36768
feat: Add Actions API rerun endpoints for runs and jobs#36768wxiaoguang merged 14 commits intogo-gitea:mainfrom
Conversation
|
@silverwind I think it's ready to review |
There was a problem hiding this comment.
Pull request overview
This PR adds REST API endpoints to rerun GitHub Actions-like workflow runs and individual jobs in Gitea. The new endpoints expose existing rerun functionality from the web UI through stable API routes.
Changes:
- Added POST
/api/v1/repos/{owner}/{repo}/actions/runs/{run}/rerunendpoint to rerun entire workflow runs - Added POST
/api/v1/repos/{owner}/{repo}/actions/runs/{run}/jobs/{job_id}/rerunendpoint to rerun specific jobs - Implemented comprehensive test coverage for both endpoints including success, authorization, and error cases
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| routers/api/v1/api.go | Registers the two new rerun endpoints with proper authentication and authorization middleware |
| routers/api/v1/repo/action.go | Implements the core rerun logic including handlers, validation, status updates, and concurrency handling |
| templates/swagger/v1_json.tmpl | Adds OpenAPI/Swagger documentation for the new rerun endpoints |
| tests/integration/api_actions_run_test.go | Adds integration tests covering successful reruns, authorization failures, and conflict scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No requests from Copilot 😄 |
c801816 to
7f27b91
Compare
|
Vscode adding new lines :-( |
|
PR Review (written by Claude) Overall this is a solid PR — clean extraction of rerun logic into a service layer with proper API endpoints, good error handling, and decent test coverage. Code duplication with web handlerThe main concern is that the web handler in Minor
|
|
@silverwind fixing it - I also let AI review it and it did not find these - do you use some sort of custom instructions? |
|
No, my prompt is just "review #36768", it shows that my Opus 4.6 is just more thorough in reviewing. I think it may also have some memory for Gitea API changes regarding checking for GitHub compat issues. BTW I hear Codex 5.3 is also very good at reviewing, possibly even better than Opus. |
|
@silverwind ah ok cool! |
|
I think I fixed the rest |
|
What about the 201 status code? Is it worth changing or is 200 more consistent for gitea? |
4417664 to
dd1e187
Compare
You are right - 201 is better |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // rerun cancel true scenario | ||
|
|
||
| // FIXME: is the jobIndex 0-based or 1-based? From code, it should be 0-based, but here it uses 1, and cause failure | ||
| req = NewRequest(t, "POST", fmt.Sprintf("/%s/%s/actions/runs/%d/jobs/%d/rerun", user2.Name, apiRepo.Name, run2.Index, 1)) |
There was a problem hiding this comment.
Now we have new problems. I think the test is wrong, it should use 0-based job index.
The error is caught by the newly refactored code.
There was a problem hiding this comment.
seems actually like the old code did just rerun all jobs in this case as 1 is out of range. While the test case has exactly one job.
There was a problem hiding this comment.
Yep. Such URL is only constructed by our frontend Vue component.
So I think the changed/corrected behavior (404 for out-of-range job index) should be safe and fine.
There was a problem hiding this comment.
So I think the changed/corrected behavior (404 for out-of-bound job index) should be safe and fine.
yes I think so as well.
There was a problem hiding this comment.
@wxiaoguang Thank you for pointing out and fixing this issue. The corrected logic looks fine.
627db26 to
52cea03
Compare
Signed-off-by: wxiaoguang <wxiaoguang@gmail.com>
* giteaofficial/main:
[skip ci] Updated translations via Crowdin
fix: /repos/{owner}/{repo}/actions/{runs,jobs} requiring owner permissions (go-gitea#36818)
Fix CRAN package version validation to allow more than 4 version components (go-gitea#36813)
Fix API not persisting pull request unit config when has_pull_requests is not set (go-gitea#36718)
feat: Add Actions API rerun endpoints for runs and jobs (go-gitea#36768)
Fix bug when pushing mirror with wiki (go-gitea#36795)
Pull Request Pusher should be the author of the merge (go-gitea#36581)
Delete non-exist branch should return 404 (go-gitea#36694)
Remove API registration-token (go-gitea#36801)
Add background and run count to actions list page (go-gitea#36707)
* origin/main: (27 commits) Fix OAuth2 authorization code expiry and reuse handling (go-gitea#36797) Fix org permission API visibility checks for hidden members and private orgs (go-gitea#36798) Fix non-admins unable to automerge PRs from forks (go-gitea#36833) upgrade to github.com/cloudflare/circl 1.6.3, svgo 4.0.1, markdownlint-cli 0.48.0 (go-gitea#36837) Fix dump release asset bug (go-gitea#36799) build(deps): update material-icon-theme v5.32.0 (go-gitea#36832) Fix bug to check whether user can update pull request branch or rebase branch (go-gitea#36465) Fix forwarded proto handling for public URL detection (go-gitea#36810) Fix artifacts v4 backend upload problems (go-gitea#36805) Add a git grep search timeout (go-gitea#36809) fix(repo): unify DEFAULT_SHOW_FULL_NAME output in templates and dropdown (go-gitea#36597) Harden render iframe open-link handling (go-gitea#36811) [skip ci] Updated translations via Crowdin fix: /repos/{owner}/{repo}/actions/{runs,jobs} requiring owner permissions (go-gitea#36818) Fix CRAN package version validation to allow more than 4 version components (go-gitea#36813) Fix API not persisting pull request unit config when has_pull_requests is not set (go-gitea#36718) feat: Add Actions API rerun endpoints for runs and jobs (go-gitea#36768) Fix bug when pushing mirror with wiki (go-gitea#36795) Pull Request Pusher should be the author of the merge (go-gitea#36581) Delete non-exist branch should return 404 (go-gitea#36694) ... # Conflicts: # routers/web/repo/issue_view.go
This PR adds official REST API endpoints to rerun Gitea Actions workflow runs and individual jobs:
POST /api/v1/repos/{owner}/{repo}/actions/runs/{run}/rerun
POST /api/v1/repos/{owner}/{repo}/actions/runs/{run}/jobs/{job_id}/rerun
It reuses the existing rerun behavior from the web UI and exposes it through stable API routes.