Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ceres/src/api_service/mono_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use callisto::sea_orm_active_enums::ConvTypeEnum;
use callisto::{mega_blob, mega_mr, mega_tree, raw_blob};
use common::errors::MegaError;
use common::model::Pagination;

use jupiter::storage::base_storage::StorageConnector;
use jupiter::storage::Storage;
use jupiter::utils::converter::generate_git_keep_with_timestamp;
Expand All @@ -53,13 +54,15 @@ use mercury::hash::SHA1;
use mercury::internal::object::blob::Blob;
use mercury::internal::object::commit::Commit;
use mercury::internal::object::tree::{Tree, TreeItem, TreeItemMode};

use neptune::model::diff_model::DiffItem;
use neptune::neptune_engine::Diff;

use crate::api_service::ApiHandler;
use crate::model::git::CreateFileInfo;
use crate::model::mr::MrDiffFile;


#[derive(Clone)]
pub struct MonoApiService {
pub storage: Storage,
Expand Down Expand Up @@ -493,6 +496,7 @@ impl MonoApiService {
}
}


if !failed_hashes.is_empty() {
tracing::warn!(
"Failed to fetch {} blob(s): {:?}",
Expand Down Expand Up @@ -523,6 +527,7 @@ impl MonoApiService {
.await;

Ok(diff_output)

}

fn collect_page_blobs(
Expand Down Expand Up @@ -629,6 +634,7 @@ impl MonoApiService {
#[cfg(test)]
mod test {
use super::*;

use crate::model::mr::MrDiffFile;
use mercury::hash::SHA1;
use std::path::PathBuf;
Expand Down
15 changes: 15 additions & 0 deletions orion-server/db/schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Orion schema (no CREATE DATABASE here)
CREATE TABLE IF NOT EXISTS public.builds (
build_id UUID PRIMARY KEY,
output_file TEXT NOT NULL,
exit_code INTEGER,
start_at TIMESTAMPTZ NOT NULL,
end_at TIMESTAMPTZ,
repo_name TEXT NOT NULL,
target TEXT NOT NULL,
arguments TEXT NOT NULL,
mr TEXT NOT NULL
);

CREATE INDEX IF NOT EXISTS idx_builds_mr ON public.builds (mr);
CREATE INDEX IF NOT EXISTS idx_builds_start_at ON public.builds (start_at);
31 changes: 31 additions & 0 deletions orion-server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ services:
depends_on:
db:
condition: service_healthy
db-init:
condition: service_completed_successfully
restart: unless-stopped

db:
Expand All @@ -35,5 +37,34 @@ services:
retries: 5
restart: unless-stopped

db-init:
image: postgres:15
container_name: orion-db-init
depends_on:
db:
condition: service_healthy
environment:
PGPASSWORD: postgres
volumes:
- ./db/schema.sql:/schema.sql:ro
entrypoint: ["sh", "-lc"]
command: |
set -euo pipefail
echo "[db-init] Waiting for Postgres to be ready..."
until pg_isready -h db -p 5432 -U postgres >/dev/null 2>&1; do echo -n "."; sleep 1; done
echo " OK"

if ! psql -h db -p 5432 -U postgres -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='orion'" | grep -q 1; then
echo "[db-init] Creating database 'orion'..."
psql -h db -p 5432 -U postgres -d postgres -v ON_ERROR_STOP=1 -c "CREATE DATABASE orion"
else
echo "[db-init] Database 'orion' already exists."
fi

echo "[db-init] Applying schema to 'orion'..."
psql -h db -p 5432 -U postgres -d orion -v ON_ERROR_STOP=1 -f /schema.sql
echo "[db-init] Schema applied."
restart: "no"

volumes:
pgdata:
8 changes: 6 additions & 2 deletions orion-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn routers() -> Router<AppState> {
get(task_output_segment_handler),
)
.route("/mr-task/{mr}", get(task_query_by_mr))
.route("/tasks", get(tasks_handler))
.route("/tasks/{mr}", get(tasks_handler))
.route("/queue-stats", get(queue_stats_handler))
}

Expand Down Expand Up @@ -812,6 +812,9 @@ impl TaskInfoDTO {
#[utoipa::path(
get,
path = "/tasks",

Copilot AI Aug 17, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OpenAPI path documentation shows "/tasks" but the actual route is "/tasks/{mr}". The path should be updated to "/tasks/{mr}" to match the implementation.

Suggested change
path = "/tasks",
path = "/tasks/{mr}",

Copilot uses AI. Check for mistakes.
params(
("mr" = String, Path, description = "MR number to filter tasks by")
),
responses(
(status = 200, description = "All tasks with their current status", body = [TaskInfoDTO]),
(status = 500, description = "Internal error", body = serde_json::Value)
Expand All @@ -820,10 +823,11 @@ impl TaskInfoDTO {
/// Return all tasks with their current status (combining /mr-task and /task-status logic)
pub async fn tasks_handler(
State(state): State<AppState>,
Path(mr): Path<String>,
) -> Result<Json<Vec<TaskInfoDTO>>, (StatusCode, Json<serde_json::Value>)> {
let db = &state.conn;
let active_builds = state.scheduler.active_builds.clone();
match builds::Entity::find().all(db).await {
match builds::Entity::find().filter(builds::Column::Mr.eq(mr)).all(db).await {
Ok(models) => {
let tasks: Vec<TaskInfoDTO> = models
.into_iter()
Expand Down
5 changes: 4 additions & 1 deletion orion-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ use utoipa_swagger_ui::SwaggerUi;
api::task_output_handler,
api::task_output_segment_handler,
api::task_query_by_mr,
api::tasks_handler,
),
components(
schemas(
crate::scheduler::BuildRequest,
crate::scheduler::LogSegment,
api::TaskStatus,
api::TaskStatusEnum,
api::BuildDTO
api::BuildDTO,
api::TaskInfoDTO

)
),
tags(
Expand Down
4 changes: 2 additions & 2 deletions orion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ futures-util = { workspace = true }
dashmap = { workspace = true }
once_cell = { workspace = true }
dotenvy = { workspace = true }
tokio-tungstenite = { workspace = true }
tokio-tungstenite = { workspace = true , features = ["native-tls"]}
tungstenite = { workspace = true }
serde_json = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
reqwest = { workspace = true, features = ["json", "rustls-tls"] }
Loading