mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-11 13:27:15 +00:00
Add API endpoints for Forgejo Actions job information and log retrieval, addressing the limitation where job data was only available through the web UI with session authentication. New endpoints: - GET /api/v1/repos/{owner}/{repo}/actions/runs/{run}/jobs/{job} Returns job information including status, timestamps, and steps - GET /api/v1/repos/{owner}/{repo}/actions/runs/{run}/jobs/{job}/logs Returns job logs with support for partial retrieval Log retrieval query parameters: - head=N: Return first N lines of the log - tail=N: Return last N lines of the log - offset=M: Skip M lines (with head) or skip to M lines from end (with tail) - format=json: Return structured JSON with line numbers and timestamps Implementation includes API response types (ActionJobResponse, ActionJobStep, ActionRunSummary), efficient line-based operations for partial log reading, integration tests, and Swagger documentation. The endpoints use standard API token authentication and follow Forgejo's existing API patterns. Job indices are 0-based matching the web UI behaviour.
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// ActionJobStep represents a step in an action job
|
|
// swagger:model
|
|
type ActionJobStep struct {
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
Started time.Time `json:"started"`
|
|
Stopped time.Time `json:"stopped"`
|
|
}
|
|
|
|
// ActionJobResponse represents a detailed action job with steps
|
|
// swagger:model
|
|
type ActionJobResponse struct {
|
|
ID int64 `json:"id"`
|
|
RunID int64 `json:"run_id"`
|
|
Name string `json:"name"`
|
|
Status string `json:"status"`
|
|
Started time.Time `json:"started,omitempty"`
|
|
Stopped time.Time `json:"stopped,omitempty"`
|
|
JobID string `json:"job_id"`
|
|
Needs []string `json:"needs"`
|
|
TaskID int64 `json:"task_id"`
|
|
// Steps are only included if the job has started
|
|
Steps []*ActionJobStep `json:"steps,omitempty"`
|
|
// Run information
|
|
Run *ActionRunSummary `json:"run"`
|
|
// Total number of jobs in the run
|
|
TotalJobs int `json:"total_jobs"`
|
|
}
|
|
|
|
// ActionRunSummary represents a summary of an action run
|
|
// swagger:model
|
|
type ActionRunSummary struct {
|
|
ID int64 `json:"id"`
|
|
Title string `json:"title"`
|
|
Status string `json:"status"`
|
|
}
|