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)

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.
…cate endpoint

Based on reviewer feedback, this commit makes the following changes:

## API Consistency Improvements
- Replace getRunIndex() with getRunID() to align with existing Gitea API patterns
- Update all endpoints to use run ID directly instead of run index
- Follow the same pattern as GetWorkflowRun(): runID := ctx.PathParamInt64("run") and db.GetByID[actions_model.ActionRun](ctx, runID)
- Update swagger documentation to reflect "run ID" instead of "run number"

## Remove Duplicate Endpoint
- Remove GetWorkflowJobLogs function and corresponding route /actions/runs/{run}/jobs/{job_id}/logs
- This eliminates duplication with existing /actions/jobs/{job_id}/logs endpoint
- Remove corresponding test TestAPIActionsGetWorkflowJobLogs

## Functions Updated
- RerunWorkflowRun: now uses run ID consistently
- CancelWorkflowRun: now uses run ID consistently
- ApproveWorkflowRun: now uses run ID consistently
- RerunWorkflowJob: now uses run ID consistently
- GetWorkflowRunLogs: now uses run ID consistently
- GetWorkflowRunLogsStream: now uses run ID consistently

## Helper Functions Refactored
- getRunIndex() → getRunID() with proper error handling
- getRunJobsByIndex() → getRunJobsByRunID() with proper validation
- getRunJobsAndCurrent() updated to use run ID parameter

All existing tests continue to pass as they were already using run IDs correctly.
@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 and others added 8 commits September 19, 2025 11:51
Initial implementation of linked proposal.

* Closes go-gitea#29942
* Fix go-gitea#34003
* Fix go-gitea#30443

---------

Co-authored-by: silverwind <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
…epository (go-gitea#35511)

Extracted from go-gitea#35077
`UpdateRef` and `RemoveRef` will call git commands even for gogit
version.
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.
This commit adds comprehensive REST API endpoints for GitHub Actions
workflow run and job operations, addressing requirements for:

- Workflow run operations: approve, cancel, rerun
- Job-specific operations: rerun individual jobs
- Log streaming: both archive download and incremental streaming
- Enhanced job log access with proper error handling

Key changes:
- Add 6 new API endpoints in actions_run.go using consistent run ID approach
- Add comprehensive integration tests with proper error scenarios
- Update Swagger documentation for all new endpoints
- Maintain backward compatibility with existing API patterns

All endpoints follow established authentication and authorization patterns,
with proper error handling and response formatting.
- Keep GetWorkflowJobLogs function and grouped job endpoints
- Use map[string]any consistently for modern Go style
- Maintain all functionality from both branches
This commit adds comprehensive REST API endpoints for GitHub Actions
workflow run and job operations, addressing requirements for:

- Workflow run operations: approve, cancel, rerun
- Job-specific operations: rerun individual jobs, download job logs
- Log streaming: both archive download and incremental streaming
- Enhanced job log access with proper error handling

Key changes:
- Add 6 new API endpoints in actions_run.go using consistent run ID approach
- Add comprehensive integration tests with proper error scenarios
- Update Swagger documentation for all new endpoints
- Maintain backward compatibility with existing API patterns

All endpoints follow established authentication and authorization patterns,
with proper error handling and response formatting.
…e/gitea into feature/runner-logs-api-endpoint
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants