Skip to content

Commit 94ca5c0

Browse files
committed
rust repo template
0 parents  commit 94ca5c0

File tree

19 files changed

+572
-0
lines changed

19 files changed

+572
-0
lines changed

.githooks/pre-push

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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!"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

.github/workflows/docs.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Rust CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
jobs:
13+
# TODO(template) remove docs publishing, when the crate is published to crates.io
14+
docs:
15+
permissions:
16+
contents: write
17+
name: Documentation
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout source code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 1
24+
persist-credentials: false
25+
26+
- name: Setup pages
27+
id: pages
28+
uses: actions/configure-pages@v5
29+
30+
- name: Clean docs folder
31+
run: cargo clean --doc
32+
33+
# Documentation with Latex support
34+
# TODO(template) if Latex is not needed
35+
# just remove katex-header.html at the root and RUSTDOCFLAGS here
36+
# TODO(template) update the crate name
37+
- name: Build documentation
38+
run: RUSTDOCFLAGS="--html-in-header katex-header.html" cargo doc --no-deps -p mycrate
39+
40+
- name: Remove lock file
41+
run: rm target/doc/.lock
42+
43+
- name: Upload artifact
44+
uses: actions/upload-pages-artifact@v3
45+
with:
46+
path: target/doc
47+
48+
publish-docs:
49+
permissions:
50+
pages: write
51+
id-token: write
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
runs-on: ubuntu-latest
56+
needs: docs
57+
steps:
58+
- name: Deploy to GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v4

.github/workflows/linter.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+

.github/workflows/ub-detection.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

CODEOWNER

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TODO(template) put codeowners here (usually the project contribitors and the group manager)
2+
3+
Michal Zajac @mpzajac

CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
```

Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[workspace.package]
2+
version = "0.1.0"
3+
edition = "2021"
4+
repository = "https://github.com/NethermindEth/LaBRADOR-rs"
5+
license = "Apache-2.0" # TODO(template) update license if needed
6+
7+
# TODO(template) update for the crate name
8+
[workspace]
9+
members = [
10+
"examples",
11+
"mycrate",
12+
]
13+
resolver = "2"
14+
default-members = ["mycrate"]
15+
16+
[workspace.dependencies]

0 commit comments

Comments
 (0)