fc: initial pull request evaluation support
The migration adds PR support, models expose PR fields, webhooks handle PR events, and tests validate it. To be honest the migrations are a bit redundant at the moment, but I'd like to handle my old deployments so it's nice(r) to have them. I *am* testing those on baremetal. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I02fb4540b62d3e8159ac18b9fa63be916a6a6964
This commit is contained in:
parent
1c18306822
commit
2eae49f313
5 changed files with 1107 additions and 12 deletions
12
crates/common/migrations/010_pull_request_support.sql
Normal file
12
crates/common/migrations/010_pull_request_support.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Add pull request tracking to evaluations
|
||||
-- This enables PR-based CI workflows for GitHub/GitLab/Gitea
|
||||
|
||||
-- Add PR-specific columns to evaluations table
|
||||
ALTER TABLE evaluations ADD COLUMN pr_number INTEGER;
|
||||
ALTER TABLE evaluations ADD COLUMN pr_head_branch TEXT;
|
||||
ALTER TABLE evaluations ADD COLUMN pr_base_branch TEXT;
|
||||
ALTER TABLE evaluations ADD COLUMN pr_action TEXT;
|
||||
|
||||
-- Index for efficient PR queries
|
||||
CREATE INDEX idx_evaluations_pr ON evaluations(jobset_id, pr_number)
|
||||
WHERE pr_number IS NOT NULL;
|
||||
|
|
@ -39,6 +39,10 @@ pub struct Evaluation {
|
|||
pub status: EvaluationStatus,
|
||||
pub error_message: Option<String>,
|
||||
pub inputs_hash: Option<String>,
|
||||
pub pr_number: Option<i32>,
|
||||
pub pr_head_branch: Option<String>,
|
||||
pub pr_base_branch: Option<String>,
|
||||
pub pr_action: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, sqlx::Type)]
|
||||
|
|
@ -360,8 +364,12 @@ pub struct UpdateJobset {
|
|||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct CreateEvaluation {
|
||||
pub jobset_id: Uuid,
|
||||
pub commit_hash: String,
|
||||
pub jobset_id: Uuid,
|
||||
pub commit_hash: String,
|
||||
pub pr_number: Option<i32>,
|
||||
pub pr_head_branch: Option<String>,
|
||||
pub pr_base_branch: Option<String>,
|
||||
pub pr_action: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -11,11 +11,16 @@ pub async fn create(
|
|||
input: CreateEvaluation,
|
||||
) -> Result<Evaluation> {
|
||||
sqlx::query_as::<_, Evaluation>(
|
||||
"INSERT INTO evaluations (jobset_id, commit_hash, status) VALUES ($1, $2, \
|
||||
'pending') RETURNING *",
|
||||
"INSERT INTO evaluations (jobset_id, commit_hash, status, pr_number, \
|
||||
pr_head_branch, pr_base_branch, pr_action) VALUES ($1, $2, 'pending', \
|
||||
$3, $4, $5, $6) RETURNING *",
|
||||
)
|
||||
.bind(input.jobset_id)
|
||||
.bind(&input.commit_hash)
|
||||
.bind(input.pr_number)
|
||||
.bind(&input.pr_head_branch)
|
||||
.bind(&input.pr_base_branch)
|
||||
.bind(&input.pr_action)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue