Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Cargo configuration for petite-ad.
#
# The mold linker flag below speeds up local builds substantially.
# If mold is not installed, the flag is silently ignored by the linker.
# Remove or adjust the rustflags if needed for your machine.

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

[registries.crates-io]
protocol = "sparse" # Faster crate downloads
104 changes: 104 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master]

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly]

steps:
- uses: actions/checkout@v4

- name: Setup mold linker
uses: rui314/setup-mold@v1

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt, clippy

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.rust }}

- name: Check formatting
run: cargo fmt -- --check

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Run tests
run: cargo test --verbose --all-features

- name: Run examples
run: cargo test --examples --all-features

Comment thread
leafyoung marked this conversation as resolved.
- name: Run benchmarks (check only)
run: cargo bench --no-run

coverage:
name: Code Coverage
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup mold linker
uses: rui314/setup-mold@v1

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin

- name: Generate coverage report
run: cargo tarpaulin --lib --out Xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./cobertura.xml
fail_ci_if_error: false

security:
name: Security audit
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup mold linker
uses: rui314/setup-mold@v1

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable

- name: Install cargo-audit
run: cargo install cargo-audit

- name: Generate temporary lockfile
run: cargo generate-lockfile

- name: Run security audit
run: cargo audit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ target
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

Cargo.lock
84 changes: 40 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,65 +1,61 @@
# Pre-commit hooks for Rust project
# Pre-commit hooks for petite-ad
# See https://pre-commit.com for more information
# Run `pre-commit install` to install these hooks
# Install: pip install pre-commit
# Setup: pre-commit install
# Run manually: prek run --all-files # alias for: pre-commit run --all-files

repos:
# General hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-merge-conflict
- id: check-case-conflict
- id: mixed-line-ending
args: ['--fix=lf']

# Rust specific hooks using local cargo commands
- repo: local
hooks:
# Run cargo fmt to automatically format Rust files.
- id: cargo-fmt
name: cargo fmt
entry: cargo fmt
language: system
types: [rust]
pass_filenames: false
Comment thread
leafyoung marked this conversation as resolved.

- id: cargo-check
name: cargo check
entry: cargo check
language: system
args: ['--all-targets', '--all-features']
pass_filenames: false

# Clippy linting
- repo: local
hooks:
- id: clippy
# Run cargo clippy to catch common mistakes.
- id: cargo-clippy
name: cargo clippy
entry: cargo clippy
entry: cargo clippy --all-targets --all-features -- -D warnings
language: system
args: ['--all-targets', '--all-features', '--', '-D', 'warnings']
types: [rust]
pass_filenames: false

# Run tests
- repo: local
hooks:
# Run cargo test to ensure all tests pass.
- id: cargo-test
name: cargo test
entry: cargo test
entry: cargo test --all-features
language: system
args: ['--all-features']
types: [rust]
pass_filenames: false

# Check documentation
- repo: local
# Generic pre-commit hooks for non-Rust files.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: cargo-doc
name: cargo doc
entry: cargo doc
language: system
args: ['--no-deps', '--all-features']
pass_filenames: false
# Check for accidentally committed large files.
- id: check-added-large-files
args: ["--maxkb=10000"]

# Check config file syntax.
- id: check-yaml
- id: check-json
- id: check-toml

# Fix whitespace-only file hygiene issues.
- id: trailing-whitespace
exclude: ^(tests/|fixtures/)
- id: end-of-file-fixer

# Detect conflict markers and case-insensitive path collisions.
- id: check-merge-conflict
- id: check-case-conflict

# Normalize line endings.
- id: mixed-line-ending
args: ["--fix=lf"]

# Check that scripts with shebangs are executable.
- id: check-executables-have-shebangs
Loading
Loading