Add Actions API endpoints for workflow run management and logs#35382
Add Actions API endpoints for workflow run management and logs#35382rossigee wants to merge 10 commits intogo-gitea:mainfrom
Conversation
|
Addresses #35176 |
|
Please be aware existing Gitea workflow api do not use runindex, also jobs use jobid instead of jobindex. GET /actions/runs/{run}/jobs/{job_id}/logs - Download job logs Line 1210 in d2f2221 |
d8ca88a to
f2cf2e6
Compare
|
Comments addressed. Please re-review. |
|
CI failure is still related. |
|
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 |
ChristopherHX
left a comment
There was a problem hiding this comment.
Need to look later again, your added or existing tests are at least failing that needs to be resolved.
|
You might be using a wrong user account for tests, do they pass locally? 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? |
ChristopherHX
left a comment
There was a problem hiding this comment.
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
cf54846 to
d3a10b3
Compare
... Tests seem to pass locally if I just run 'make test'.
I probably do 👍 |
c7dc5ba to
4fae287
Compare
0644c42 to
71bb9e7
Compare
|
conflicts |
3ff9e2d to
0200bf6
Compare
|
whats the current state? |
- Cancel and approve workflow runs via POST /runs/{run}/cancel|approve
- Download all job logs as zip via GET /runs/{run}/logs
- Download individual job log via GET /runs/{run}/jobs/{job_id}/logs
- Stream live log cursors via POST /runs/{run}/logs
- Add CreatedAt field to ActionWorkflowRun API response
- Extract shared log streaming and cancel logic into services/actions
- Move streaming log types to modules/structs
- Add Swagger documentation for all new endpoints
- Add integration tests with subtests for all new endpoints
Co-Authored-By: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
- Cast org.Visibility.String() to api.UserVisibility in ToOrganization - Cast t.AccessMode.ToString() to api.AccessLevelName in ToTeams - Update webhook notifier to pass repo to ToActionWorkflowRun Co-Authored-By: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
Pass repo parameter to ToActionWorkflowRun in action.go and shared/action.go. Co-Authored-By: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
- Add reqToken/reqRepoReader to GET log download endpoints for consistency
with the POST streaming endpoint
- Remove spurious LoadRepos call in DownloadActionsRunAllJobLogs; jobs are
already scoped to the repo by the query and Repo is never read
- Refactor reader.Close() in zip loop to use a closure with defer
- Update copyright year to 2026 on new services/actions/{cancel,log}.go
- Add TestAPIActionsListUserWorkflows and TestAPIActionsListRepoWorkflows
as standalone top-level tests (were dropped when breaking up the
orchestrator)
- Add idempotency assertion to TestAPIActionsApproveWorkflowRun: approving
an already-approved run returns 400
Co-Authored-By: Claude Sonnet <claude-sonnet-4-6@anthropic.com>
GetWorkflowRunLogsStream (POST /runs/{run}/logs) and its supporting
code are moved to feature/runner-logs-stream-api for a standalone PR
where the POST-vs-GET design question can be resolved independently.
Removed from this branch:
- GetWorkflowRunLogsStream handler and route
- getRunJobsAndCurrent helper (only used by the stream handler)
- services/actions/log.go (ReadStepLogs)
- ActionLogCursor/Request/StepLine/Step/Response structs
- TestAPIActionsGetWorkflowRunLogsStream integration test
- Regenerated swagger specs accordingly
Co-Authored-By: Claude Sonnet <claude-sonnet-4-6@anthropic.com>
Replace the duplicated inline cancel logic in the web Cancel handler with a call to actions_service.CancelRun, which encapsulates the same transaction, commit status update, and notification logic. Co-Authored-By: Claude Sonnet (claude-sonnet-4-6) <claude-sonnet-4-6@anthropic.com>
- Remove spurious context.ReferencesGitRepo(true) from /actions route group - ToActionTask: restore targeted loads (LoadJob/LoadRun/LoadRepo) instead of LoadAttributes which unnecessarily loads task steps; use httplib.MakeAbsoluteURL(ctx, ...) for the URL field - ToActionWorkflowRun: replace run.LoadAttributes with direct repo assignment + LoadTriggerUser to avoid redundant language-stats query; restore attempt.Run = run before attempt.LoadAttributes to prevent redundant DB re-fetch; restore ctx to APIURL/HTMLURL calls - ToActionWorkflowJob: restore ctx to APIURL and HTMLURL calls Co-Authored-By: Claude <claude-sonnet-4-6@anthropic.com>
1e1d0f5 to
e38010e
Compare
| triggerUser = attempt.TriggerUser | ||
| if attempt.Attempt > 1 { | ||
| previousAttemptURL = new(fmt.Sprintf("%s/actions/runs/%d/attempts/%d", run.Repo.APIURL(ctx), run.ID, attempt.Attempt-1)) | ||
| url := fmt.Sprintf("%s/actions/runs/%d/attempts/%d", repo.APIURL(ctx), run.ID, attempt.Attempt-1) |
Aggregated review (Claude Opus 4.7 + opencode/gpt-5.4)Correctness — confirmed bugs
Design / API smells
Conventions / churn
Test coverage gaps
Permissions / securityNo auth-bypass concerns. New mutating endpoints use VerdictTwo real correctness bugs (rerun-job log omission, nil-deref in Review by @silverwind, written with Claude Opus 4.7 and opencode/gpt-5.4. |
Implements REST API endpoints for GitHub Actions workflow run management and logs:
Features:
Note: Uses existing implementations for rerun endpoints from action.go.
Fixes workflow management gaps in API compatibility.