diff --git a/.github/workflows/cargo-check.yml b/.github/workflows/cargo-check.yml new file mode 100644 index 000000000..4548a1855 --- /dev/null +++ b/.github/workflows/cargo-check.yml @@ -0,0 +1,40 @@ +on: + push: + branches: + - main + paths: + - '**/Cargo.toml' + - '**/Cargo.lock' + - '**/rust-toolchain.toml' + - '**.rs' + - .github/workflows/cargo-check.yml + pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +name: cargo check +jobs: + cargocheck: + name: cargo check + 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 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 check --all --features disable-println --features pyo3 diff --git a/.github/workflows/cargo-clippy.yml b/.github/workflows/cargo-clippy.yml index 14daf69f7..ec35a2159 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 diff --git a/src/wasm-lib/kcl/Cargo.toml b/src/wasm-lib/kcl/Cargo.toml index d11259ad1..64615ac57 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/engine/conn.rs b/src/wasm-lib/kcl/src/engine/conn.rs index 2367aa0bc..648baad55 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/lib.rs b/src/wasm-lib/kcl/src/lib.rs index fd61ecdcf..c5a08b8fb 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; diff --git a/src/wasm-lib/kcl/src/parser/parser_impl.rs b/src/wasm-lib/kcl/src/parser/parser_impl.rs index 3d48beb05..60be926c6 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)" }"# + ); } }