Skip to content

Conversation

@rossigee
Copy link

Implements comprehensive REST API endpoints for GitHub Actions workflow runs:

  • POST /actions/runs/{run}/rerun - Rerun entire workflow run
  • POST /actions/runs/{run}/cancel - Cancel running workflow
  • POST /actions/runs/{run}/approve - Approve workflow requiring approval
  • POST /actions/runs/{run}/jobs/{job_id}/rerun - Rerun specific job
  • GET /actions/runs/{run}/logs - Download run logs archive
  • GET /actions/runs/{run}/jobs/{job_id}/logs - Download job logs
  • POST /actions/runs/{run}/logs - Stream logs with cursor support

Features:

  • Proper permission checks and workflow validation
  • Support for "latest" run parameter
  • Job dependency handling for reruns
  • Streaming log API with cursor-based pagination
  • Comprehensive test coverage

Fixes workflow management gaps in API compatibility.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 29, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Aug 29, 2025
@rossigee
Copy link
Author

Addresses #35176

@ChristopherHX
Copy link
Contributor

Please be aware existing Gitea workflow api do not use runindex, {run} is expected to be the run id.

also jobs use jobid instead of jobindex.


GET /actions/runs/{run}/jobs/{job_id}/logs - Download job logs
is already implemented

m.Get("/{job_id}/logs", repo.DownloadActionsRunJobLogs)

@rossigee rossigee force-pushed the feature/runner-logs-api-endpoint branch from d8ca88a to f2cf2e6 Compare September 18, 2025 13:17
@rossigee
Copy link
Author

Comments addressed. Please re-review.

@lunny
Copy link
Member

lunny commented Sep 19, 2025

CI failure is still related.

@ChristopherHX
Copy link
Contributor

You seem to have messed up the PR diff, by not doing a merge. This is hard to read right now so I merge the branch via GitHub UI first

Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

Need to look later again, your added or existing tests are at least failing that needs to be resolved.

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Sep 25, 2025

You might be using a wrong user account for tests, do they pass locally?

--- FAIL: TestAPIActionsRerunWorkflowRun (0.44s)
    testlogger.go:61: 2025/09/25 11:46:04 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:04 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.1ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 5.9ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 6.0ms @ setting/applications.go:38(setting.ApplicationsPost)
    api_actions_run_test.go:150: Response:  {"message":"User does not have write access to actions","url":"http://localhost:3003/api/swagger"}
        
    api_actions_run_test.go:150: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:150
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 403
        	Test:       	TestAPIActionsRerunWorkflowRun
        	Messages:   	Request: POST /api/v1/repos/user2/repo2/actions/runs/795/rerun
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /api/v1/repos/user2/repo2/actions/runs/795/rerun for test-mock:12345, 403 Forbidden in 7.0ms @ repo/actions_run.go:78(repo.RerunWorkflowRun)
=== TestAPIActionsRerunWorkflowRunPermissions (tests/integration/api_actions_run_test.go:164)
--- FAIL: TestAPIActionsRerunWorkflowRunPermissions (0.44s)
    testlogger.go:61: 2025/09/25 11:46:04 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:04 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.1ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 5.8ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 6.1ms @ setting/applications.go:38(setting.ApplicationsPost)
    api_actions_run_test.go:174: Response:  {"errors":null,"message":"not found","url":"http://localhost:3003/api/swagger"}
        
    testlogger.go:61: 2025/09/25 11:46:04 HTTPRequest [I] router: completed POST /api/v1/repos/user2/repo2/actions/runs/795/rerun for test-mock:12345, 404 Not Found in 8.4ms @ v1/api.go:138(v1.Routes.func2.(*Router).Group.Routes.func2.8.repoAssignment.93)
    api_actions_run_test.go:174: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:174
        	Error:      	Not equal: 
        	            	expected: 403
        	            	actual  : 404
        	Test:       	TestAPIActionsRerunWorkflowRunPermissions
        	Messages:   	Request: POST /api/v1/repos/user2/repo2/actions/runs/795/rerun
=== TestAPIActionsCancelWorkflowRun (tests/integration/api_actions_run_test.go:178)
--- FAIL: TestAPIActionsCancelWorkflowRun (0.45s)
    testlogger.go:61: 2025/09/25 11:46:04 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:05 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.1ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 5.8ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 5.9ms @ setting/applications.go:38(setting.ApplicationsPost)
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /api/v1/repos/user5/repo4/actions/runs/793/cancel for test-mock:12345, 403 Forbidden in 9.3ms @ repo/actions_run.go:163(repo.CancelWorkflowRun)
    api_actions_run_test.go:188: Response:  {"message":"User does not have write access to actions","url":"http://localhost:3003/api/swagger"}
        
    api_actions_run_test.go:188: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:188
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 403
        	Test:       	TestAPIActionsCancelWorkflowRun
        	Messages:   	Request: POST /api/v1/repos/user5/repo4/actions/runs/793/cancel
