diff --git a/.github/workflows/backend-test.yml b/.github/workflows/backend-test.yml index 5fa4a289f2..366e6bd27d 100644 --- a/.github/workflows/backend-test.yml +++ b/.github/workflows/backend-test.yml @@ -67,13 +67,21 @@ jobs: - name: Substitute EE code (EE logic is behind feature flag) run: | ./substitute_ee_code.sh --copy --dir ./windmill-ee-private + - name: Cache DuckDB FFI module build + uses: actions/cache@v3 + with: + path: ./backend/windmill-duckdb-ffi-internal/target + key: ${{ runner.os }}-duckdb-ffi-${{ hashFiles('./backend/windmill-duckdb-ffi-internal/src/**/*.rs', './backend/windmill-duckdb-ffi-internal/Cargo.toml', './backend/windmill-duckdb-ffi-internal/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-duckdb-ffi- - name: cargo test timeout-minutes: 16 run: deno --version && bun -v && go version && python3 --version && + cd windmill-duckdb-ffi-internal && ./build_dev.sh && cd .. && SQLX_OFFLINE=true DATABASE_URL=postgres://postgres:changeme@localhost:5432/windmill DISABLE_EMBEDDING=true RUST_LOG=info RUST_LOG_STYLE=never DENO_PATH=$(which deno) BUN_PATH=$(which bun) GO_PATH=$(which go) UV_PATH=$(which uv) cargo test --features - enterprise,deno_core,license,python,rust,scoped_cache,private --all -- + enterprise,deno_core,license,python,duckdb,rust,scoped_cache,private --all -- --nocapture diff --git a/backend/run_until_fail.sh b/backend/run_until_fail.sh index d8c461504b..935bacc88c 100755 --- a/backend/run_until_fail.sh +++ b/backend/run_until_fail.sh @@ -1,6 +1,7 @@ #!/bin/bash # Run the command repeatedly until it fails (exits with non-zero code) +cd windmill-duckdb-ffi-internal && ./build_dev.sh && cd .. while true; do DISABLE_EMBEDDING=true \ RUST_LOG=info \ @@ -9,7 +10,7 @@ while true; do GO_PATH=$(which go) \ UV_PATH=$(which uv) \ CARGO_PATH=$(which cargo) \ - cargo test --features enterprise,deno_core,license,python,rust,scoped_cache \ + cargo test --features enterprise,deno_core,license,python,duckdb,rust,scoped_cache \ -- --nocapture --test-threads=8 | tee /tmp/test.log # Capture the exit code of the cargo test command (not tee) diff --git a/backend/tests/worker.rs b/backend/tests/worker.rs index 57d7833c9d..0a92dfc74d 100644 --- a/backend/tests/worker.rs +++ b/backend/tests/worker.rs @@ -2944,3 +2944,33 @@ async fn test_workflow_as_code(db: Pool) -> anyhow::Result<()> { .await; Ok(()) } + +#[cfg(feature = "duckdb")] +#[sqlx::test(fixtures("base"))] +async fn test_duckdb_ffi(db: Pool) -> anyhow::Result<()> { + initialize_tracing().await; + + let server = ApiServer::start(db.clone()).await?; + + let content = "-- result_collection=last_statement_first_row_scalar\nSELECT 'Hello world!';"; + + let flow: FlowValue = serde_json::from_value(serde_json::json!({ + "modules": [{ + "value": { + "type": "rawscript", + "language": "duckdb", + "content": content, + }, + }], + })) + .unwrap(); + + let result = + RunJob::from(JobPayload::RawFlow { value: flow.clone(), path: None, restarted_from: None }) + .run_until_complete(&db, false, server.addr.port()) + .await + .json_result() + .unwrap(); + assert_eq!(result, serde_json::json!("Hello world!")); + Ok(()) +}