From e32bcd33838113db24e41592a0fff2e837eed9c3 Mon Sep 17 00:00:00 2001 From: Lucas Abel <22837557+uael@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:37:31 +0100 Subject: [PATCH] backend: pass `cargo check --all-features` (#4946) --- .github/workflows/backend-check.yml | 8 +++-- backend/src/monitor.rs | 1 + backend/windmill-api/src/job_helpers_ee.rs | 31 ++++++++++++++++--- backend/windmill-api/src/smtp_server_ee.rs | 6 +++- backend/windmill-queue/src/jobs.rs | 2 -- backend/windmill-worker/src/handle_child.rs | 4 ++- .../windmill-worker/src/result_processor.rs | 3 -- backend/windmill-worker/src/worker.rs | 7 +++-- 8 files changed, 46 insertions(+), 16 deletions(-) diff --git a/.github/workflows/backend-check.yml b/.github/workflows/backend-check.yml index c26abd93d4..40f781937e 100644 --- a/.github/workflows/backend-check.yml +++ b/.github/workflows/backend-check.yml @@ -48,7 +48,9 @@ jobs: - name: cargo check working-directory: ./backend timeout-minutes: 16 - run: SQLX_OFFLINE=true cargo check --all-features + run: | + mkdir -p fake_frontend_build + FRONTEND_BUILD_DIR=$(pwd)/fake_frontend_build SQLX_OFFLINE=true cargo check --all-features check_ee: runs-on: ubicloud-standard-8 @@ -125,6 +127,8 @@ jobs: - name: cargo check timeout-minutes: 16 working-directory: ./backend - run: SQLX_OFFLINE=true cargo check --all-features + run: | + mkdir -p fake_frontend_build + FRONTEND_BUILD_DIR=$(pwd)/fake_frontend_build SQLX_OFFLINE=true cargo check --all-features \ No newline at end of file diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index 1059913f56..2a8b3b6f33 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -344,6 +344,7 @@ pub async fn load_metrics_debug_enabled(db: &DB) -> error::Result<()> { #[cfg(all(not(target_env = "msvc"), feature = "jemalloc"))] #[derive(Debug, Clone)] pub struct MallctlError { + #[allow(unused)] pub code: i32, } diff --git a/backend/windmill-api/src/job_helpers_ee.rs b/backend/windmill-api/src/job_helpers_ee.rs index 3033a2ec5a..be2dd49ab8 100644 --- a/backend/windmill-api/src/job_helpers_ee.rs +++ b/backend/windmill-api/src/job_helpers_ee.rs @@ -12,6 +12,12 @@ use std::sync::Arc; use windmill_common::error; #[cfg(feature = "parquet")] use windmill_common::{db::UserDB, s3_helpers::ObjectStoreResource}; + +#[cfg(feature = "parquet")] +use bytes::Bytes; +#[cfg(feature = "parquet")] +use futures::Stream; + #[derive(Serialize)] pub struct UploadFileResponse { pub file_key: String, @@ -35,7 +41,7 @@ pub async fn get_workspace_s3_resource<'c>( } pub fn get_random_file_name(_file_extension: Option) -> String { - todo!() + unimplemented!("Not implemented in Windmill's Open Source repository") } pub async fn get_s3_resource<'c>( @@ -48,14 +54,31 @@ pub async fn get_s3_resource<'c>( _resource_type: Option, _job_id: Option, ) -> error::Result { - todo!() + Err(error::Error::InternalErr( + "Not implemented in Windmill's Open Source repository".to_string(), + )) } +#[cfg(feature = "parquet")] +pub async fn upload_file_from_req( + _s3_client: Arc, + _file_key: &str, + _req: axum::extract::Request, + _options: PutMultipartOpts, +) -> error::Result<()> { + Err(error::Error::InternalErr( + "Not implemented in Windmill's Open Source repository".to_string(), + )) +} + +#[cfg(feature = "parquet")] pub async fn upload_file_internal( _s3_client: Arc, _file_key: &str, - _request: axum::extract::Request, + _stream: impl Stream> + Unpin, _options: PutMultipartOpts, ) -> error::Result<()> { - todo!() + Err(error::Error::InternalErr( + "Not implemented in Windmill's Open Source repository".to_string(), + )) } diff --git a/backend/windmill-api/src/smtp_server_ee.rs b/backend/windmill-api/src/smtp_server_ee.rs index a680499148..48e274f6a1 100644 --- a/backend/windmill-api/src/smtp_server_ee.rs +++ b/backend/windmill-api/src/smtp_server_ee.rs @@ -1,4 +1,4 @@ -use crate::{db::DB, users::AuthCache}; +use crate::{auth::AuthCache, db::DB}; use std::{net::SocketAddr, sync::Arc}; use windmill_common::db::UserDB; @@ -11,6 +11,10 @@ pub struct SmtpServer { impl SmtpServer { pub async fn start_listener_thread(self: Arc, _addr: SocketAddr) -> anyhow::Result<()> { + let _ = self.auth_cache; + let _ = self.db; + let _ = self.user_db; + let _ = self.base_internal_url; Err(anyhow::anyhow!("Implementation not open source")) } } diff --git a/backend/windmill-queue/src/jobs.rs b/backend/windmill-queue/src/jobs.rs index ffedbda163..a41ad14c4e 100644 --- a/backend/windmill-queue/src/jobs.rs +++ b/backend/windmill-queue/src/jobs.rs @@ -20,8 +20,6 @@ use reqwest::Client; use serde::{ser::SerializeMap, Serialize}; use serde_json::{json, value::RawValue}; use sqlx::{types::Json, FromRow, Pool, Postgres, Transaction}; -#[cfg(feature = "benchmark")] -use std::time::Instant; use tokio::{sync::RwLock, time::sleep}; use ulid::Ulid; use uuid::Uuid; diff --git a/backend/windmill-worker/src/handle_child.rs b/backend/windmill-worker/src/handle_child.rs index 5215b05b83..5dcdbfa287 100644 --- a/backend/windmill-worker/src/handle_child.rs +++ b/backend/windmill-worker/src/handle_child.rs @@ -34,8 +34,10 @@ use windmill_common::DB; #[cfg(feature = "enterprise")] use windmill_common::job_metrics; +#[cfg(target_os = "linux")] +use tokio::io::AsyncWriteExt; use tokio::{ - io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, + io::{AsyncBufReadExt, BufReader}, process::Child, sync::{broadcast, watch}, time::{interval, sleep, Instant, MissedTickBehavior}, diff --git a/backend/windmill-worker/src/result_processor.rs b/backend/windmill-worker/src/result_processor.rs index 031cff0544..5812b12175 100644 --- a/backend/windmill-worker/src/result_processor.rs +++ b/backend/windmill-worker/src/result_processor.rs @@ -30,9 +30,6 @@ use windmill_common::bench::{BenchmarkInfo, BenchmarkIter}; use windmill_queue::{append_logs, get_queued_job, CanceledBy, WrappedError}; -#[cfg(feature = "prometheus")] -use windmill_queue::register_metric; - use serde_json::{json, value::RawValue}; use tokio::{ diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index 5fb572bb6d..aa99743e26 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -305,6 +305,7 @@ pub const DEFAULT_NATIVE_JOBS: usize = 1; const VACUUM_PERIOD: u32 = 50000; +#[cfg(any(target_os = "linux"))] const DROP_CACHE_PERIOD: u32 = 1000; pub const MAX_BUFFERED_DEDICATED_JOBS: usize = 3; @@ -855,7 +856,7 @@ pub async fn run_worker( }; #[cfg(feature = "prometheus")] - let worker_save_completed_job_duration = if METRICS_DEBUG_ENABLED.load(Ordering::Relaxed) + let _worker_save_completed_job_duration = if METRICS_DEBUG_ENABLED.load(Ordering::Relaxed) && METRICS_ENABLED.load(Ordering::Relaxed) { Some(Arc::new( @@ -1090,7 +1091,7 @@ pub async fn run_worker( } #[cfg(feature = "prometheus")] - let worker_dedicated_channel_queue_send_duration = { + let _worker_dedicated_channel_queue_send_duration = { if is_dedicated_worker && METRICS_DEBUG_ENABLED.load(Ordering::Relaxed) && METRICS_ENABLED.load(Ordering::Relaxed) @@ -1897,7 +1898,7 @@ async fn handle_queued_job( job_completed_tx: JobCompletedSender, occupancy_metrics: &mut OccupancyMetrics, killpill_rx: &mut tokio::sync::broadcast::Receiver<()>, - #[cfg(feature = "benchmark")] bench: &mut BenchmarkIter, + #[cfg(feature = "benchmark")] _bench: &mut BenchmarkIter, ) -> windmill_common::error::Result { // Extract the active span from the context