mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 16:00:38 +00:00
e1a815f6a0
* refactor: extract windmill-dep-map crate for parallel api/worker compilation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve WebhookShared type mismatch and missing enterprise propagation - Make windmill-api webhook_util re-export from windmill-common instead of duplicating types, fixing Extension<WebhookShared> mismatch between windmill-store and windmill-api - Add windmill-api-jobs/enterprise to windmill-trigger enterprise feature so check_license_key_valid is available when trigger subcrates enable enterprise on windmill-trigger Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: stop trigger features from unconditionally enabling enterprise Move enterprise propagation for all trigger subcrates from individual trigger feature definitions to the enterprise feature itself, so enterprise is only enabled when explicitly requested. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: remove unused pub use re-exports and disable CI cargo cache - Remove unused re-exports from windmill-worker/src/lib.rs: trigger_dependents_to_recompute_dependencies, handle_job_error, and unused bun/otel items - Fix callers to use direct module paths instead - Add windmill-dep-map as dev-dependency for tests - Disable cargo cache in backend-check CI (faster from-scratch builds) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: restore bun re-exports used by tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * all * chore: re-enable cargo cache for check_ee_full CI job Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
195 lines
6.1 KiB
Rust
195 lines
6.1 KiB
Rust
mod common;
|
|
mod workspace_dependencies {
|
|
|
|
use crate::common::in_test_worker;
|
|
use crate::common::init_client;
|
|
use crate::common::listen_for_completed_jobs;
|
|
use sqlx::{Pool, Postgres};
|
|
use tokio_stream::StreamExt;
|
|
use windmill_common::scripts::ScriptLang;
|
|
use windmill_dep_map::workspace_dependencies::NewWorkspaceDependencies;
|
|
mod deps {
|
|
pub const REQUIREMENTS_IN: &'static str = "tiny==0.1.3";
|
|
// pub const GO_MOD: &'static str = r##"
|
|
// module example.com/project
|
|
|
|
// go 1.20
|
|
|
|
// require github.com/gin-gonic/gin v1.8.1
|
|
// "##;
|
|
|
|
pub const PACKAGE_JSON: &'static str = r##"
|
|
{
|
|
"name": "example-project",
|
|
"version": "1.0.0",
|
|
"dependencies": {
|
|
"express": "^4.17.1"
|
|
}
|
|
}
|
|
"##;
|
|
|
|
pub const COMPOSER_JSON: &'static str = r##"
|
|
{
|
|
"name": "example/project",
|
|
"require": {
|
|
"monolog/monolog": "^2.3"
|
|
}
|
|
}
|
|
"##;
|
|
}
|
|
|
|
#[cfg(feature = "python")]
|
|
#[sqlx::test(fixtures("base", "workspace_dependencies_leafs"))]
|
|
#[ignore]
|
|
async fn basic_manual_named(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
let ((_client, port, _s), db, mut completed) = (
|
|
init_client(db.clone()).await,
|
|
&db,
|
|
listen_for_completed_jobs(&db).await,
|
|
);
|
|
|
|
for (idx, (l, c)) in [
|
|
(ScriptLang::Python3, deps::REQUIREMENTS_IN),
|
|
(ScriptLang::Bun, deps::PACKAGE_JSON),
|
|
(ScriptLang::Php, deps::COMPOSER_JSON),
|
|
// (ScriptLang::Go, deps::GO_MOD),
|
|
]
|
|
.iter()
|
|
.enumerate()
|
|
{
|
|
let id = NewWorkspaceDependencies {
|
|
workspace_id: "test-workspace".into(),
|
|
language: *l,
|
|
content: (*c).into(),
|
|
name: Some("test".to_owned()),
|
|
description: None,
|
|
}
|
|
.create(("".to_owned(), "".to_owned(), "".to_owned()), db.clone())
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(idx + 1, id as usize);
|
|
}
|
|
|
|
// Wait for 4 jobs.
|
|
// Creating those dependencies will trigger redeployment of all scripts in workspace_dependencies_leafs.sql
|
|
in_test_worker(
|
|
db,
|
|
async {
|
|
completed.next().await;
|
|
completed.next().await;
|
|
completed.next().await;
|
|
// completed.next().await;
|
|
},
|
|
port,
|
|
)
|
|
.await;
|
|
|
|
// Verify all scripts have correct locks
|
|
// let mut langs = vec![];
|
|
// for r in sqlx::query!(
|
|
// r#"SELECT language AS "language: ScriptLang",lock FROM script WHERE archived = false"#
|
|
// )
|
|
// .fetch_all(db)
|
|
// .await
|
|
// .unwrap()
|
|
// {
|
|
// match r.language {
|
|
// ScriptLang::Python3 => assert_eq!("", &r.lock.unwrap()),
|
|
// ScriptLang::Go => todo!(),
|
|
// ScriptLang::Bun => todo!(),
|
|
// ScriptLang::Bunnative => todo!(),
|
|
// ScriptLang::Php => todo!(),
|
|
// _ => panic!("Unsupported language"),
|
|
// }
|
|
|
|
// langs.push(r.language);
|
|
// }
|
|
|
|
// langs.sort();
|
|
// // Just tiny additional verification for peace of mind.
|
|
// assert_eq!(langs.as_slice(), &[]);
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[sqlx::test(fixtures("base", "hub_sync_blacklist"))]
|
|
async fn hub_sync_blacklist_from_workspace_deps(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
let ((_client, port, _s), db, mut completed) = (
|
|
init_client(db.clone()).await,
|
|
&db,
|
|
listen_for_completed_jobs(&db).await,
|
|
);
|
|
|
|
// Verify built-in fixtures exist
|
|
// Check that the setup_app exists
|
|
let app_exists =
|
|
sqlx::query_scalar!("SELECT EXISTS(SELECT 1 FROM app WHERE path = 'g/all/setup_app')")
|
|
.fetch_one(db)
|
|
.await
|
|
.unwrap();
|
|
assert!(app_exists.unwrap(), "Expected g/all/setup_app to exist");
|
|
|
|
// Check that hub_sync script exists and is a Bun script
|
|
let hub_sync_lang = sqlx::query_scalar!(
|
|
r#"SELECT language AS "language: ScriptLang" FROM script WHERE path = 'u/admin/hub_sync'"#
|
|
)
|
|
.fetch_one(db)
|
|
.await
|
|
.unwrap();
|
|
assert_eq!(
|
|
hub_sync_lang,
|
|
ScriptLang::Bun,
|
|
"Expected hub_sync to be a Bun script"
|
|
);
|
|
|
|
// Create unnamed (default) workspace dependencies for Bun
|
|
let _id = NewWorkspaceDependencies {
|
|
workspace_id: "admins".into(),
|
|
language: ScriptLang::Bun,
|
|
content: deps::PACKAGE_JSON.into(),
|
|
name: None, // No name = default workspace dependencies
|
|
description: None,
|
|
}
|
|
.create(("".to_owned(), "".to_owned(), "".to_owned()), db.clone())
|
|
.await
|
|
.unwrap();
|
|
|
|
// Wait for exactly 1 job (only u/admin/simple_bun, not hub_sync)
|
|
let job_id = in_test_worker(db, async { completed.next().await }, port)
|
|
.await
|
|
.expect("Expected one job to complete");
|
|
|
|
// Query the job's runnable_path
|
|
let runnable_path =
|
|
sqlx::query_scalar!("SELECT runnable_path FROM v2_job WHERE id = $1", job_id)
|
|
.fetch_one(db)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(
|
|
runnable_path,
|
|
Some("u/admin/simple_bun".to_string()),
|
|
"Expected job runnable_path to be 'u/admin/simple_bun' (hub_sync should be blacklisted)"
|
|
);
|
|
|
|
// Assert total job count is 1
|
|
let job_count = sqlx::query_scalar!("SELECT COUNT(*) FROM v2_job")
|
|
.fetch_one(db)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(job_count, Some(1), "Expected exactly one job total");
|
|
|
|
// Assert v2_job_queue is empty
|
|
let queue_count = sqlx::query_scalar!("SELECT COUNT(*) FROM v2_job_queue")
|
|
.fetch_one(db)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(queue_count, Some(0), "Expected job queue to be empty");
|
|
|
|
Ok(())
|
|
}
|
|
}
|