initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I79a875e75937ff6b3739ca36bfb0b2836a6a6964
This commit is contained in:
commit
6203ea7f52
13 changed files with 3226 additions and 0 deletions
29
crates/common/src/error.rs
Normal file
29
crates/common/src/error.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//! Error types for FC CI
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum CiError {
|
||||
#[error("Database error: {0}")]
|
||||
Database(#[from] sqlx::Error),
|
||||
|
||||
#[error("Git error: {0}")]
|
||||
Git(#[from] git2::Error),
|
||||
|
||||
#[error("Serialization error: {0}")]
|
||||
Serialization(#[from] serde_json::Error),
|
||||
|
||||
#[error("IO error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
#[error("Configuration error: {0}")]
|
||||
Config(String),
|
||||
|
||||
#[error("Build error: {0}")]
|
||||
Build(String),
|
||||
|
||||
#[error("Not found: {0}")]
|
||||
NotFound(String),
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, CiError>;
|
||||
7
crates/common/src/lib.rs
Normal file
7
crates/common/src/lib.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//! Common types and utilities for CI
|
||||
|
||||
pub mod error;
|
||||
pub mod models;
|
||||
|
||||
pub use error::*;
|
||||
pub use models::*;
|
||||
67
crates/common/src/models.rs
Normal file
67
crates/common/src/models.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
//! Data models for CI
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||
pub struct Project {
|
||||
pub id: Uuid,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub repository_url: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||
pub struct Jobset {
|
||||
pub id: Uuid,
|
||||
pub project_id: Uuid,
|
||||
pub name: String,
|
||||
pub nix_expression: String,
|
||||
pub enabled: bool,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||
pub struct Evaluation {
|
||||
pub id: Uuid,
|
||||
pub jobset_id: Uuid,
|
||||
pub commit_hash: String,
|
||||
pub evaluation_time: DateTime<Utc>,
|
||||
pub status: EvaluationStatus,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
||||
#[sqlx(type_name = "text", rename_all = "lowercase")]
|
||||
pub enum EvaluationStatus {
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||
pub struct Build {
|
||||
pub id: Uuid,
|
||||
pub evaluation_id: Uuid,
|
||||
pub job_name: String,
|
||||
pub drv_path: String,
|
||||
pub status: BuildStatus,
|
||||
pub started_at: Option<DateTime<Utc>>,
|
||||
pub completed_at: Option<DateTime<Utc>>,
|
||||
pub log_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, sqlx::Type)]
|
||||
#[sqlx(type_name = "text", rename_all = "lowercase")]
|
||||
pub enum BuildStatus {
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed,
|
||||
Cancelled,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue