diff --git a/.github/hooks/pre-commit b/.github/hooks/pre-commit new file mode 100755 index 0000000..fbb860a --- /dev/null +++ b/.github/hooks/pre-commit @@ -0,0 +1,16 @@ +#!/bin/sh +# NQL pre-commit hook: run the same checks as CI before allowing a commit. +# To install: cp .github/hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit + +set -e + +echo "[pre-commit] Running cargo fmt --all -- --check" +cargo fmt --all -- --check + +echo "[pre-commit] Running cargo clippy --all-targets -- -D warnings" +cargo clippy --all-targets -- -D warnings + +echo "[pre-commit] Running cargo test --all" +cargo test --all + +echo "[pre-commit] OK" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5354a69 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +repos: + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt + entry: cargo fmt --all -- --check + language: system + types: [rust] + pass_filenames: false + stages: [pre-commit] + + - id: cargo-clippy + name: cargo clippy + entry: cargo clippy --all-targets -- -D warnings + language: system + types: [rust] + pass_filenames: false + stages: [pre-commit] + + - id: cargo-test + name: cargo test + entry: cargo test --all + language: system + types: [rust] + pass_filenames: false + stages: [pre-commit] diff --git a/Cargo.toml b/Cargo.toml index 412a148..cf2b320 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nql" -version = "0.1.6" +version = "0.1.7" edition = "2021" authors = ["NPC Worldwide "] description = "NQL — SQL compiler with AI function calls targeting multiple databases" diff --git a/src/main.rs b/src/main.rs index 91e2162..1a71358 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use nql::compiler::Target; use nql::runner::Runner; #[derive(Parser)] -#[command(name = "nql", about = "NQL — SQL compiler with AI function calls")] +#[command(name = "nql", about = "NQL — SQL compiler with AI function calls", version = env!("CARGO_PKG_VERSION"))] struct Cli { #[command(subcommand)] command: Commands, diff --git a/src/runner.rs b/src/runner.rs index 6572f56..d1a1053 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -198,7 +198,10 @@ impl Runner { let mut bq_args = query_args.clone(); bq_args.push(format!("--job_id={}", job_id)); - eprintln!("[nql] Executing model on BigQuery: {} (job_id={})", name, job_id); + eprintln!( + "[nql] Executing model on BigQuery: {} (job_id={})", + name, job_id + ); let mut child = std::process::Command::new("bq") .args(&bq_args) .stdin(std::process::Stdio::piped())