From 91a39f10cec181789f0fc6a1d8924222b46b5cf7 Mon Sep 17 00:00:00 2001 From: Nusendra Hanggarawan Date: Wed, 28 Oct 2026 10:38:24 +0700 Subject: [PATCH 1/5] fix(lint): clear 15 non-breaking clippy findings across six crates Mechanical fixes only; no behaviour change, no signature change. ployer-core - BuildStrategy: derive Default with #[default] instead of a manual impl (derivable_impls). ployer-git - GitService: derive Default (new_without_default). - Two Option::map_or(false, ..) -> Option::is_some_and (unnecessary_map_or). ployer-server - ServerManager: add Default forwarding to new(), which logs, so it cannot be derived (new_without_default). ployer-templates - compose.rs: drop a needless borrow on Mapping::remove. - render.rs: collapse a nested if. These two are the same edits as nusendra/ployer#3, byte for byte, so the branches merge without conflict in either order. ployer-api - domains.rs: `if let Some(_) = ..` -> bind, then `.is_some()`. - deployment.rs: single-arm match -> `if let`/`.is_ok()`. - deployment.rs: execute_deployment keeps its 10 arguments behind an #[allow(.., reason = ..)]; it is spawned detached so nothing can be borrowed from AppState, and bundling the arguments is a refactor of the deployment path, not a lint fix. ployer-db - Five repository writers keep their argument lists behind #[allow(.., reason = ..)]: each argument is one SQL column, and a params struct would duplicate the column list where it can drift from the statement without the compiler noticing. Verified: SQLX_OFFLINE=true cargo test --workspace -> 137 passed, 0 failed. Remaining after this commit: 8x should_implement_trait in ployer-core. --- crates/ployer-api/src/routes/domains.rs | 6 +++++- crates/ployer-api/src/services/deployment.rs | 13 ++++++++++--- crates/ployer-core/src/models/application.rs | 9 ++------- crates/ployer-db/src/repositories/application.rs | 10 ++++++++++ .../ployer-db/src/repositories/container_stats.rs | 5 +++++ crates/ployer-db/src/repositories/server.rs | 5 +++++ crates/ployer-db/src/repositories/webhook.rs | 5 +++++ crates/ployer-git/src/lib.rs | 5 +++-- crates/ployer-server/src/lib.rs | 6 ++++++ crates/ployer-templates/src/compose.rs | 2 +- crates/ployer-templates/src/render.rs | 12 +++++------- 11 files changed, 57 insertions(+), 21 deletions(-) diff --git a/crates/ployer-api/src/routes/domains.rs b/crates/ployer-api/src/routes/domains.rs index ed1161a..2d87224 100644 --- a/crates/ployer-api/src/routes/domains.rs +++ b/crates/ployer-api/src/routes/domains.rs @@ -128,7 +128,11 @@ async fn add_domain( let repo = DomainRepository::new(state.db.clone()); // Check if domain already exists - if let Some(_) = repo.find_by_domain(&domain_name).await.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))? { + let existing = repo + .find_by_domain(&domain_name) + .await + .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?; + if existing.is_some() { return Err((StatusCode::CONFLICT, "Domain already exists".to_string())); } diff --git a/crates/ployer-api/src/services/deployment.rs b/crates/ployer-api/src/services/deployment.rs index b65f657..0c3ed62 100644 --- a/crates/ployer-api/src/services/deployment.rs +++ b/crates/ployer-api/src/services/deployment.rs @@ -105,6 +105,13 @@ impl DeploymentService { } /// Execute the full deployment pipeline + #[allow( + clippy::too_many_arguments, + reason = "spawned as a detached task, so every dependency must be passed by value \ + rather than borrowed from AppState; the first six are the ambient services \ + and the last four are this job's inputs. Bundling them into a struct is a \ + refactor of the deployment hot path, deliberately not folded into a lint fix." + )] async fn execute_deployment( db: SqlitePool, docker: Arc, @@ -226,9 +233,9 @@ impl DeploymentService { } // Also force-remove by fixed name (catches untracked containers with the same name) - match docker.remove_container(&container_name, true).await { - Ok(_) => send_log(format!("Removed existing container '{}'", container_name)).await, - Err(_) => {} // doesn't exist — that's fine + // An Err here just means no such container, which is the normal case. + if docker.remove_container(&container_name, true).await.is_ok() { + send_log(format!("Removed existing container '{}'", container_name)).await; } // Note: we no longer kill "containers bound to this port" — app containers diff --git a/crates/ployer-core/src/models/application.rs b/crates/ployer-core/src/models/application.rs index e6ff1c1..438424f 100644 --- a/crates/ployer-core/src/models/application.rs +++ b/crates/ployer-core/src/models/application.rs @@ -23,20 +23,15 @@ pub struct Application { pub updated_at: DateTime, } -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] #[serde(rename_all = "snake_case")] pub enum BuildStrategy { + #[default] Dockerfile, Nixpacks, DockerCompose, } -impl Default for BuildStrategy { - fn default() -> Self { - BuildStrategy::Dockerfile - } -} - impl BuildStrategy { pub fn as_str(&self) -> &str { match self { diff --git a/crates/ployer-db/src/repositories/application.rs b/crates/ployer-db/src/repositories/application.rs index 71de072..72ec987 100644 --- a/crates/ployer-db/src/repositories/application.rs +++ b/crates/ployer-db/src/repositories/application.rs @@ -12,6 +12,11 @@ impl ApplicationRepository { Self { pool } } + #[allow( + clippy::too_many_arguments, + reason = "one parameter per `applications` column; a params struct would duplicate \ + the column list and could drift from the INSERT silently" + )] pub async fn create( &self, name: &str, @@ -124,6 +129,11 @@ impl ApplicationRepository { Ok(rows.into_iter().map(|r| r.into()).collect()) } + #[allow( + clippy::too_many_arguments, + reason = "one parameter per `applications` column; a params struct would duplicate \ + the column list and could drift from the UPDATE silently" + )] pub async fn update( &self, id: &str, diff --git a/crates/ployer-db/src/repositories/container_stats.rs b/crates/ployer-db/src/repositories/container_stats.rs index 360b56a..6a3fd1d 100644 --- a/crates/ployer-db/src/repositories/container_stats.rs +++ b/crates/ployer-db/src/repositories/container_stats.rs @@ -14,6 +14,11 @@ impl ContainerStatsRepository { } /// Record container stats + #[allow( + clippy::too_many_arguments, + reason = "one parameter per `container_stats` column; a params struct would duplicate \ + the column list and could drift from the INSERT silently" + )] pub async fn record( &self, container_id: &str, diff --git a/crates/ployer-db/src/repositories/server.rs b/crates/ployer-db/src/repositories/server.rs index c7016c5..9e722b8 100644 --- a/crates/ployer-db/src/repositories/server.rs +++ b/crates/ployer-db/src/repositories/server.rs @@ -70,6 +70,11 @@ impl ServerRepository { Ok(rows.into_iter().map(|r| r.into()).collect()) } + #[allow( + clippy::too_many_arguments, + reason = "one parameter per `servers` column; a params struct would duplicate \ + the column list and could drift from the UPDATE silently" + )] pub async fn update( &self, id: &str, diff --git a/crates/ployer-db/src/repositories/webhook.rs b/crates/ployer-db/src/repositories/webhook.rs index 6586e7f..6d2c8c2 100644 --- a/crates/ployer-db/src/repositories/webhook.rs +++ b/crates/ployer-db/src/repositories/webhook.rs @@ -118,6 +118,11 @@ impl WebhookRepository { } /// Create a webhook delivery record + #[allow( + clippy::too_many_arguments, + reason = "one parameter per `webhook_deliveries` column; a params struct would duplicate \ + the column list and could drift from the INSERT silently" + )] pub async fn create_delivery( &self, webhook_id: &str, diff --git a/crates/ployer-git/src/lib.rs b/crates/ployer-git/src/lib.rs index b6506e4..9ec34d2 100644 --- a/crates/ployer-git/src/lib.rs +++ b/crates/ployer-git/src/lib.rs @@ -3,6 +3,7 @@ use git2::{Cred, FetchOptions, RemoteCallbacks, Repository}; use std::path::Path; use tracing::info; +#[derive(Debug, Clone, Copy, Default)] pub struct GitService; #[derive(Debug, Clone)] @@ -42,10 +43,10 @@ impl GitService { let mut n_bytes = private_key.n().to_bytes_be(); // SSH wire format: if MSB is set, prepend 0x00 to indicate positive number - if e_bytes.first().map_or(false, |&b| b & 0x80 != 0) { + if e_bytes.first().is_some_and(|&b| b & 0x80 != 0) { e_bytes.insert(0, 0x00); } - if n_bytes.first().map_or(false, |&b| b & 0x80 != 0) { + if n_bytes.first().is_some_and(|&b| b & 0x80 != 0) { n_bytes.insert(0, 0x00); } diff --git a/crates/ployer-server/src/lib.rs b/crates/ployer-server/src/lib.rs index ad551bb..76c4813 100644 --- a/crates/ployer-server/src/lib.rs +++ b/crates/ployer-server/src/lib.rs @@ -7,6 +7,12 @@ pub struct ServerManager { system: System, } +impl Default for ServerManager { + fn default() -> Self { + Self::new() + } +} + impl ServerManager { pub fn new() -> Self { info!("Server manager initialized"); diff --git a/crates/ployer-templates/src/compose.rs b/crates/ployer-templates/src/compose.rs index 7eba827..9e4e69b 100644 --- a/crates/ployer-templates/src/compose.rs +++ b/crates/ployer-templates/src/compose.rs @@ -68,7 +68,7 @@ pub fn remove_ports_from_all_services(yaml: &str) -> Result().is_err() { - return Err(TemplateError::InvalidInput { - key: spec.key.clone(), - reason: "expected number".to_string(), - }); - } + if matches!(spec.kind, InputKind::Number) && value.parse::().is_err() { + return Err(TemplateError::InvalidInput { + key: spec.key.clone(), + reason: "expected number".to_string(), + }); } out.insert(spec.key.clone(), value); From 0f1f6fcfc88f03bab4254b12df3790a82daec57c Mon Sep 17 00:00:00 2001 From: Nusendra Hanggarawan Date: Wed, 28 Oct 2026 10:40:26 +0700 Subject: [PATCH 2/5] refactor(core)!: rename the lossy `from_str` constructors to `from_db_str` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: eight inherent constructors in ployer-core are renamed. BuildStrategy::from_str -> BuildStrategy::from_db_str AppStatus::from_str -> AppStatus::from_db_str DeploymentStatus::from_str -> DeploymentStatus::from_db_str HealthCheckStatus::from_str -> HealthCheckStatus::from_db_str ServerStatus::from_str -> ServerStatus::from_db_str UserRole::from_str -> UserRole::from_db_str WebhookProvider::from_str -> WebhookProvider::from_db_str WebhookDeliveryStatus::from_str -> WebhookDeliveryStatus::from_db_str Signatures are otherwise unchanged (`&str -> Self`) and the match arms are untouched, so behaviour is identical. All 32 call sites in this workspace are updated in the same commit; there is no external consumer, since every ployer-* crate is a path dependency of the `ployer` binary. Why rename instead of implementing `FromStr`: Each of these is a total, infallible, *lossy* function — an unrecognised value silently becomes a default variant (`"bitbucket"` -> `WebhookProvider::GitHub`, `"superadmin"` -> `UserRole::User`). `FromStr` would have to use `Err = Infallible`, which makes that fallback unobservable: `s.parse()?` would read like a successful parse and quietly hand back the wrong variant. Naming the method `from_str` without implementing the trait is the same trap wearing the trait's clothes, which is precisely what clippy::should_implement_trait objects to. `from_db_str` says what these are: readers for one specific database column, where tolerating an unknown value is the point — a row written by a newer schema must not make existing rows unreadable. Each now carries a doc comment stating the fallback variant and why `FromStr` was declined. This clears the last 8 of the 23 clippy findings on this branch. `cargo clippy --workspace --all-targets -- -D warnings` now exits 0, and SQLX_OFFLINE=true cargo test --workspace passes 137/137. --- crates/ployer-core/src/models/application.rs | 22 +++++++++++++++-- .../src/models/application_tests.rs | 8 +++---- crates/ployer-core/src/models/deployment.rs | 22 +++++++++++++++-- .../src/models/deployment_tests.rs | 8 +++---- crates/ployer-core/src/models/server.rs | 11 ++++++++- crates/ployer-core/src/models/server_tests.rs | 4 ++-- crates/ployer-core/src/models/user.rs | 14 ++++++++++- crates/ployer-core/src/models/user_tests.rs | 6 ++--- crates/ployer-core/src/models/webhook.rs | 24 +++++++++++++++++-- .../ployer-core/src/models/webhook_tests.rs | 14 +++++------ .../ployer-db/src/repositories/application.rs | 4 ++-- .../ployer-db/src/repositories/deployment.rs | 6 ++--- .../src/repositories/health_check.rs | 4 ++-- crates/ployer-db/src/repositories/server.rs | 2 +- crates/ployer-db/src/repositories/user.rs | 2 +- crates/ployer-db/src/repositories/webhook.rs | 6 ++--- 16 files changed, 117 insertions(+), 40 deletions(-) diff --git a/crates/ployer-core/src/models/application.rs b/crates/ployer-core/src/models/application.rs index 438424f..fd73343 100644 --- a/crates/ployer-core/src/models/application.rs +++ b/crates/ployer-core/src/models/application.rs @@ -41,7 +41,16 @@ impl BuildStrategy { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `BuildStrategy` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`BuildStrategy::Dockerfile`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "dockerfile" => BuildStrategy::Dockerfile, "nixpacks" => BuildStrategy::Nixpacks, @@ -72,7 +81,16 @@ impl AppStatus { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `AppStatus` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`AppStatus::Idle`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "idle" => AppStatus::Idle, "building" => AppStatus::Building, diff --git a/crates/ployer-core/src/models/application_tests.rs b/crates/ployer-core/src/models/application_tests.rs index e2d4415..49bce45 100644 --- a/crates/ployer-core/src/models/application_tests.rs +++ b/crates/ployer-core/src/models/application_tests.rs @@ -8,13 +8,13 @@ fn build_strategy_round_trips() { (BuildStrategy::DockerCompose, "docker_compose"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(BuildStrategy::from_str(s), variant); + assert_eq!(BuildStrategy::from_db_str(s), variant); } } #[test] fn build_strategy_unknown_defaults_to_dockerfile() { - assert_eq!(BuildStrategy::from_str("unknown"), BuildStrategy::Dockerfile); + assert_eq!(BuildStrategy::from_db_str("unknown"), BuildStrategy::Dockerfile); } #[test] @@ -27,13 +27,13 @@ fn app_status_round_trips() { (AppStatus::Failed, "failed"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(AppStatus::from_str(s), variant); + assert_eq!(AppStatus::from_db_str(s), variant); } } #[test] fn app_status_unknown_defaults_to_idle() { - assert_eq!(AppStatus::from_str("mystery"), AppStatus::Idle); + assert_eq!(AppStatus::from_db_str("mystery"), AppStatus::Idle); } #[test] diff --git a/crates/ployer-core/src/models/deployment.rs b/crates/ployer-core/src/models/deployment.rs index ed1e19a..c5522e3 100644 --- a/crates/ployer-core/src/models/deployment.rs +++ b/crates/ployer-core/src/models/deployment.rs @@ -43,7 +43,16 @@ impl DeploymentStatus { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `DeploymentStatus` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`DeploymentStatus::Queued`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "queued" => DeploymentStatus::Queued, "cloning" => DeploymentStatus::Cloning, @@ -103,7 +112,16 @@ impl HealthCheckStatus { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `HealthCheckStatus` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`HealthCheckStatus::Unknown`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "healthy" => HealthCheckStatus::Healthy, "unhealthy" => HealthCheckStatus::Unhealthy, diff --git a/crates/ployer-core/src/models/deployment_tests.rs b/crates/ployer-core/src/models/deployment_tests.rs index 536fa78..52e4fbd 100644 --- a/crates/ployer-core/src/models/deployment_tests.rs +++ b/crates/ployer-core/src/models/deployment_tests.rs @@ -13,13 +13,13 @@ fn deployment_status_round_trips() { (DeploymentStatus::RolledBack, "rolled_back"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(DeploymentStatus::from_str(s), variant); + assert_eq!(DeploymentStatus::from_db_str(s), variant); } } #[test] fn deployment_status_unknown_defaults_to_queued() { - assert_eq!(DeploymentStatus::from_str("unknown"), DeploymentStatus::Queued); + assert_eq!(DeploymentStatus::from_db_str("unknown"), DeploymentStatus::Queued); } #[test] @@ -30,11 +30,11 @@ fn health_check_status_round_trips() { (HealthCheckStatus::Unknown, "unknown"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(HealthCheckStatus::from_str(s), variant); + assert_eq!(HealthCheckStatus::from_db_str(s), variant); } } #[test] fn health_check_status_unknown_defaults_to_unknown() { - assert_eq!(HealthCheckStatus::from_str("bad"), HealthCheckStatus::Unknown); + assert_eq!(HealthCheckStatus::from_db_str("bad"), HealthCheckStatus::Unknown); } diff --git a/crates/ployer-core/src/models/server.rs b/crates/ployer-core/src/models/server.rs index 37097c6..13b4b13 100644 --- a/crates/ployer-core/src/models/server.rs +++ b/crates/ployer-core/src/models/server.rs @@ -34,7 +34,16 @@ impl ServerStatus { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `ServerStatus` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`ServerStatus::Unknown`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "online" => ServerStatus::Online, "offline" => ServerStatus::Offline, diff --git a/crates/ployer-core/src/models/server_tests.rs b/crates/ployer-core/src/models/server_tests.rs index fb460a7..f20437e 100644 --- a/crates/ployer-core/src/models/server_tests.rs +++ b/crates/ployer-core/src/models/server_tests.rs @@ -8,11 +8,11 @@ fn server_status_round_trips() { (ServerStatus::Unknown, "unknown"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(ServerStatus::from_str(s), variant); + assert_eq!(ServerStatus::from_db_str(s), variant); } } #[test] fn server_status_unknown_defaults_to_unknown() { - assert_eq!(ServerStatus::from_str("unreachable"), ServerStatus::Unknown); + assert_eq!(ServerStatus::from_db_str("unreachable"), ServerStatus::Unknown); } diff --git a/crates/ployer-core/src/models/user.rs b/crates/ployer-core/src/models/user.rs index 47a5615..7fa8e36 100644 --- a/crates/ployer-core/src/models/user.rs +++ b/crates/ployer-core/src/models/user.rs @@ -28,7 +28,19 @@ impl UserRole { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `UserRole` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`UserRole::User`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Anything that is not `"admin"` is treated as an unprivileged user, so a + /// corrupt value fails closed. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "admin" => UserRole::Admin, _ => UserRole::User, diff --git a/crates/ployer-core/src/models/user_tests.rs b/crates/ployer-core/src/models/user_tests.rs index abae87b..9afa07c 100644 --- a/crates/ployer-core/src/models/user_tests.rs +++ b/crates/ployer-core/src/models/user_tests.rs @@ -4,11 +4,11 @@ use super::*; fn user_role_round_trips() { assert_eq!(UserRole::Admin.as_str(), "admin"); assert_eq!(UserRole::User.as_str(), "user"); - assert_eq!(UserRole::from_str("admin"), UserRole::Admin); - assert_eq!(UserRole::from_str("user"), UserRole::User); + assert_eq!(UserRole::from_db_str("admin"), UserRole::Admin); + assert_eq!(UserRole::from_db_str("user"), UserRole::User); } #[test] fn user_role_unknown_defaults_to_user() { - assert_eq!(UserRole::from_str("superadmin"), UserRole::User); + assert_eq!(UserRole::from_db_str("superadmin"), UserRole::User); } diff --git a/crates/ployer-core/src/models/webhook.rs b/crates/ployer-core/src/models/webhook.rs index 9f703f1..897885e 100644 --- a/crates/ployer-core/src/models/webhook.rs +++ b/crates/ployer-core/src/models/webhook.rs @@ -27,7 +27,18 @@ impl WebhookProvider { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `WebhookProvider` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`WebhookProvider::GitHub`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Matching is case-insensitive. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s.to_lowercase().as_str() { "github" => WebhookProvider::GitHub, "gitlab" => WebhookProvider::GitLab, @@ -71,7 +82,16 @@ impl WebhookDeliveryStatus { } } - pub fn from_str(s: &str) -> Self { + /// Parse a `WebhookDeliveryStatus` out of the string stored in its database column. + /// + /// Total and lossy by design: an unrecognised value yields + /// [`WebhookDeliveryStatus::Failed`] rather than an error, so a row written by a newer + /// schema can never make an existing row unreadable. + /// + /// Deliberately not [`std::str::FromStr`]: that trait would need + /// `Err = Infallible`, which hides the fallback from callers and makes + /// `"nonsense".parse()` look like a successful parse. + pub fn from_db_str(s: &str) -> Self { match s { "success" => WebhookDeliveryStatus::Success, "failed" => WebhookDeliveryStatus::Failed, diff --git a/crates/ployer-core/src/models/webhook_tests.rs b/crates/ployer-core/src/models/webhook_tests.rs index 06ec91e..ffd44fd 100644 --- a/crates/ployer-core/src/models/webhook_tests.rs +++ b/crates/ployer-core/src/models/webhook_tests.rs @@ -4,19 +4,19 @@ use super::*; fn webhook_provider_round_trips() { assert_eq!(WebhookProvider::GitHub.as_str(), "github"); assert_eq!(WebhookProvider::GitLab.as_str(), "gitlab"); - assert_eq!(WebhookProvider::from_str("github"), WebhookProvider::GitHub); - assert_eq!(WebhookProvider::from_str("gitlab"), WebhookProvider::GitLab); + assert_eq!(WebhookProvider::from_db_str("github"), WebhookProvider::GitHub); + assert_eq!(WebhookProvider::from_db_str("gitlab"), WebhookProvider::GitLab); } #[test] fn webhook_provider_is_case_insensitive() { - assert_eq!(WebhookProvider::from_str("GitHub"), WebhookProvider::GitHub); - assert_eq!(WebhookProvider::from_str("GitLab"), WebhookProvider::GitLab); + assert_eq!(WebhookProvider::from_db_str("GitHub"), WebhookProvider::GitHub); + assert_eq!(WebhookProvider::from_db_str("GitLab"), WebhookProvider::GitLab); } #[test] fn webhook_provider_unknown_defaults_to_github() { - assert_eq!(WebhookProvider::from_str("bitbucket"), WebhookProvider::GitHub); + assert_eq!(WebhookProvider::from_db_str("bitbucket"), WebhookProvider::GitHub); } #[test] @@ -27,11 +27,11 @@ fn webhook_delivery_status_round_trips() { (WebhookDeliveryStatus::Skipped, "skipped"), ] { assert_eq!(variant.as_str(), s); - assert_eq!(WebhookDeliveryStatus::from_str(s), variant); + assert_eq!(WebhookDeliveryStatus::from_db_str(s), variant); } } #[test] fn webhook_delivery_status_unknown_defaults_to_failed() { - assert_eq!(WebhookDeliveryStatus::from_str("unknown"), WebhookDeliveryStatus::Failed); + assert_eq!(WebhookDeliveryStatus::from_db_str("unknown"), WebhookDeliveryStatus::Failed); } diff --git a/crates/ployer-db/src/repositories/application.rs b/crates/ployer-db/src/repositories/application.rs index 72ec987..99b6a64 100644 --- a/crates/ployer-db/src/repositories/application.rs +++ b/crates/ployer-db/src/repositories/application.rs @@ -253,12 +253,12 @@ impl From for Application { server_id: row.server_id, git_url: row.git_url, git_branch: row.git_branch, - build_strategy: BuildStrategy::from_str(&row.build_strategy), + build_strategy: BuildStrategy::from_db_str(&row.build_strategy), dockerfile_path: row.dockerfile_path, port: row.port.map(|p| p as u16), cpu_limit: row.cpu_limit, memory_limit: row.memory_limit, - status: AppStatus::from_str(&row.status), + status: AppStatus::from_db_str(&row.status), auto_deploy: row.auto_deploy != 0, compose_content: row.compose_content, template_slug: row.template_slug, diff --git a/crates/ployer-db/src/repositories/deployment.rs b/crates/ployer-db/src/repositories/deployment.rs index 383d84f..d9661cf 100644 --- a/crates/ployer-db/src/repositories/deployment.rs +++ b/crates/ployer-db/src/repositories/deployment.rs @@ -83,7 +83,7 @@ impl DeploymentRepository { server_id: r.server_id, commit_sha: r.commit_sha, commit_message: r.commit_message, - status: DeploymentStatus::from_str(&r.status), + status: DeploymentStatus::from_db_str(&r.status), build_log: r.build_log, container_id: r.container_id, image_tag: r.image_tag, @@ -116,7 +116,7 @@ impl DeploymentRepository { server_id: r.server_id, commit_sha: r.commit_sha, commit_message: r.commit_message, - status: DeploymentStatus::from_str(&r.status), + status: DeploymentStatus::from_db_str(&r.status), build_log: r.build_log, container_id: r.container_id, image_tag: r.image_tag, @@ -214,7 +214,7 @@ impl DeploymentRepository { server_id: r.server_id, commit_sha: r.commit_sha, commit_message: r.commit_message, - status: DeploymentStatus::from_str(&r.status), + status: DeploymentStatus::from_db_str(&r.status), build_log: r.build_log, container_id: r.container_id, image_tag: r.image_tag, diff --git a/crates/ployer-db/src/repositories/health_check.rs b/crates/ployer-db/src/repositories/health_check.rs index 948e6a0..07d3cba 100644 --- a/crates/ployer-db/src/repositories/health_check.rs +++ b/crates/ployer-db/src/repositories/health_check.rs @@ -219,7 +219,7 @@ impl HealthCheckRepository { id: r.id, application_id: r.application_id, container_id: r.container_id, - status: HealthCheckStatus::from_str(&r.status), + status: HealthCheckStatus::from_db_str(&r.status), response_time_ms: r.response_time_ms.map(|v| v as i32), status_code: r.status_code.map(|v| v as i32), error_message: r.error_message, @@ -243,7 +243,7 @@ impl HealthCheckRepository { .fetch_optional(&self.pool) .await?; - Ok(row.map(|r| HealthCheckStatus::from_str(&r.status))) + Ok(row.map(|r| HealthCheckStatus::from_db_str(&r.status))) } /// Clean up old health check results (keep only last N days) diff --git a/crates/ployer-db/src/repositories/server.rs b/crates/ployer-db/src/repositories/server.rs index 9e722b8..920bbfc 100644 --- a/crates/ployer-db/src/repositories/server.rs +++ b/crates/ployer-db/src/repositories/server.rs @@ -172,7 +172,7 @@ impl From for Server { username: row.username, ssh_key_encrypted: row.ssh_key_encrypted, is_local: row.is_local != 0, - status: ServerStatus::from_str(&row.status), + status: ServerStatus::from_db_str(&row.status), last_seen_at: row.last_seen_at.and_then(|s| { chrono::DateTime::parse_from_rfc3339(&s) .ok() diff --git a/crates/ployer-db/src/repositories/user.rs b/crates/ployer-db/src/repositories/user.rs index 259dfda..f51fa56 100644 --- a/crates/ployer-db/src/repositories/user.rs +++ b/crates/ployer-db/src/repositories/user.rs @@ -107,7 +107,7 @@ impl From for User { email: row.email, password_hash: row.password_hash, name: row.name, - role: UserRole::from_str(&row.role), + role: UserRole::from_db_str(&row.role), created_at: chrono::DateTime::parse_from_rfc3339(&row.created_at) .unwrap() .with_timezone(&chrono::Utc), diff --git a/crates/ployer-db/src/repositories/webhook.rs b/crates/ployer-db/src/repositories/webhook.rs index 6d2c8c2..d4f5799 100644 --- a/crates/ployer-db/src/repositories/webhook.rs +++ b/crates/ployer-db/src/repositories/webhook.rs @@ -67,7 +67,7 @@ impl WebhookRepository { Ok(row.map(|r| Webhook { id: r.id, application_id: r.application_id, - provider: WebhookProvider::from_str(&r.provider), + provider: WebhookProvider::from_db_str(&r.provider), secret: r.secret, enabled: r.enabled != 0, created_at: r.created_at.parse().unwrap(), @@ -213,13 +213,13 @@ impl WebhookRepository { id: r.id, webhook_id: r.webhook_id, application_id: r.application_id, - provider: WebhookProvider::from_str(&r.provider), + provider: WebhookProvider::from_db_str(&r.provider), event_type: r.event_type, branch: r.branch, commit_sha: r.commit_sha, commit_message: r.commit_message, author: r.author, - status: WebhookDeliveryStatus::from_str(&r.status), + status: WebhookDeliveryStatus::from_db_str(&r.status), response_code: r.response_code.map(|c| c as i32), error_message: r.error_message, deployment_id: r.deployment_id, From 87e4249b519f3a5b4cd53bfdc78848fdf88f5aab Mon Sep 17 00:00:00 2001 From: Nusendra Hanggarawan Date: Wed, 28 Oct 2026 10:43:29 +0700 Subject: [PATCH 3/5] docs+ci: document the two build prerequisites and pin the clippy gate Both prerequisites were already encoded in release.yml but nowhere a human would look, which is why they cost ~20 minutes to rediscover. DOCUMENTATION.md - Prerequisites gains OpenSSL headers, with the package name per distro, the reason (reqwest's default native-tls feature pulls in openssl-sys), and the verbatim error so it is searchable. - A new subsection on SQLX_OFFLINE=true: what breaks without it, why the error says "no such table" rather than "no database", and that the fix is offline mode and not running migrations. - A new "Development Checks" section with the two gate commands and the house rule for lint exceptions: narrowly scoped #[allow] on the item with a comment, never a wider gate. README.md - One line under Requirements pointing source builders at the above; the existing list is about running a release binary, not building one. .github/workflows/ci.yml (new) - Runs `cargo clippy --workspace --all-targets -- -D warnings` and `cargo test --workspace` on pushes to main and on every PR, so the gate cannot rot again. Mirrors release.yml: same stable toolchain action, same libssl-dev/pkg-config step, same Swatinem/rust-cache, SQLX_OFFLINE in the workflow env. - `cargo fmt --check` is included as continue-on-error only. The tree is not rustfmt-clean on main; making it blocking would either fail on arrival or force a tree-wide reformat that buries git blame. Advisory keeps the backlog visible without pretending it is decided. Lint attributes use a plain #[allow] plus a comment rather than the tidier `reason = ".."` form: `reason` needs Rust 1.81 and DOCUMENTATION.md declares an MSRV of 1.75. Raising the MSRV is not a lint cleanup's call to make. --- .github/workflows/ci.yml | 60 +++++++++++++++++ DOCUMENTATION.md | 65 +++++++++++++++++++ README.md | 2 + crates/ployer-api/src/services/deployment.rs | 12 ++-- .../ployer-db/src/repositories/application.rs | 16 ++--- .../src/repositories/container_stats.rs | 8 +-- crates/ployer-db/src/repositories/server.rs | 8 +-- crates/ployer-db/src/repositories/webhook.rs | 8 +-- 8 files changed, 147 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..214b0e0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + # Required: `.cargo/config.toml` points DATABASE_URL at + # sqlite://ployer.db?mode=rwc, which would CREATE an empty database here and + # make every sqlx::query! macro fail with "no such table". Offline mode uses + # the committed .sqlx/ metadata instead. See DOCUMENTATION.md > Prerequisites. + SQLX_OFFLINE: true + +jobs: + check: + name: Clippy and tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + # reqwest is built with its default native-tls feature, so openssl-sys + # needs system OpenSSL or the build fails on the first dependency. + - name: Install build dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y libssl-dev pkg-config + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + + # The gate. Any warning is an error; see DOCUMENTATION.md > + # Development Checks for how to handle a lint that is wrong for a + # specific call site. + - name: cargo clippy -- -D warnings + run: cargo clippy --workspace --all-targets -- -D warnings + + - name: cargo test + run: cargo test --workspace + + # Not a gate: the tree is not rustfmt-clean and a blanket reformat is a + # separate decision. Reported so the backlog stays visible instead of + # silently growing. + - name: cargo fmt (advisory, non-blocking) + continue-on-error: true + run: cargo fmt --all -- --check diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 6b7b4dd..3f73f06 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -5,12 +5,53 @@ - **Rust** (1.75+) — [rustup.rs](https://rustup.rs) - **Node.js** (20+) or **Bun** (1.0+) — for frontend builds - **Docker** (optional) — required for container management features +- **OpenSSL headers** — `libssl-dev` on Debian/Ubuntu, `openssl-devel` on + Fedora/RHEL, `openssl` on macOS (Homebrew). Required: `reqwest` is built with + its default `native-tls` feature, so `openssl-sys` must find system OpenSSL + or the build fails on the very first dependency, long before any Ployer code + is reached. + + ```bash + sudo apt-get install -y libssl-dev pkg-config # Debian / Ubuntu + ``` + + The failure looks like this, and it is not a Ployer bug: + + ``` + error: failed to run custom build command for `openssl-sys v0.9.x` + Could not find directory of OpenSSL installation + ``` + +### `SQLX_OFFLINE=true` is required for every cargo command + +Ployer uses `sqlx`'s compile-time-checked `query!` macros, which need either a +live database matching the schema or the checked-in offline metadata in +`.sqlx/`. Always build and test with: + +```bash +export SQLX_OFFLINE=true +``` + +Without it, `.cargo/config.toml` points `DATABASE_URL` at +`sqlite://ployer.db?mode=rwc`, whose `mode=rwc` *creates* an empty database in +whatever directory you happen to be in. The macros then type-check against that +empty database and every one of them fails: + +``` +error: error returned from database: (code: 1) no such table: applications +``` + +The fix is never "run the migrations" — it is to set `SQLX_OFFLINE=true` and +use the committed `.sqlx/` metadata. Only regenerate that metadata +(`cargo sqlx prepare --workspace`, against a migrated database) when you change +a SQL query. ## Quick Start ### 1. Build the backend ```bash +export SQLX_OFFLINE=true cargo build --workspace ``` @@ -52,6 +93,30 @@ Expected response: `docker: false` is normal if Docker is not running. +## Development Checks + +CI (`.github/workflows/ci.yml`) runs these on every push and pull request, and +they are the same commands to run locally before opening a PR: + +```bash +export SQLX_OFFLINE=true +cargo clippy --workspace --all-targets -- -D warnings +cargo test --workspace +``` + +The clippy gate is enforced: **any** warning fails the build. If you are adding +a function that trips a lint you believe is wrong for the case at hand, add a +narrowly scoped `#[allow(clippy::the_lint)]` on that item with a comment saying +why, rather than widening the gate or silencing the lint crate-wide. There are +currently six such allows, all `clippy::too_many_arguments` on SQL writers whose +arguments are one-per-column. + +`cargo fmt --check` is deliberately **not** in CI yet: the tree predates any +formatting discipline and is not rustfmt-clean, so turning it on would either +fail immediately or require a tree-wide reformat that would bury every +subsequent `git blame`. That is its own decision, not a side effect of a lint +cleanup. + ## CLI Commands | Command | Description | diff --git a/README.md b/README.md index 3eb0de0..58046be 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ A lightweight, self-hosted PaaS — deploy your apps from Git with automatic SSL > **Important:** Install on a **fresh, dedicated server**. Ployer owns ports 80 and 443 via Caddy. It will conflict with Nginx, Apache, Coolify, or any other reverse proxy already running on those ports. +**Building from source?** You need `libssl-dev` and `SQLX_OFFLINE=true` as well — see [DOCUMENTATION.md § Prerequisites](DOCUMENTATION.md#prerequisites). The above applies to *running* a release binary. + --- ## Quick Install diff --git a/crates/ployer-api/src/services/deployment.rs b/crates/ployer-api/src/services/deployment.rs index 0c3ed62..8bdcbc5 100644 --- a/crates/ployer-api/src/services/deployment.rs +++ b/crates/ployer-api/src/services/deployment.rs @@ -105,13 +105,11 @@ impl DeploymentService { } /// Execute the full deployment pipeline - #[allow( - clippy::too_many_arguments, - reason = "spawned as a detached task, so every dependency must be passed by value \ - rather than borrowed from AppState; the first six are the ambient services \ - and the last four are this job's inputs. Bundling them into a struct is a \ - refactor of the deployment hot path, deliberately not folded into a lint fix." - )] + // spawned as a detached task, so every dependency must be passed by value rather than + // borrowed from AppState; the first six are the ambient services and the last four are this + // job's inputs. Bundling them into a struct is a refactor of the deployment hot path, + // deliberately not folded into a lint fix. + #[allow(clippy::too_many_arguments)] async fn execute_deployment( db: SqlitePool, docker: Arc, diff --git a/crates/ployer-db/src/repositories/application.rs b/crates/ployer-db/src/repositories/application.rs index 99b6a64..7da68df 100644 --- a/crates/ployer-db/src/repositories/application.rs +++ b/crates/ployer-db/src/repositories/application.rs @@ -12,11 +12,9 @@ impl ApplicationRepository { Self { pool } } - #[allow( - clippy::too_many_arguments, - reason = "one parameter per `applications` column; a params struct would duplicate \ - the column list and could drift from the INSERT silently" - )] + // one parameter per `applications` column; a params struct would duplicate the column list + // and could drift from the INSERT silently + #[allow(clippy::too_many_arguments)] pub async fn create( &self, name: &str, @@ -129,11 +127,9 @@ impl ApplicationRepository { Ok(rows.into_iter().map(|r| r.into()).collect()) } - #[allow( - clippy::too_many_arguments, - reason = "one parameter per `applications` column; a params struct would duplicate \ - the column list and could drift from the UPDATE silently" - )] + // one parameter per `applications` column; a params struct would duplicate the column list + // and could drift from the UPDATE silently + #[allow(clippy::too_many_arguments)] pub async fn update( &self, id: &str, diff --git a/crates/ployer-db/src/repositories/container_stats.rs b/crates/ployer-db/src/repositories/container_stats.rs index 6a3fd1d..50a9179 100644 --- a/crates/ployer-db/src/repositories/container_stats.rs +++ b/crates/ployer-db/src/repositories/container_stats.rs @@ -14,11 +14,9 @@ impl ContainerStatsRepository { } /// Record container stats - #[allow( - clippy::too_many_arguments, - reason = "one parameter per `container_stats` column; a params struct would duplicate \ - the column list and could drift from the INSERT silently" - )] + // one parameter per `container_stats` column; a params struct would duplicate the column + // list and could drift from the INSERT silently + #[allow(clippy::too_many_arguments)] pub async fn record( &self, container_id: &str, diff --git a/crates/ployer-db/src/repositories/server.rs b/crates/ployer-db/src/repositories/server.rs index 920bbfc..b88b9eb 100644 --- a/crates/ployer-db/src/repositories/server.rs +++ b/crates/ployer-db/src/repositories/server.rs @@ -70,11 +70,9 @@ impl ServerRepository { Ok(rows.into_iter().map(|r| r.into()).collect()) } - #[allow( - clippy::too_many_arguments, - reason = "one parameter per `servers` column; a params struct would duplicate \ - the column list and could drift from the UPDATE silently" - )] + // one parameter per `servers` column; a params struct would duplicate the column list and + // could drift from the UPDATE silently + #[allow(clippy::too_many_arguments)] pub async fn update( &self, id: &str, diff --git a/crates/ployer-db/src/repositories/webhook.rs b/crates/ployer-db/src/repositories/webhook.rs index d4f5799..633b405 100644 --- a/crates/ployer-db/src/repositories/webhook.rs +++ b/crates/ployer-db/src/repositories/webhook.rs @@ -118,11 +118,9 @@ impl WebhookRepository { } /// Create a webhook delivery record - #[allow( - clippy::too_many_arguments, - reason = "one parameter per `webhook_deliveries` column; a params struct would duplicate \ - the column list and could drift from the INSERT silently" - )] + // one parameter per `webhook_deliveries` column; a params struct would duplicate the column + // list and could drift from the INSERT silently + #[allow(clippy::too_many_arguments)] pub async fn create_delivery( &self, webhook_id: &str, From c4ffb584c35cb1380bae07f1f23db1e45d2005af Mon Sep 17 00:00:00 2001 From: Nusendra Hanggarawan Date: Wed, 28 Oct 2026 10:58:27 +0700 Subject: [PATCH 4/5] fix(ci): pin the clippy toolchain, and fix the 24th finding it surfaced The first CI run on this PR failed, which is the gate doing its job and also exposing a design flaw in how I had set it up. 1. A 24th finding, invisible locally crates/ployer-api/src/routes/system.rs:104 trips unnecessary_sort_by on Rust 1.99 (CI) but not on 1.94 (the toolchain I measured the other 23 with), so the "full set" of 23 was itself relative to a toolchain version. Fixed with sort_by_cached_key rather than clippy's suggested sort_by_key: version_key allocates a Vec<(u32, String)> on every call, and the old comparator recomputed it twice per comparison. Caching drops that to one key per element. Order is unchanged -- Reverse(key) ascending is the same as the old descending comparator, and both sorts are stable, so ties keep input order either way. 2. The gate was pinned to a moving target `-D warnings` on a floating `stable` toolchain means every six-week Rust release can red-light every open PR over a new lint unrelated to the change under review. That is the same rot this card set out to fix, just pointing the other way. CI is now two jobs: - lint: toolchain pinned to 1.99.1, runs the clippy gate. Deterministic, so a clippy upgrade is its own reviewable PR that bumps the pin and fixes the new findings together. The upgrade procedure is in a comment at the top of the workflow. - test: floating stable, runs the suite. Genuine compiler and runtime regressions still surface, which is the kind of breakage worth interrupting a PR for. Verified against the pinned toolchain, in an isolated CARGO_TARGET_DIR: cargo +1.99.1 clippy --workspace --all-targets -- -D warnings -> exit 0 SQLX_OFFLINE=true cargo +1.99.1 test --workspace -> 137 passed --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++---- crates/ployer-api/src/routes/system.rs | 5 ++- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 214b0e0..53c26de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,16 +22,28 @@ env: SQLX_OFFLINE: true jobs: - check: - name: Clippy and tests + # The lint gate runs on a PINNED toolchain, on purpose. + # + # `-D warnings` plus a floating `stable` means every six-week Rust release can + # red-light every open PR over a brand-new lint that has nothing to do with the + # change under review. Pinning makes the gate deterministic: a clippy upgrade + # becomes its own PR that bumps this version and fixes the new findings in one + # place, reviewed on its own merits. + # + # To upgrade: bump the version below, run + # cargo + clippy --workspace --all-targets -- -D warnings + # locally, fix what it finds, and ship both together. + lint: + name: Clippy (pinned 1.99.1) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable + uses: dtolnay/rust-toolchain@master with: - components: clippy + toolchain: 1.99.1 + components: clippy, rustfmt # reqwest is built with its default native-tls feature, so openssl-sys # needs system OpenSSL or the build fails on the first dependency. @@ -42,6 +54,8 @@ jobs: - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 + with: + key: lint-1.99.1 # The gate. Any warning is an error; see DOCUMENTATION.md > # Development Checks for how to handle a lint that is wrong for a @@ -49,12 +63,34 @@ jobs: - name: cargo clippy -- -D warnings run: cargo clippy --workspace --all-targets -- -D warnings - - name: cargo test - run: cargo test --workspace - # Not a gate: the tree is not rustfmt-clean and a blanket reformat is a # separate decision. Reported so the backlog stays visible instead of # silently growing. - name: cargo fmt (advisory, non-blocking) continue-on-error: true run: cargo fmt --all -- --check + + # Tests run on floating `stable` so genuine compiler and runtime regressions + # still surface; a test failure is always worth looking at, whereas a new lint + # usually is not urgent. + test: + name: Tests (stable) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install build dependencies + run: | + sudo apt-get update -qq + sudo apt-get install -y libssl-dev pkg-config + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + key: test-stable + + - name: cargo test + run: cargo test --workspace diff --git a/crates/ployer-api/src/routes/system.rs b/crates/ployer-api/src/routes/system.rs index 58b0fb0..0ef8f6c 100644 --- a/crates/ployer-api/src/routes/system.rs +++ b/crates/ployer-api/src/routes/system.rs @@ -101,7 +101,10 @@ async fn fetch_latest_version() -> Option { .map(|t| (t.to_string(), r)) }) .collect(); - candidates.sort_by(|a, b| version_key(&b.0).cmp(&version_key(&a.0))); + // `sort_by_cached_key` rather than `sort_by_key`: `version_key` allocates a + // Vec<(u32, String)> per call, and a plain comparator recomputes it twice per + // comparison. Caching makes it one key per element. + candidates.sort_by_cached_key(|c| std::cmp::Reverse(version_key(&c.0))); let latest_tag = candidates .into_iter() From f7bd58a65a8b58bd979890bcca0cc8c6a54b34a1 Mon Sep 17 00:00:00 2001 From: Nusendra Hanggarawan Date: Wed, 28 Oct 2026 11:01:37 +0700 Subject: [PATCH 5/5] =?UTF-8?q?docs:=20correct=20the=20rustfmt=20claim=20?= =?UTF-8?q?=E2=80=94=20it=20is=20in=20CI,=20just=20non-blocking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured: cargo +1.99.1 fmt --all -- --check reports ~325 unformatted hunks across nearly every file, so the 'not rustfmt-clean' premise holds. But the previous wording said fmt was 'not in CI yet' when the workflow does run it; it is non-blocking, which is a different claim. Also notes that GitHub reports a continue-on-error step as green whatever it returns, so a reader does not mistake the green check for a clean tree. --- .github/workflows/ci.yml | 6 +++--- DOCUMENTATION.md | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53c26de..25eaa54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,9 +63,9 @@ jobs: - name: cargo clippy -- -D warnings run: cargo clippy --workspace --all-targets -- -D warnings - # Not a gate: the tree is not rustfmt-clean and a blanket reformat is a - # separate decision. Reported so the backlog stays visible instead of - # silently growing. + # Not a gate: the tree has ~325 unformatted hunks and a blanket reformat + # is a separate decision. GitHub reports a continue-on-error step as + # green whatever happens, so this is log-only visibility, not a signal. - name: cargo fmt (advisory, non-blocking) continue-on-error: true run: cargo fmt --all -- --check diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 3f73f06..70d9fc1 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -111,11 +111,13 @@ why, rather than widening the gate or silencing the lint crate-wide. There are currently six such allows, all `clippy::too_many_arguments` on SQL writers whose arguments are one-per-column. -`cargo fmt --check` is deliberately **not** in CI yet: the tree predates any -formatting discipline and is not rustfmt-clean, so turning it on would either -fail immediately or require a tree-wide reformat that would bury every -subsequent `git blame`. That is its own decision, not a side effect of a lint -cleanup. +`cargo fmt --check` is **not** a gate: the tree predates any formatting +discipline and currently has ~325 unformatted hunks spread across nearly every +file, so turning it on would either fail immediately or require a tree-wide +reformat that would bury every subsequent `git blame`. That is its own +decision, not a side effect of a lint cleanup. CI still runs it as a +`continue-on-error` step, so the current state is one click away in the job +log; note that GitHub reports such a step as green regardless of its result. ## CLI Commands