mirror of
https://codeberg.org/secana/ForgejoKit.git
synced 2026-06-16 05:13:53 -07:00
131 lines
3.7 KiB
Swift
131 lines
3.7 KiB
Swift
import Foundation
|
|
|
|
/// Response from Forgejo's internal web route
|
|
/// `POST /{owner}/{repo}/actions/runs/{runIndex}/jobs/{jobIndex}`.
|
|
///
|
|
/// **Experimental.** This endpoint is the web UI's own JSON contract, it is
|
|
/// not part of `/api/v1` and may change between Forgejo releases without
|
|
/// notice. Use only for surfaces where graceful degradation is acceptable.
|
|
public struct WorkflowRunView: Codable, Sendable {
|
|
public let state: WorkflowRunViewState
|
|
public let logs: WorkflowRunViewLogs
|
|
|
|
public init(state: WorkflowRunViewState, logs: WorkflowRunViewLogs) {
|
|
self.state = state
|
|
self.logs = logs
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewState: Codable, Sendable {
|
|
public let run: WorkflowRunViewRun
|
|
public let currentJob: WorkflowRunViewCurrentJob
|
|
|
|
public init(run: WorkflowRunViewRun, currentJob: WorkflowRunViewCurrentJob) {
|
|
self.run = run
|
|
self.currentJob = currentJob
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewRun: Codable, Sendable {
|
|
public let title: String
|
|
public let status: String
|
|
public let done: Bool
|
|
public let jobs: [WorkflowRunViewJob]
|
|
public let preExecutionError: String?
|
|
|
|
public init(
|
|
title: String, status: String, done: Bool,
|
|
jobs: [WorkflowRunViewJob],
|
|
preExecutionError: String? = nil,
|
|
) {
|
|
self.title = title
|
|
self.status = status
|
|
self.done = done
|
|
self.jobs = jobs
|
|
self.preExecutionError = preExecutionError
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewJob: Codable, Identifiable, Sendable {
|
|
public let id: Int
|
|
public let name: String
|
|
public let status: String
|
|
public let duration: String
|
|
|
|
public init(id: Int, name: String, status: String, duration: String) {
|
|
self.id = id
|
|
self.name = name
|
|
self.status = status
|
|
self.duration = duration
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewCurrentJob: Codable, Sendable {
|
|
public let title: String
|
|
public let steps: [WorkflowRunViewStep]
|
|
|
|
public init(title: String, steps: [WorkflowRunViewStep]) {
|
|
self.title = title
|
|
self.steps = steps
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewStep: Codable, Sendable {
|
|
public let summary: String
|
|
public let duration: String
|
|
public let status: String
|
|
|
|
public init(summary: String, duration: String, status: String) {
|
|
self.summary = summary
|
|
self.duration = duration
|
|
self.status = status
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewLogs: Codable, Sendable {
|
|
public let stepsLog: [WorkflowRunViewStepLog]
|
|
|
|
public init(stepsLog: [WorkflowRunViewStepLog] = []) {
|
|
self.stepsLog = stepsLog
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewStepLog: Codable, Sendable {
|
|
public let step: Int
|
|
public let cursor: Int
|
|
public let started: Int
|
|
public let lines: [WorkflowRunViewLogLine]
|
|
|
|
public init(step: Int, cursor: Int, started: Int, lines: [WorkflowRunViewLogLine]) {
|
|
self.step = step
|
|
self.cursor = cursor
|
|
self.started = started
|
|
self.lines = lines
|
|
}
|
|
}
|
|
|
|
public struct WorkflowRunViewLogLine: Codable, Sendable {
|
|
public let index: Int
|
|
public let message: String
|
|
public let timestamp: Double
|
|
|
|
public init(index: Int, message: String, timestamp: Double) {
|
|
self.index = index
|
|
self.message = message
|
|
self.timestamp = timestamp
|
|
}
|
|
}
|
|
|
|
/// Cursor passed in the `logCursors` array of a `WorkflowRunView` request to
|
|
/// indicate which step's logs to fetch and from which line.
|
|
public struct WorkflowLogCursor: Codable, Sendable {
|
|
public let step: Int
|
|
public let cursor: Int
|
|
public let expanded: Bool
|
|
|
|
public init(step: Int, cursor: Int = 0, expanded: Bool = true) {
|
|
self.step = step
|
|
self.cursor = cursor
|
|
self.expanded = expanded
|
|
}
|
|
}
|