From 7b77d63be56eda80dd6d29efcf1ca5638e3e8b7e Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Tue, 4 Mar 2025 09:34:04 +0100 Subject: [PATCH] test: detect typos Use `crate-ci/typos` to detect typos Signed-off-by: Flavio Castelli --- .github/workflows/ci.yml | 9 +++++++++ .typos.toml | 12 ++++++++++++ Makefile | 4 ++++ src/api/service.rs | 2 +- src/config.rs | 2 +- src/evaluation/evaluation_environment.rs | 2 +- src/evaluation/precompiled_policy.rs | 2 +- src/policy_downloader.rs | 2 +- src/profiling.rs | 4 ++-- tests/common/mod.rs | 2 +- tests/integration_test.rs | 6 +++--- 11 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 .typos.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ed7b715..90144b26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,15 @@ jobs: - name: Run Clippy run: make lint + spelling: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Spell Check Repo + uses: crate-ci/typos@db35ee91e80fbb447f33b0e5fbddb24d2a1a884f # v1.29.10 + coverage: name: coverage runs-on: ubuntu-latest diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 00000000..d540be91 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,12 @@ +[default] +extend-ignore-re = [ + "(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", + "(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on", +] + +[files] +extend-exclude = ["*.md", "*.toml"] + +[type.csr] +check-file = false +extend-glob = ["*.csr"] diff --git a/Makefile b/Makefile index 12d56e58..f3e53fe3 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,10 @@ fmt: lint: cargo clippy -- -D warnings +.PHONY: typos +typos: + typos # run typo checker from crate-ci/typos + .PHONY: test test: fmt lint cargo test --workspace diff --git a/src/api/service.rs b/src/api/service.rs index 3cec1340..693afbdc 100644 --- a/src/api/service.rs +++ b/src/api/service.rs @@ -177,7 +177,7 @@ fn validation_response_with_constraints( // have been the decision of the // policy. We also force mutating // patches to be none. Status is also - // overriden, as it's only taken into + // overridden, as it's only taken into // account when a request is rejected. info!( policy_id = policy_id.to_string(), diff --git a/src/config.rs b/src/config.rs index 31238596..53c57f31 100644 --- a/src/config.rs +++ b/src/config.rs @@ -341,7 +341,7 @@ pub enum PolicyOrPolicyGroupSettings { #[derive(Deserialize, Debug, Clone, PartialEq)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct PolicyGroupMember { - /// Thge URL where the policy is located + /// The URL where the policy is located pub module: String, /// The settings for the policy pub settings: Option>, diff --git a/src/evaluation/evaluation_environment.rs b/src/evaluation/evaluation_environment.rs index 80b00c43..49c25818 100644 --- a/src/evaluation/evaluation_environment.rs +++ b/src/evaluation/evaluation_environment.rs @@ -830,7 +830,7 @@ mod tests { precompiled_policies.insert(policy_url, Ok(precompiled_policy.clone())); } - // add poliy group policies + // add policy group policies policies.insert( "group_policy_valid_expression_with_single_member".to_string(), PolicyOrPolicyGroup::PolicyGroup { diff --git a/src/evaluation/precompiled_policy.rs b/src/evaluation/precompiled_policy.rs index 27af65f1..c3c41ec0 100644 --- a/src/evaluation/precompiled_policy.rs +++ b/src/evaluation/precompiled_policy.rs @@ -128,7 +128,7 @@ mod tests { } #[test] - fn no_mininum_kubewarden_version_is_valid_test() { + fn no_minimum_kubewarden_version_is_valid_test() { let metadata = Metadata { minimum_kubewarden_version: None, ..Default::default() diff --git a/src/policy_downloader.rs b/src/policy_downloader.rs index 69d52a3d..b6888e61 100644 --- a/src/policy_downloader.rs +++ b/src/policy_downloader.rs @@ -90,7 +90,7 @@ impl Downloader { if !processed_policies.insert(policy_url) { debug!( policy = name.as_str(), - "skipping, wasm module alredy processed" + "skipping, wasm module already processed" ); continue; diff --git a/src/profiling.rs b/src/profiling.rs index ec1c4fa5..d9ebf31e 100644 --- a/src/profiling.rs +++ b/src/profiling.rs @@ -17,7 +17,7 @@ lazy_static! { // To normalize thread names. static ref THREAD_NAME_RE: Regex = Regex::new(r"^(?P[a-z-_ :]+?)(-?\d)*$").unwrap(); - static ref THREAD_NAME_REPLACE_SEPERATOR_RE: Regex = Regex::new(r"[_ ]").unwrap(); + static ref THREAD_NAME_REPLACE_SEPARATOR_RE: Regex = Regex::new(r"[_ ]").unwrap(); } #[derive(Debug, Error)] @@ -102,7 +102,7 @@ fn extract_thread_name(thread_name: &str) -> String { .captures(thread_name) .and_then(|cap| { cap.name("thread_name").map(|thread_name| { - THREAD_NAME_REPLACE_SEPERATOR_RE + THREAD_NAME_REPLACE_SEPARATOR_RE .replace_all(thread_name.as_str(), "-") .into_owned() }) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index c04ae859..27ecf9b4 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -130,7 +130,7 @@ pub(crate) fn default_test_config() -> Config { } } -/// Returns a random adress with an available port to use with policy server. Therefore, we can +/// Returns a random address with an available port to use with policy server. Therefore, we can /// have multiple policy server running at the same time in async tests fn get_available_address_with_port() -> SocketAddr { TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)) diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 2abf20ca..533fb4b1 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -918,7 +918,7 @@ async fn test_otel() { let app = app(config).await; - // one succesful request + // one successful request let request = Request::builder() .method(http::Method::POST) .header(header::CONTENT_TYPE, "application/json") @@ -1161,7 +1161,7 @@ async fn send_validate_request( .body(include_str!("data/pod_without_privileged_containers.json")) .send() .await - .expect("successfull request") + .expect("successful request") .status()) } @@ -1183,7 +1183,7 @@ fn build_request_client( if let (Some(client_cert), Some(client_key)) = (client_cert, client_key) { let identity = reqwest::Identity::from_pem(format!("{}\n{}", client_cert, client_key).as_bytes()) - .expect("successfull pem parsing"); + .expect("successful pem parsing"); builder = builder.identity(identity) } builder.build().expect("failed to build client")