diff --git a/.githooks/pre-push b/.githooks/pre-push index 3900fc2..22e0de4 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,34 +1,40 @@ #!/bin/sh -set -e pipefail +set -e + +# Dependency sorting +if ! cargo sort --workspace --check; then + echo "❌ Dependencies should be sorted (run 'cargo sort --workspace')" + exit 1 +fi # Dependency audit -cargo deny check || { +if ! cargo deny check; then echo "❌ Critical: Vulnerable dependencies detected (run 'cargo deny check')" - exit 1 -} + exit 2 +fi # Formatting check -cargo fmt --all -- --check || { +if ! cargo fmt --all -- --check; then echo "❌ Formatting issues (run 'cargo fmt --all')" - exit 2 -} + exit 3 +fi # Typo check -typos || { +if ! typos; then echo "❌ Spelling mistakes found (run 'typos --write-changes')" - exit 3 -} + exit 4 +fi # Linting -cargo clippy --all-targets --all-features -- -D warnings || { +if ! cargo clippy --all-targets --all-features -- -D warnings; then echo "❌ Clippy violations (check warnings above)" - exit 4 -} + exit 5 +fi # Tests -cargo test --workspace --verbose || { +if ! cargo test --workspace --verbose; then echo "❌ Test failures detected" - exit 5 -} + exit 6 +fi echo "✅ All checks passed!" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 82f80fa..44cf999 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,6 +13,7 @@ git config commit.gpgsign true * [Rust](https://www.rust-lang.org/tools/install) * [cargo deny](https://github.com/EmbarkStudios/cargo-deny) * [typos](https://github.com/crate-ci/typos?tab=readme-ov-file#install) +* [cargo sort](https://github.com/DevinR528/cargo-sort) ## Code quality assurance diff --git a/Cargo.toml b/Cargo.toml index 24d4f9c..8bb9a53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,9 @@ + +# TODO(template) update for the crate name +[workspace] +members = ["examples", "mycrate"] +resolver = "2" +default-members = ["mycrate"] [workspace.package] version = "0.1.0" edition = "2021" @@ -5,15 +11,6 @@ edition = "2021" repository = "https://github.com/NethermindEth/rust-template" license = "Apache-2.0" # TODO(template) update license if needed -# TODO(template) update for the crate name -[workspace] -members = [ - "examples", - "mycrate", -] -resolver = "2" -default-members = ["mycrate"] - [workspace.dependencies] [workspace.lints.rust] @@ -33,4 +30,4 @@ cast_precision_loss = "deny" cast_sign_loss = "deny" needless_return = "deny" panicking_overflow_checks = "deny" -unwrap_used = "deny" \ No newline at end of file +unwrap_used = "deny" diff --git a/README.md b/README.md index 9d65b90..7d89d64 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ TODO(template) describe the project ## TODO(template) - rust template usage (remove this section after setup) This is a rust template from ZKE team :rocket: (a focus on cryptographic libs in sync Rust). -To use it - find `TODO(template)` over the repository and set appropriate values. + +:bike: To use it - find `TODO(template)` over the repository and set appropriate values. - [ ] Settings -> Collaborators and teams - add your team group as admins for the repo (e.g. [zk-engineering](https://github.com/orgs/NethermindEth/teams/zk-engineering)) - [ ] Settings -> General -> Pull Requests - allow only `Allow squash merging`, also tick `Automatically delete head branches` @@ -13,8 +14,9 @@ To use it - find `TODO(template)` over the repository and set appropriate values - [ ] Update the description of the repo at the repo's page, add tag topics - [ ] Introduce necessary sections at the repo's page (releases, deployments etc) - [ ] Add a website url (if applicable) or a docs page (see [docs](./.github/workflows/docs.yml) flow for public repos) -- [ ] add [all contributors](https://allcontributors.org/docs/en/cli/installation) -- [ ] import protection rulesets (see below) in the repo settings (Settings -> Rules -> Rulesets -> Import a ruleset) +- [ ] Add [all contributors](https://allcontributors.org/docs/en/cli/installation) +- [ ] Import protection rulesets (see below) in the repo settings (Settings -> Rules -> Rulesets -> Import a ruleset) +- [ ] For binary crates with specific requirements to Rust features consider also [pinning](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) the rust toolchain version Main branch protection @@ -104,7 +106,8 @@ See [examples](./examples/). ## License -TODO(template) - update [license](https://www.notion.so/nethermind/Open-Source-Software-Usage-and-Licensing-Policy-1c3360fc38d080fd9e61c29b35d1d5af) if needed +TODO(template) - update [license](https://www.notion.so/nethermind/Open-Source-Software-Usage-and-Licensing-Policy-1c3360fc38d080fd9e61c29b35d1d5af) if needed. +For commercial licenses it is required to get an approve from Legal. Apache 2.0 diff --git a/mycrate/Cargo.toml b/mycrate/Cargo.toml index 9935edf..e01630a 100644 --- a/mycrate/Cargo.toml +++ b/mycrate/Cargo.toml @@ -12,10 +12,10 @@ license.workspace = true # Use `default-features = false` # and explicitly list features to prevent code bloat and # code break after upgrades -thiserror = {version = "1.0", default-features = false } +thiserror = { version = "1.0", default-features = false } # TODO(template) # don't forget to put this at every crate # to inherit workspace's lints [lints] -workspace = true \ No newline at end of file +workspace = true