mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 16:02:11 +00:00
d36760bff7
* commit raw requirements Signed-off-by: pyranota <pyra@duck.com> * raw requirements Signed-off-by: pyranota <pyra@duck.com> * implement `parse_annotation` Signed-off-by: pyranota <pyra@duck.com> * more progress on wdeps Signed-off-by: pyranota <pyra@duck.com> * more progress Signed-off-by: pyranota <pyra@duck.com> * fixes Signed-off-by: pyranota <pyra@duck.com> * more progress Signed-off-by: pyranota <pyra@duck.com> * fixes Signed-off-by: pyranota <pyra@duck.com> * cli improvements + raw deps Signed-off-by: pyranota <pyra@duck.com> * cleanup Signed-off-by: pyranota <pyra@duck.com> * fix python versions Signed-off-by: pyranota <pyra@duck.com> * progress Signed-off-by: pyranota <pyra@duck.com> * update :) Signed-off-by: pyranota <pyra@duck.com> * add MaybeLock Signed-off-by: pyranota <pyra@duck.com> * go WIP Signed-off-by: pyranota <pyra@duck.com> * fix python ignoring py version from requirements Signed-off-by: pyranota <pyra@duck.com> * optimize php Signed-off-by: pyranota <pyra@duck.com> * require admin to alter Signed-off-by: pyranota <pyra@duck.com> * fix(cli): flow generateLocks raw deps Signed-off-by: pyranota <pyra@duck.com> * progress in checklist Signed-off-by: pyranota <pyra@duck.com> * fix agent workers Signed-off-by: pyranota <pyra@duck.com> * nits Signed-off-by: pyranota <pyra@duck.com> * nits Signed-off-by: pyranota <pyra@duck.com> * nit: remove default features Signed-off-by: pyranota <pyra@duck.com> * oh-wow Signed-off-by: pyranota <pyra@duck.com> * remove dbg! Signed-off-by: pyranota <pyra@duck.com> * nits Signed-off-by: pyranota <pyra@duck.com> * add indexes Signed-off-by: pyranota <pyra@duck.com> * cleanup Signed-off-by: pyranota <pyra@duck.com> * nits Signed-off-by: pyranota <pyra@duck.com> * remove todos Signed-off-by: pyranota <pyra@duck.com> * fix cli Signed-off-by: pyranota <pyra@duck.com> * add debug flag Signed-off-by: pyranota <pyra@duck.com> * cli: remove noise Signed-off-by: pyranota <pyra@duck.com> * fix cli Signed-off-by: pyranota <pyra@duck.com> * remove todos Signed-off-by: pyranota <pyra@duck.com> * trigger deps correctly Signed-off-by: pyranota <pyra@duck.com> * fix frontend Signed-off-by: pyranota <pyra@duck.com> * fix frontend again Signed-off-by: pyranota <pyra@duck.com> * finally fix frontend Signed-off-by: pyranota <pyra@duck.com> * ee repo ref Signed-off-by: pyranota <pyra@duck.com> * fix all Signed-off-by: pyranota <pyra@duck.com> * more fixes... Signed-off-by: pyranota <pyra@duck.com> * remove test Signed-off-by: pyranota <pyra@duck.com> * Update backend-test.yml * comment out legacy test Signed-off-by: pyranota <pyra@duck.com> * fix ci Signed-off-by: pyranota <pyra@duck.com> * fix ci? Signed-off-by: pyranota <pyra@duck.com> * comment out thing Signed-off-by: pyranota <pyra@duck.com> * ignore test Signed-off-by: pyranota <pyra@duck.com> * ci Signed-off-by: pyranota <pyra@duck.com> * base fixture Signed-off-by: pyranota <pyra@duck.com> * fix regression Signed-off-by: pyranota <pyra@duck.com> * fix docs links Signed-off-by: pyranota <pyra@duck.com> * update min version Signed-off-by: pyranota <pyra@duck.com> * simplify * implement cache for get_latest Signed-off-by: pyranota <pyra@duck.com> * move to workspace settings Signed-off-by: pyranota <pyra@duck.com> * sqlx + migration Signed-off-by: pyranota <pyra@duck.com> * more migrations Signed-off-by: pyranota <pyra@duck.com> * use box pin Signed-off-by: pyranota <pyra@duck.com> * nit Signed-off-by: pyranota <pyra@duck.com> --------- Signed-off-by: pyranota <pyra@duck.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
195 lines
6.0 KiB
Rust
195 lines
6.0 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_worker::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("", "", "", db)
|
|
.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("", "", "", db)
|
|
.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(())
|
|
}
|
|
}
|