Skip to content

Commit 7b77d63

Browse files
committed
test: detect typos
Use `crate-ci/typos` to detect typos Signed-off-by: Flavio Castelli <fcastelli@suse.com>
1 parent 066e7bd commit 7b77d63

11 files changed

+36
-11
lines changed

.github/workflows/ci.yml

+9
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ jobs:
9191
- name: Run Clippy
9292
run: make lint
9393

94+
spelling:
95+
name: Spell Check with Typos
96+
runs-on: ubuntu-latest
97+
steps:
98+
- name: Checkout Actions Repository
99+
uses: actions/checkout@v4
100+
- name: Spell Check Repo
101+
uses: crate-ci/typos@db35ee91e80fbb447f33b0e5fbddb24d2a1a884f # v1.29.10
102+
94103
coverage:
95104
name: coverage
96105
runs-on: ubuntu-latest

.typos.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
]
6+
7+
[files]
8+
extend-exclude = ["*.md", "*.toml"]
9+
10+
[type.csr]
11+
check-file = false
12+
extend-glob = ["*.csr"]

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ fmt:
2121
lint:
2222
cargo clippy -- -D warnings
2323

24+
.PHONY: typos
25+
typos:
26+
typos # run typo checker from crate-ci/typos
27+
2428
.PHONY: test
2529
test: fmt lint
2630
cargo test --workspace

src/api/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn validation_response_with_constraints(
177177
// have been the decision of the
178178
// policy. We also force mutating
179179
// patches to be none. Status is also
180-
// overriden, as it's only taken into
180+
// overridden, as it's only taken into
181181
// account when a request is rejected.
182182
info!(
183183
policy_id = policy_id.to_string(),

src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub enum PolicyOrPolicyGroupSettings {
341341
#[derive(Deserialize, Debug, Clone, PartialEq)]
342342
#[serde(deny_unknown_fields, rename_all = "camelCase")]
343343
pub struct PolicyGroupMember {
344-
/// Thge URL where the policy is located
344+
/// The URL where the policy is located
345345
pub module: String,
346346
/// The settings for the policy
347347
pub settings: Option<HashMap<String, serde_yaml::Value>>,

src/evaluation/evaluation_environment.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ mod tests {
830830
precompiled_policies.insert(policy_url, Ok(precompiled_policy.clone()));
831831
}
832832

833-
// add poliy group policies
833+
// add policy group policies
834834
policies.insert(
835835
"group_policy_valid_expression_with_single_member".to_string(),
836836
PolicyOrPolicyGroup::PolicyGroup {

src/evaluation/precompiled_policy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ mod tests {
128128
}
129129

130130
#[test]
131-
fn no_mininum_kubewarden_version_is_valid_test() {
131+
fn no_minimum_kubewarden_version_is_valid_test() {
132132
let metadata = Metadata {
133133
minimum_kubewarden_version: None,
134134
..Default::default()

src/policy_downloader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Downloader {
9090
if !processed_policies.insert(policy_url) {
9191
debug!(
9292
policy = name.as_str(),
93-
"skipping, wasm module alredy processed"
93+
"skipping, wasm module already processed"
9494
);
9595

9696
continue;

src/profiling.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ lazy_static! {
1717
// To normalize thread names.
1818
static ref THREAD_NAME_RE: Regex =
1919
Regex::new(r"^(?P<thread_name>[a-z-_ :]+?)(-?\d)*$").unwrap();
20-
static ref THREAD_NAME_REPLACE_SEPERATOR_RE: Regex = Regex::new(r"[_ ]").unwrap();
20+
static ref THREAD_NAME_REPLACE_SEPARATOR_RE: Regex = Regex::new(r"[_ ]").unwrap();
2121
}
2222

2323
#[derive(Debug, Error)]
@@ -102,7 +102,7 @@ fn extract_thread_name(thread_name: &str) -> String {
102102
.captures(thread_name)
103103
.and_then(|cap| {
104104
cap.name("thread_name").map(|thread_name| {
105-
THREAD_NAME_REPLACE_SEPERATOR_RE
105+
THREAD_NAME_REPLACE_SEPARATOR_RE
106106
.replace_all(thread_name.as_str(), "-")
107107
.into_owned()
108108
})

tests/common/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub(crate) fn default_test_config() -> Config {
130130
}
131131
}
132132

133-
/// Returns a random adress with an available port to use with policy server. Therefore, we can
133+
/// Returns a random address with an available port to use with policy server. Therefore, we can
134134
/// have multiple policy server running at the same time in async tests
135135
fn get_available_address_with_port() -> SocketAddr {
136136
TcpListener::bind(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0))

tests/integration_test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ async fn test_otel() {
918918

919919
let app = app(config).await;
920920

921-
// one succesful request
921+
// one successful request
922922
let request = Request::builder()
923923
.method(http::Method::POST)
924924
.header(header::CONTENT_TYPE, "application/json")
@@ -1161,7 +1161,7 @@ async fn send_validate_request(
11611161
.body(include_str!("data/pod_without_privileged_containers.json"))
11621162
.send()
11631163
.await
1164-
.expect("successfull request")
1164+
.expect("successful request")
11651165
.status())
11661166
}
11671167

@@ -1183,7 +1183,7 @@ fn build_request_client(
11831183
if let (Some(client_cert), Some(client_key)) = (client_cert, client_key) {
11841184
let identity =
11851185
reqwest::Identity::from_pem(format!("{}\n{}", client_cert, client_key).as_bytes())
1186-
.expect("successfull pem parsing");
1186+
.expect("successful pem parsing");
11871187
builder = builder.identity(identity)
11881188
}
11891189
builder.build().expect("failed to build client")

0 commit comments

Comments
 (0)