=== TestAPIActionsCancelWorkflowRunPermissions (tests/integration/api_actions_run_test.go:197)
=== TestAPIActionsApproveWorkflowRun (tests/integration/api_actions_run_test.go:211)
--- FAIL: TestAPIActionsApproveWorkflowRun (0.44s)
    testlogger.go:61: 2025/09/25 11:46:05 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:05 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.0ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 7.4ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 6.4ms @ setting/applications.go:38(setting.ApplicationsPost)
    api_actions_run_test.go:221: Response:  {"message":"User does not have write access to actions","url":"http://localhost:3003/api/swagger"}
        
    api_actions_run_test.go:221: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:221
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 403
        	Test:       	TestAPIActionsApproveWorkflowRun
        	Messages:   	Request: POST /api/v1/repos/user2/repo2/actions/runs/795/approve
    testlogger.go:61: 2025/09/25 11:46:05 HTTPRequest [I] router: completed POST /api/v1/repos/user2/repo2/actions/runs/795/approve for test-mock:12345, 403 Forbidden in 7.6ms @ repo/actions_run.go:264(repo.ApproveWorkflowRun)
=== TestAPIActionsRerunWorkflowJob (tests/integration/api_actions_run_test.go:230)
--- FAIL: TestAPIActionsRerunWorkflowJob (0.45s)
    testlogger.go:61: 2025/09/25 11:46:06 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:06 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:06 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.2ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:06 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 7.5ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:06 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 5.9ms @ setting/applications.go:38(setting.ApplicationsPost)
    api_actions_run_test.go:240: Response:  {"message":"User does not have write access to actions","url":"http://localhost:3003/api/swagger"}
        
    api_actions_run_test.go:240: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:240
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 403
        	Test:       	TestAPIActionsRerunWorkflowJob
        	Messages:   	Request: POST /api/v1/repos/user2/repo2/actions/runs/795/jobs/192/rerun
    testlogger.go:61: 2025/09/25 11:46:06 HTTPRequest [I] router: completed POST /api/v1/repos/user2/repo2/actions/runs/795/jobs/192/rerun for test-mock:12345, 403 Forbidden in 9.0ms @ repo/actions_run.go:362(repo.RerunWorkflowJob)
=== TestAPIActionsGetWorkflowRunLogs (tests/integration/api_actions_run_test.go:249)
=== TestAPIActionsGetWorkflowJobLogs (tests/integration/api_actions_run_test.go:268)
--- FAIL: TestAPIActionsGetWorkflowJobLogs (0.44s)
    testlogger.go:61: 2025/09/25 11:46:07 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/gitea-lfs-meta
    testlogger.go:61: 2025/09/25 11:46:07 modules/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/runner/work/gitea/gitea/tests/testdata/data/artifacts
    testlogger.go:61: 2025/09/25 11:46:07 HTTPRequest [I] router: completed GET /user/login for test-mock:12345, 200 OK in 2.2ms @ auth/auth.go:184(auth.SignIn)
    testlogger.go:61: 2025/09/25 11:46:07 HTTPRequest [I] router: completed POST /user/login for test-mock:12345, 303 See Other in 6.2ms @ auth/auth.go:197(auth.SignInPost)
    testlogger.go:61: 2025/09/25 11:46:07 HTTPRequest [I] router: completed POST /user/settings/applications for test-mock:12345, 303 See Other in 5.9ms @ setting/applications.go:38(setting.ApplicationsPost)
    api_actions_run_test.go:278: Response:  {"message":"Job not found in this run","url":"http://localhost:3003/api/swagger"}
        
    testlogger.go:61: 2025/09/25 11:46:07 HTTPRequest [I] router: completed GET /api/v1/repos/user2/repo2/actions/runs/795/jobs/192/logs for test-mock:12345, 404 Not Found in 8.0ms @ repo/actions_run.go:640(repo.GetWorkflowJobLogs)
    api_actions_run_test.go:278: 
        	Error Trace:	/home/runner/work/gitea/gitea/tests/integration/integration_test.go:354
        	            				/home/runner/work/gitea/gitea/tests/integration/api_actions_run_test.go:278
        	Error:      	Not equal: 
        	            	expected: 200
        	            	actual  : 404
        	Test:       	TestAPIActionsGetWorkflowJobLogs
        	Messages:   	Request: GET /api/v1/repos/user2/repo2/actions/runs/795/jobs/192/logs

EDIT fixed the malformed pasted markdown due to bugs in GitHub Comments Markdown pasting....

Do you need to help how to run these tests locally?

@github-actions github-actions bot added modifies/translation modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/templates This PR modifies the template files modifies/migrations modifies/internal modifies/dependencies modifies/frontend labels Oct 4, 2025
@ChristopherHX ChristopherHX added the topic/gitea-actions related to the actions of Gitea label Oct 13, 2025
@github-actions github-actions bot removed modifies/translation modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/templates This PR modifies the template files modifies/migrations modifies/internal modifies/dependencies modifies/frontend labels Oct 18, 2025
Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

I need to do some required refactoring on your branch.

  • Tests look good
  • Test failures not so good
  • Copied code from webui needs to be refactored to be only defined once

@rossigee rossigee force-pushed the feature/runner-logs-api-endpoint branch from cf54846 to d3a10b3 Compare October 23, 2025 14:31
@rossigee
Copy link
Author

You might be using a wrong user account for tests, do they pass locally?

--- FAIL: TestAPIActionsRerunWorkflowRun (0.44s)

...

Tests seem to pass locally if I just run 'make test'.

Do you need to help how to run these tests locally?

I probably do 👍

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/go Pull requests that update Go code topic/gitea-actions related to the actions of Gitea

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants