From cfa9cde5c607cd5d5bb0b8e4361a1e9c32d8e056 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 18:29:49 -0700 Subject: [PATCH 1/8] updates Signed-off-by: Jess Frazelle --- src/wasm-lib/kcl/Cargo.toml | 3 +++ src/wasm-lib/kcl/src/lib.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/wasm-lib/kcl/Cargo.toml b/src/wasm-lib/kcl/Cargo.toml index d11259ad17..64615ac57d 100644 --- a/src/wasm-lib/kcl/Cargo.toml +++ b/src/wasm-lib/kcl/Cargo.toml @@ -63,6 +63,9 @@ tower-lsp = { version = "0.20.0", features = ["proposed"] } [features] default = ["cli", "engine"] cli = ["dep:clap"] +# For the lsp server, when run with stdout for rpc we want to disable println. +# This is used for editor extensions that use the lsp server. +disable-println = [] engine = [] pyo3 = ["dep:pyo3"] diff --git a/src/wasm-lib/kcl/src/lib.rs b/src/wasm-lib/kcl/src/lib.rs index fd61ecdcfd..c5a08b8fbf 100644 --- a/src/wasm-lib/kcl/src/lib.rs +++ b/src/wasm-lib/kcl/src/lib.rs @@ -4,6 +4,13 @@ //! the standard library implementation, a LSP implementation, generator for the docs, and more. #![recursion_limit = "1024"] +macro_rules! println { + ($($rest:tt)*) => { + #[cfg(not(feature = "disable-println"))] + std::println!($($rest)*) + } +} + pub mod ast; pub mod coredump; pub mod docs; From ecd9fe72a1d3f9635c3b6a32a73033b75e45b548 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 18:37:31 -0700 Subject: [PATCH 2/8] updates Signed-off-by: Jess Frazelle --- .github/workflows/cargo-clippy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml index 14daf69f77..ec35a2159a 100644 --- a/.github/workflows/cargo-clippy.yml +++ b/.github/workflows/cargo-clippy.yml @@ -53,7 +53,7 @@ jobs: - name: Run clippy run: | cd "${{ matrix.dir }}" - cargo clippy --all --tests --all-features --benches -- -D warnings + cargo clippy --all --tests --benches -- -D warnings # If this fails, run "cargo check" to update Cargo.lock, # then add Cargo.lock to the PR. - name: Check Cargo.lock doesn't need updating From 3270823e19084c869762c1c7632a12b7f946e171 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 18:37:56 -0700 Subject: [PATCH 3/8] updates Signed-off-by: Jess Frazelle --- .github/workflows/cargo-clippy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml index ec35a2159a..4a31796b8e 100644 --- a/.github/workflows/cargo-clippy.yml +++ b/.github/workflows/cargo-clippy.yml @@ -54,6 +54,7 @@ jobs: run: | cd "${{ matrix.dir }}" cargo clippy --all --tests --benches -- -D warnings + cargo clippy --all --tests --features pyo3 --benches -- -D warnings # If this fails, run "cargo check" to update Cargo.lock, # then add Cargo.lock to the PR. - name: Check Cargo.lock doesn't need updating From 4f7c12451d1dbfbf0c2c5016fb4e4d06c56f22dc Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 18:52:20 -0700 Subject: [PATCH 4/8] updates Signed-off-by: Jess Frazelle --- .github/workflows/cargo-build.yml | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/cargo-build.yml diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml new file mode 100644 index 0000000000..f6ed90ae3e --- /dev/null +++ b/.github/workflows/cargo-build.yml @@ -0,0 +1,40 @@ +on: + push: + branches: + - main + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + - '**/rust-toolchain.toml' + - '**.rs' + - .github/workflows/cargo-build.yml + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +name: cargo build +jobs: + cargobuild: + name: cargo build + runs-on: ubuntu-latest + strategy: + matrix: + dir: ['src/wasm-lib'] + steps: + - uses: actions/checkout@v4 + - name: Install latest rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Rust Cache + uses: Swatinem/rust-cache@v2.6.1 + + - name: Run build + run: | + cd "${{ matrix.dir }}" + # We specifically want to test the disable-println feature + # Since it is not enabled by default, we need to specify it + # This is used in kcl-lsp + cargo build --all --features disable-println From 580822cba20ecb00b00e0e6a0e22a3571eebd539 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 18:57:20 -0700 Subject: [PATCH 5/8] cleanup weird printlns Signed-off-by: Jess Frazelle --- src/wasm-lib/kcl/src/engine/conn.rs | 4 ---- src/wasm-lib/kcl/src/parser/parser_impl.rs | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/wasm-lib/kcl/src/engine/conn.rs b/src/wasm-lib/kcl/src/engine/conn.rs index 2367aa0bc5..648baad554 100644 --- a/src/wasm-lib/kcl/src/engine/conn.rs +++ b/src/wasm-lib/kcl/src/engine/conn.rs @@ -180,11 +180,7 @@ impl EngineConnection { loop { match tcp_read.read().await { Ok(ws_resp) => { - for e in ws_resp.errors.iter().flatten() { - println!("got error message: {} {}", e.error_code, e.message); - } // If we got a batch response, add all the inner responses. - println!("got response: {:?}", ws_resp); if let Some(kittycad::types::OkWebSocketResponseData::ModelingBatch { responses }) = &ws_resp.resp { diff --git a/src/wasm-lib/kcl/src/parser/parser_impl.rs b/src/wasm-lib/kcl/src/parser/parser_impl.rs index 3d48beb051..60be926c62 100644 --- a/src/wasm-lib/kcl/src/parser/parser_impl.rs +++ b/src/wasm-lib/kcl/src/parser/parser_impl.rs @@ -2907,7 +2907,10 @@ let myBox = box([0,0], -3, -16, -10) let tokens = crate::token::lexer(some_program_string).unwrap(); let parser = crate::parser::Parser::new(tokens); let err = parser.ast().unwrap_err(); - println!("{err}") + assert_eq!( + err.to_string(), + r#"syntax: KclErrorDetails { source_ranges: [SourceRange([30, 36])], message: "All expressions in a pipeline must use the % (substitution operator)" }"# + ); } } From f39c287bb0bba54cf878add821774c91bd006bdd Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 19:13:15 -0700 Subject: [PATCH 6/8] updates Signed-off-by: Jess Frazelle --- .github/workflows/cargo-build.yml | 2 +- .github/workflows/cargo-clippy.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml index f6ed90ae3e..88152c0f5e 100644 --- a/.github/workflows/cargo-build.yml +++ b/.github/workflows/cargo-build.yml @@ -37,4 +37,4 @@ jobs: # We specifically want to test the disable-println feature # Since it is not enabled by default, we need to specify it # This is used in kcl-lsp - cargo build --all --features disable-println + cargo build --all --features disable-println --features pyo3 diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml index 4a31796b8e..ec35a2159a 100644 --- a/.github/workflows/cargo-clippy.yml +++ b/.github/workflows/cargo-clippy.yml @@ -54,7 +54,6 @@ jobs: run: | cd "${{ matrix.dir }}" cargo clippy --all --tests --benches -- -D warnings - cargo clippy --all --tests --features pyo3 --benches -- -D warnings # If this fails, run "cargo check" to update Cargo.lock, # then add Cargo.lock to the PR. - name: Check Cargo.lock doesn't need updating From d3143832e79855a2f1c04db9f68ed348becf4326 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 19:18:44 -0700 Subject: [PATCH 7/8] check Signed-off-by: Jess Frazelle --- .github/workflows/cargo-build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-build.yml index 88152c0f5e..4548a18557 100644 --- a/.github/workflows/cargo-build.yml +++ b/.github/workflows/cargo-build.yml @@ -7,15 +7,15 @@ on: - '**/Cargo.lock' - '**/rust-toolchain.toml' - '**.rs' - - .github/workflows/cargo-build.yml + - .github/workflows/cargo-check.yml pull_request: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true -name: cargo build +name: cargo check jobs: - cargobuild: - name: cargo build + cargocheck: + name: cargo check runs-on: ubuntu-latest strategy: matrix: @@ -31,10 +31,10 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v2.6.1 - - name: Run build + - name: Run check run: | cd "${{ matrix.dir }}" # We specifically want to test the disable-println feature # Since it is not enabled by default, we need to specify it # This is used in kcl-lsp - cargo build --all --features disable-println --features pyo3 + cargo check --all --features disable-println --features pyo3 From f2c5ec09b1d9de0fb05f787a157261a4495d3213 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 19 Jun 2024 19:19:12 -0700 Subject: [PATCH 8/8] rename file Signed-off-by: Jess Frazelle --- .github/workflows/{cargo-build.yml => cargo-check.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{cargo-build.yml => cargo-check.yml} (100%) diff --git a/.github/workflows/cargo-build.yml b/.github/workflows/cargo-check.yml similarity index 100% rename from .github/workflows/cargo-build.yml rename to .github/workflows/cargo-check.yml