Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: detect typos #1116

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashMap<String, serde_yaml::Value>>,
Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/evaluation_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/precompiled_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/policy_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
if !processed_policies.insert(policy_url) {
debug!(
policy = name.as_str(),
"skipping, wasm module alredy processed"
"skipping, wasm module already processed"

Check warning on line 93 in src/policy_downloader.rs

View check run for this annotation

Codecov / codecov/patch

src/policy_downloader.rs#L93

Added line #L93 was not covered by tests
);

continue;
Expand Down
4 changes: 2 additions & 2 deletions src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// To normalize thread names.
static ref THREAD_NAME_RE: Regex =
Regex::new(r"^(?P<thread_name>[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)]
Expand Down Expand Up @@ -102,7 +102,7 @@
.captures(thread_name)
.and_then(|cap| {
cap.name("thread_name").map(|thread_name| {
THREAD_NAME_REPLACE_SEPERATOR_RE
THREAD_NAME_REPLACE_SEPARATOR_RE

Check warning on line 105 in src/profiling.rs

View check run for this annotation

Codecov / codecov/patch

src/profiling.rs#L105

Added line #L105 was not covered by tests
.replace_all(thread_name.as_str(), "-")
.into_owned()
})
Expand Down
2 changes: 1 addition & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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())
}

Expand All @@ -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")
Expand Down
Loading