From 8987dc14309838aac4f9269f02fcf0950a18f5a8 Mon Sep 17 00:00:00 2001 From: Ben King <9087625+benfdking@users.noreply.github.com> Date: Fri, 29 Nov 2024 23:10:13 +0000 Subject: [PATCH] chore: rectify docs and centralise strum --- .github/workflows/docs.yml | 4 ++-- Cargo.lock | 1 + Cargo.toml | 3 +++ crates/cli/Cargo.toml | 1 + crates/cli/src/commands.rs | 18 ++++-------------- crates/cli/src/github_action.rs | 4 +++- crates/lib-core/Cargo.toml | 4 ++-- crates/lib-dialects/Cargo.toml | 2 +- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 51abbca2c..da26796f3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - uses: dtolnay/rust-toolchain@stable - - run: cargo r -F codegen-docs + - run: env GITHUB_ACTIONS=false cargo r -F codegen-docs - uses: stefanzweifel/git-auto-commit-action@v5 with: push_options: "--force" @@ -22,5 +22,5 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - uses: dtolnay/rust-toolchain@stable - - run: cargo r --bin sqruff -F codegen-docs + - run: env GITHUB_ACTIONS=false cargo r --bin sqruff -F codegen-docs - run: git diff --quiet || exit 1 diff --git a/Cargo.lock b/Cargo.lock index 001d1566a..861b80ebf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1720,6 +1720,7 @@ dependencies = [ "serde", "sqruff-lib", "sqruff-lsp", + "strum_macros", "tempfile", "tikv-jemallocator", ] diff --git a/Cargo.toml b/Cargo.toml index 93583a64e..ace53f4ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,3 +33,6 @@ sqruff-lib-core = { version = "0.21.6", path = "crates/lib-core" } sqruff-lib-dialects = { version = "0.21.6", path = "crates/lib-dialects"} wasm-bindgen = "0.2" wasm-pack = "0.13.0" + +strum = "0.26.3" +strum_macros = "0.26.4" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 10103f34a..58aa6e909 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -39,6 +39,7 @@ codegen-docs = ["clap-markdown", "minijinja", "serde", "python"] [dependencies] sqruff-lib.workspace = true sqruff-lsp.workspace = true +strum_macros.workspace = true clap = { version = "4", features = ["derive"] } console = "0.15.8" diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index 88a417fc6..7e561b955 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -1,7 +1,5 @@ -use std::{ - fmt::{write, Display}, - path::PathBuf, -}; +use std::path::PathBuf; +use strum_macros::Display; use clap::{Parser, Subcommand, ValueEnum}; @@ -48,7 +46,8 @@ pub(crate) struct FixArgs { pub format: Format, } -#[derive(Debug, Clone, Copy, ValueEnum)] +#[derive(Debug, Clone, Copy, ValueEnum, Display)] +#[strum(serialize_all = "kebab-case")] pub(crate) enum Format { Human, GithubAnnotationNative, @@ -63,12 +62,3 @@ impl Default for Format { } } } - -impl Display for Format { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Format::Human => f.write_str("human"), - Format::GithubAnnotationNative => f.write_str("github-annotation-native"), - } - } -} diff --git a/crates/cli/src/github_action.rs b/crates/cli/src/github_action.rs index 81101c612..1e5dfb2a2 100644 --- a/crates/cli/src/github_action.rs +++ b/crates/cli/src/github_action.rs @@ -1,5 +1,7 @@ use std::env; pub(crate) fn is_in_github_action() -> bool { - env::var("GITHUB_ACTIONS").is_ok() + env::var("GITHUB_ACTIONS") + .map(|s| s == "true") + .unwrap_or(false) } diff --git a/crates/lib-core/Cargo.toml b/crates/lib-core/Cargo.toml index 4634bfef2..83de2678a 100644 --- a/crates/lib-core/Cargo.toml +++ b/crates/lib-core/Cargo.toml @@ -19,9 +19,9 @@ stringify = ["dep:serde_yaml", "serde"] [dependencies] smol_str = "0.3.1" ahash = { version = "0.8.11", features = ["compile-time-rng", "serde"] } -strum = "0.26.3" +strum.workspace = true +strum_macros.workspace = true indexmap = "2.5.0" -strum_macros = "0.26.4" nohash-hasher = "0.2.0" itertools = "0.13.0" fancy-regex = "0.14.0" diff --git a/crates/lib-dialects/Cargo.toml b/crates/lib-dialects/Cargo.toml index a33aebf2f..b98f7b5a7 100644 --- a/crates/lib-dialects/Cargo.toml +++ b/crates/lib-dialects/Cargo.toml @@ -44,9 +44,9 @@ trino = [] [dependencies] sqruff-lib-core.workspace = true +strum.workspace = true itertools = "0.13.0" ahash = "0.8.11" -strum = "0.26.3" serde_yaml = "0.9.34+deprecated" [dev-dependencies]