Skip to content

Commit 939981d

Browse files
maksimryndinpycckuufrozenspidermraljmattsuffern
committed
rust repo template
Co-authored-by: Igor Markelov <pycckuu@users.noreply.github.com> Co-authored-by: Alex Abdugafarov <frozenspider@users.noreply.github.com> Co-authored-by: Nikola Mratinic <mralj@users.noreply.github.com> Co-authored-by: Mateo Suffern <135047609+mattsuffern@users.noreply.github.com>
0 parents  commit 939981d

24 files changed

Lines changed: 669 additions & 0 deletions

.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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## 🧩 What was the bug?
2+
3+
Describe what was broken or not working as expected. Link to issues if relevant.
4+
5+
> Example: the was a random deadlock when several requests landed
6+
7+
---
8+
9+
### 📎 Related issues (optional)
10+
11+
Closes #123
12+
13+
---
14+
15+
## 🔧 What’s been fixed?
16+
17+
Explain the fix and any relevant changes made.
18+
19+
> Example: Changed RWLock to Mutex
20+
21+
---
22+
23+
### 💬 Anything else reviewers should know?
24+
25+
> Example: This fix touches shared validation code. Double-check for side effects!
26+
27+
---
28+
29+
## ✅ Checklist
30+
31+
List what you tested to confirm the bug is resolved.
32+
33+
- [ ] Confirmed the bug no longer occurs
34+
- [ ] Existing tests pass
35+
- [ ] Added new test(s) for the bug
36+
- [ ] The branch with the bugfix is named `bugfix/<name>`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Choose a PR Template
2+
3+
- [Bug Fix](bugfix.md)
4+
- [New Feature](feature.md)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## 🚀 What’s this PR do?
2+
3+
The PR must explain which problem it solves or which feature it introduces. This can also be done in an issue; if this is the case, then it's ok for PR to just have closes #whatever
4+
5+
---
6+
7+
### 📎 Related issues (optional)
8+
9+
Closes #123
10+
11+
## 🧠 Context
12+
13+
It would be helpful to point out if you solved the problem in an interesting way. For example, I've reordered the fields in a struct to achieve better struct packing, which reduced memory usage and improved CPU caching.
14+
Especially if you reached for some unorthodox solution or used one that at first glance seems weird/wrong, it's helpful to point this out in the PR. Example: Usually, I would use locking primitives here, but because of {this specific reason}, we can get away w/o locking.
15+
If anything you think is worth pointing out or that the reviewer might find interesting or helpful, feel free to put it into the description. Example: I've decided to use RWLock instead of Mutex because Reader to Writer ratio is 5:1.
16+
17+
## ✅ Checklist
18+
19+
- [ ] I’ve tested this locally
20+
- [ ] I’ve added relevant docs or comments
21+
- [ ] I’ve updated or created tests if needed
22+
- [ ] The branch with the feature is named `feature/<name>`
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: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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

.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

0 commit comments

Comments
 (0)