use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use uuid::Uuid; #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct RegisterRequest { pub token: String, pub name: String, #[serde(default)] pub labels: Vec, #[serde(default = "default_capacity")] pub capacity: i32, #[serde(default)] pub version: Option, #[serde(default)] pub protocol_versions: Vec, #[serde(default)] pub capabilities: Vec, } fn default_capacity() -> i32 { 1 } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct RegisterResponse { pub runner_id: Uuid, pub credential: String, pub heartbeat_interval_secs: u64, pub poll_timeout_secs: u64, pub protocol_version: u32, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct HeartbeatRequest { #[serde(default)] pub running_job_ids: Vec, #[serde(default)] pub protocol_versions: Vec, #[serde(default)] pub capabilities: Vec, } #[derive(Debug, Clone, Default, Serialize, Deserialize, utoipa::ToSchema)] pub struct HeartbeatResponse { #[serde(default)] pub cancel: Vec, pub next_heartbeat_secs: u64, } #[derive(Debug, Clone, Default, Serialize, Deserialize, utoipa::ToSchema)] pub struct ClaimRequest { #[serde(default)] pub wait_secs: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ClaimResponse { #[serde(default)] pub job: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct LeaseDto { pub token: String, pub expires_at: OffsetDateTime, pub heartbeat_interval_secs: u64, pub attempt: i32, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ArtifactRefDto { pub artifact_id: Uuid, pub name: String, pub upload_url: String, pub sha256: Option, pub declared_size: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ArtifactSpecDto { pub name: String, pub path: String, pub always: bool, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct NeedsArtifactDto { pub run_id: Uuid, pub job_id: Uuid, pub name: String, pub download_url: String, pub size: i64, pub sha256: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct StepPayload { pub index: i32, pub name: String, pub run: String, pub shell: Option, pub working_directory: Option, pub env: BTreeMap, pub timeout_secs: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct JobPayload { pub job_id: Uuid, pub run_id: Uuid, pub repo_id: Uuid, pub space_id: Uuid, pub run_attempt: i32, pub job_name: String, pub clone_url: String, pub commit_sha: String, pub git_ref: String, pub branch: Option, pub tag: Option, pub base_sha: Option, pub base_ref: Option, pub pr_number: Option, pub event: String, pub workflow_name: String, pub workflow_file: String, pub env: BTreeMap, pub secrets: BTreeMap, pub allow_git_token: bool, pub container: Option, pub timeout_secs: u64, pub steps: Vec, pub artifacts: Vec, pub needs_artifacts: Vec, pub lease: LeaseDto, /// Trace context of the CI event that produced the run; lets the runner /// continue the run's trace in its own process. #[serde(default, skip_serializing_if = "Option::is_none")] pub trace: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub actions: Option, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "snake_case")] pub enum StepReportState { Started, Finished, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct StepReport { pub state: StepReportState, #[serde(default)] pub exit_code: Option, #[serde(default)] pub name: Option, #[serde(default)] pub shell: Option, #[serde(default)] pub working_directory: Option, #[serde(default)] pub script: Option, #[serde(default)] pub timeout_secs: Option, #[serde(default)] pub started_at: Option, #[serde(default)] pub finished_at: Option, #[serde(default)] pub step_key: Option, #[serde(default)] pub stage: Option, #[serde(default)] pub outcome: Option, #[serde(default)] pub conclusion: Option, #[serde(default)] pub outputs: BTreeMap, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct LogChunk { pub seq: i32, pub text: String, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct LogChunksRequest { pub chunks: Vec, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "snake_case")] pub enum JobFinishState { Success, Failure, TimedOut, Cancelled, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct JobFinishRequest { pub state: JobFinishState, #[serde(default)] pub exit_code: Option, #[serde(default)] pub error: Option, #[serde(default)] pub outputs: BTreeMap, #[serde(default)] pub lease_token: Option, } impl Default for JobFinishRequest { fn default() -> Self { Self { state: JobFinishState::Failure, exit_code: None, error: None, outputs: Default::default(), lease_token: None, } } } impl Default for StepReport { fn default() -> Self { Self { state: StepReportState::Started, exit_code: None, name: None, shell: None, working_directory: None, script: None, timeout_secs: None, started_at: None, finished_at: None, step_key: None, stage: None, outcome: None, conclusion: None, outputs: Default::default(), } } } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ArtifactInitRequest { pub name: String, pub size: i64, #[serde(default)] pub sha256: Option, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ArtifactInitResponse { pub artifact_id: Uuid, pub upload_url: String, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct ArtifactCompleteRequest { pub size: i64, #[serde(default)] pub sha256: Option, }