Skip to content

Commit f97b494

Browse files
authored
pre-push hook checks for sorted deps (#1)
1 parent 939981d commit f97b494

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

.githooks/pre-push

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
11
#!/bin/sh
2-
set -e pipefail
2+
set -e
3+
4+
# Dependency sorting
5+
if ! cargo sort --workspace --check; then
6+
echo "❌ Dependencies should be sorted (run 'cargo sort --workspace')"
7+
exit 1
8+
fi
39

410
# Dependency audit
5-
cargo deny check || {
11+
if ! cargo deny check; then
612
echo "❌ Critical: Vulnerable dependencies detected (run 'cargo deny check')"
7-
exit 1
8-
}
13+
exit 2
14+
fi
915

1016
# Formatting check
11-
cargo fmt --all -- --check || {
17+
if ! cargo fmt --all -- --check; then
1218
echo "❌ Formatting issues (run 'cargo fmt --all')"
13-
exit 2
14-
}
19+
exit 3
20+
fi
1521

1622
# Typo check
17-
typos || {
23+
if ! typos; then
1824
echo "❌ Spelling mistakes found (run 'typos --write-changes')"
19-
exit 3
20-
}
25+
exit 4
26+
fi
2127

2228
# Linting
23-
cargo clippy --all-targets --all-features -- -D warnings || {
29+
if ! cargo clippy --all-targets --all-features -- -D warnings; then
2430
echo "❌ Clippy violations (check warnings above)"
25-
exit 4
26-
}
31+
exit 5
32+
fi
2733

2834
# Tests
29-
cargo test --workspace --verbose || {
35+
if ! cargo test --workspace --verbose; then
3036
echo "❌ Test failures detected"
31-
exit 5
32-
}
37+
exit 6
38+
fi
3339

3440
echo "✅ All checks passed!"

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ git config commit.gpgsign true
1313
* [Rust](https://www.rust-lang.org/tools/install)
1414
* [cargo deny](https://github.com/EmbarkStudios/cargo-deny)
1515
* [typos](https://github.com/crate-ci/typos?tab=readme-ov-file#install)
16+
* [cargo sort](https://github.com/DevinR528/cargo-sort)
1617

1718
## Code quality assurance
1819

Cargo.toml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1+
2+
# TODO(template) update for the crate name
3+
[workspace]
4+
members = ["examples", "mycrate"]
5+
resolver = "2"
6+
default-members = ["mycrate"]
17
[workspace.package]
28
version = "0.1.0"
39
edition = "2021"
410
# TODO(template) update for your repository
511
repository = "https://github.com/NethermindEth/rust-template"
612
license = "Apache-2.0" # TODO(template) update license if needed
713

8-
# TODO(template) update for the crate name
9-
[workspace]
10-
members = [
11-
"examples",
12-
"mycrate",
13-
]
14-
resolver = "2"
15-
default-members = ["mycrate"]
16-
1714
[workspace.dependencies]
1815

1916
[workspace.lints.rust]
@@ -33,4 +30,4 @@ cast_precision_loss = "deny"
3330
cast_sign_loss = "deny"
3431
needless_return = "deny"
3532
panicking_overflow_checks = "deny"
36-
unwrap_used = "deny"
33+
unwrap_used = "deny"

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ TODO(template) describe the project
55
## TODO(template) - rust template usage (remove this section after setup)
66

77
This is a rust template from ZKE team :rocket: (a focus on cryptographic libs in sync Rust).
8-
To use it - find `TODO(template)` over the repository and set appropriate values.
8+
9+
:bike: To use it - find `TODO(template)` over the repository and set appropriate values.
910

1011
- [ ] 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))
1112
- [ ] Settings -> General -> Pull Requests - allow only `Allow squash merging`, also tick `Automatically delete head branches`
1213
- [ ] Settings -> Pages -> Build and deployment -> Source Github Actions
1314
- [ ] Update the description of the repo at the repo's page, add tag topics
1415
- [ ] Introduce necessary sections at the repo's page (releases, deployments etc)
1516
- [ ] Add a website url (if applicable) or a docs page (see [docs](./.github/workflows/docs.yml) flow for public repos)
16-
- [ ] add [all contributors](https://allcontributors.org/docs/en/cli/installation)
17-
- [ ] import protection rulesets (see below) in the repo settings (Settings -> Rules -> Rulesets -> Import a ruleset)
17+
- [ ] Add [all contributors](https://allcontributors.org/docs/en/cli/installation)
18+
- [ ] Import protection rulesets (see below) in the repo settings (Settings -> Rules -> Rulesets -> Import a ruleset)
19+
- [ ] 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
1820

1921
Main branch protection
2022

@@ -104,7 +106,8 @@ See [examples](./examples/).
104106

105107
## License
106108

107-
TODO(template) - update [license](https://www.notion.so/nethermind/Open-Source-Software-Usage-and-Licensing-Policy-1c3360fc38d080fd9e61c29b35d1d5af) if needed
109+
TODO(template) - update [license](https://www.notion.so/nethermind/Open-Source-Software-Usage-and-Licensing-Policy-1c3360fc38d080fd9e61c29b35d1d5af) if needed.
110+
For commercial licenses it is required to get an approve from Legal.
108111

109112
Apache 2.0
110113

mycrate/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ license.workspace = true
1212
# Use `default-features = false`
1313
# and explicitly list features to prevent code bloat and
1414
# code break after upgrades
15-
thiserror = {version = "1.0", default-features = false }
15+
thiserror = { version = "1.0", default-features = false }
1616

1717
# TODO(template)
1818
# don't forget to put this at every crate
1919
# to inherit workspace's lints
2020
[lints]
21-
workspace = true
21+
workspace = true

0 commit comments

Comments
 (0)