File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e pipefail
3+
4+ # Dependency audit
5+ cargo deny check || {
6+ echo " ❌ Critical: Vulnerable dependencies detected (run 'cargo deny check')"
7+ exit 1
8+ }
9+
10+ # Formatting check
11+ cargo fmt --all -- --check || {
12+ echo " ❌ Formatting issues (run 'cargo fmt --all')"
13+ exit 2
14+ }
15+
16+ # Typo check
17+ typos || {
18+ echo " ❌ Spelling mistakes found (run 'typos --write-changes')"
19+ exit 3
20+ }
21+
22+ # Linting
23+ cargo clippy --all-targets --all-features -- -D warnings || {
24+ echo " ❌ Clippy violations (check warnings above)"
25+ exit 4
26+ }
27+
28+ # Tests
29+ cargo test --workspace --verbose || {
30+ echo " ❌ Test failures detected"
31+ exit 5
32+ }
33+
34+ echo " ✅ All checks passed!"
Original file line number Diff line number Diff line change 1+ name : Build and test code
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+
9+ env :
10+ CARGO_TERM_COLOR : always
11+ CARGO_INCREMENTAL : 0
12+
13+ jobs :
14+ build :
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+ - name : Build
19+ run : cargo test --workspace --verbose --no-run
20+ - name : Run tests
21+ run : cargo test --workspace --verbose
Original file line number Diff line number Diff line change 1+ name : Dependency security audit
2+
3+ on :
4+ push :
5+ paths :
6+ - ' **/Cargo.toml'
7+ - ' **/Cargo.lock'
8+
9+ env :
10+ CARGO_TERM_COLOR : always
11+ CARGO_INCREMENTAL : 0
12+
13+ jobs :
14+ security_audit :
15+ timeout-minutes : 10
16+ runs-on : ubuntu-latest
17+ permissions :
18+ contents : read
19+ checks : write
20+ steps :
21+ - name : Check out
22+ uses : actions/checkout@v4
23+
24+ - name : Cache audit-check build
25+ id : cache-audit-check
26+ uses : actions/cache@v4
27+ continue-on-error : false
28+ with :
29+ path : |
30+ ~/.cargo/bin/
31+ ~/.cargo/registry/index/
32+ ~/.cargo/registry/cache/
33+ ~/.cargo/git/db/
34+ target/
35+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
36+ restore-keys : ${{ runner.os }}-cargo-
37+
38+ - name : Run audit-check action
39+ run : |
40+ which cargo-deny || cargo install cargo-deny
41+ cargo deny check
Original file line number Diff line number Diff line change 1+ name : Docs
2+
3+ # TODO(template)
4+ # GH pages seems to work properly for public repos
5+ on :
6+ workflow_dispatch :
7+
8+ jobs :
9+ # TODO(template) remove docs publishing, when the crate is published to crates.io
10+ docs :
11+ permissions :
12+ contents : write
13+ name : Documentation
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Checkout source code
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 1
20+ persist-credentials : false
21+
22+ - name : Setup pages
23+ id : pages
24+ uses : actions/configure-pages@v5
25+
26+ - name : Clean docs folder
27+ run : cargo clean --doc
28+
29+ # Documentation with Latex support
30+ # TODO(template) if Latex is not needed
31+ # just remove katex-header.html at the root and RUSTDOCFLAGS here
32+ # TODO(template) update the crate name
33+ - name : Build documentation
34+ run : RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p mycrate
35+
36+ - name : Remove lock file
37+ run : rm target/doc/.lock
38+
39+ - name : Upload artifact
40+ uses : actions/upload-pages-artifact@v3
41+ with :
42+ path : target/doc
43+
44+ publish-docs :
45+ permissions :
46+ pages : write
47+ id-token : write
48+ environment :
49+ name : github-pages
50+ url : ${{ steps.deployment.outputs.page_url }}
51+ runs-on : ubuntu-latest
52+ needs : docs
53+ steps :
54+ - name : Deploy to GitHub Pages
55+ id : deployment
56+ uses : actions/deploy-pages@v4
Original file line number Diff line number Diff line change 1+ name : Linter check
2+
3+ on : push
4+
5+ env :
6+ CARGO_TERM_COLOR : always
7+ CARGO_INCREMENTAL : 0
8+ # Make sure CI fails on all warnings, including Clippy lints
9+ RUSTFLAGS : " -Dwarnings"
10+
11+ jobs :
12+ linter_check :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+ - name : Run Fmt
17+ run : cargo fmt --all -- --check
18+
19+ - name : Run Clippy
20+ run : cargo clippy --all-targets --all-features
21+
22+ - name : Check typos
23+ uses : crate-ci/typos@master
24+
Original file line number Diff line number Diff line change 1+ name : UB (undefined behavior) detection
2+
3+ on : push
4+
5+ env :
6+ CARGO_TERM_COLOR : always
7+ CARGO_INCREMENTAL : 0
8+ # Make sure CI fails on all warnings, including Clippy lints
9+ RUSTFLAGS : " -Dwarnings"
10+
11+ jobs :
12+ ub-detection :
13+ if : github.event.pull_request.draft == false
14+ name : Check for undefined behaviour (UB)
15+ timeout-minutes : 30
16+ runs-on : ubuntu-latest
17+ steps :
18+ - uses : actions/checkout@v4
19+ - run : |
20+ rustup +nightly component add miri
21+ cargo +nightly miri setup
22+ MIRIFLAGS="-Zmiri-strict-provenance" cargo +nightly miri test --lib
Original file line number Diff line number Diff line change 1+ # IDEs
2+ .vscode
3+ .idea
4+
5+ # Rust/Cargo
6+ debug /
7+ target /
8+ Cargo.lock
9+
10+ # MSVC Windows builds of rustc generate these, which store debugging information
11+ * .pdb
12+
13+ # These are backup files generated by rustfmt
14+ ** /* .rs.bk
Original file line number Diff line number Diff line change 1+ # TODO(template) put codeowners here (usually the project contribitors and the group manager)
2+
3+ Michal Zajac @mpzajac
Original file line number Diff line number Diff line change 1+ # Contributor's guide
2+
3+ ## Commit signing
4+
5+ Enable [ commit signing] ( https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits )
6+
7+ ``` sh
8+ git config commit.gpgsign true
9+ ```
10+
11+ ## Prerequisites
12+
13+ * [ Rust] ( https://www.rust-lang.org/tools/install )
14+ * [ cargo deny] ( https://github.com/EmbarkStudios/cargo-deny )
15+ * [ typos] ( https://github.com/crate-ci/typos?tab=readme-ov-file#install )
16+
17+ ## Code quality assurance
18+
19+ Install a pre-push git hook:
20+
21+ ``` sh
22+ git config core.hooksPath .githooks
23+ ```
24+
25+ ## Running the Rust Documentation Locally
26+ After cloning the repository, follow the instructions below to run the documentation locally:
27+
28+ ``` sh
29+ cargo doc
30+ ```
31+
32+ Docs for ` TODO(template) template-crate ` :
33+
34+ ``` sh
35+ RUSTDOCFLAGS=" --html-in-header katex-header.html" cargo doc --no-deps -p template-crate --open
36+ ```
Original file line number Diff line number Diff line change 1+ [workspace .package ]
2+ version = " 0.1.0"
3+ edition = " 2021"
4+ # TODO(template) update for your repository
5+ repository = " https://github.com/NethermindEth/rust-template"
6+ license = " Apache-2.0" # TODO(template) update license if needed
7+
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+
17+ [workspace .dependencies ]
18+
19+ [workspace .lints .rust ]
20+ missing_docs = " deny"
21+ # TODO(template) if you use any unsafe code, then running miri in CI is a must
22+ # if for a crate in the workspace you need an unsafe code
23+ # prefer to preserve forbid for the workspace
24+ # and allowing only at a specific crate level
25+ unsafe_code = " forbid"
26+
27+ [workspace .lints .clippy ]
28+ arithmetic_side_effects = " deny"
29+ cast_lossless = " deny"
30+ cast_possible_truncation = " deny"
31+ cast_possible_wrap = " deny"
32+ cast_precision_loss = " deny"
33+ cast_sign_loss = " deny"
34+ needless_return = " deny"
35+ panicking_overflow_checks = " deny"
36+ unwrap_used = " deny"
You can’t perform that action at this time.
0 commit comments