PRECOMMIT_HOOK := f'''
#!/usr/bin/sh
just precommit
'''
CARGO_PLUGINS := " \
cargo-audit \
cargo-machete \
cargo-msrv \
"
EXAMPLES := " \
juggler-smol \
juggler-tokio \
"
[private]
default:
@just --list
# Initialize development environment
init:
@echo "Initialize dev environment:"
@echo "- Installing cargo plugins:"
@for PLUGIN in {{CARGO_PLUGINS}}; do \
cargo install "$PLUGIN"; \
done
@echo "- Installing pre-commit hook"
@echo -n "{{PRECOMMIT_HOOK}}" > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
@echo
# Clean all artifacts
clean:
@echo "Cleaning all artifacts:"
cargo clean
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" clean; \
done
# Format codebase
format:
@echo "Formatting codebase:"
cargo fmt
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" format; \
done
# Build with in different feature combinations
build:
@echo "Building artifacts (with feature combinations):"
cargo build --release --features "systemd toml yaml json agnostic"
cargo build --release --features "systemd toml yaml json tokio"
cargo build --release --features "systemd toml yaml json agnostic tokio"
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" build; \
done
# Run tests with different feature combinations
test:
@echo "Running tests (async runtime agnostic):"
cargo test --features "systemd toml yaml json agnostic"
@echo
@echo "Running tests (tokio):"
cargo test --features "systemd toml yaml json tokio"
@echo
@echo "Running tests (all features):"
cargo test --features "systemd toml yaml json agnostic tokio"
@echo
# Run clippy with different feature combinations
clippy:
@echo "Running clippy (async runtime agnostic):"
cargo clippy --features "systemd toml yaml json agnostic" -- -Dwarnings
@echo
@echo "Running clippy (tokio):"
cargo clippy --features "systemd toml yaml json tokio" -- -Dwarnings
@echo
@echo "Running clippy (all features):"
cargo clippy --features "systemd toml yaml json agnostic tokio" -- -Dwarnings
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" clippy; \
done
# Scan dependency tree with different feature combinations
machete:
@echo "Scan dependency tree for unused dependencies:"
cargo machete
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" machete; \
done
# Scan dependency tree for known vulnerabilities or unmaintained crates
audit:
@echo "Auditing dependency tree:"
cargo audit -D warnings
@echo
@for EXAMPLE in {{EXAMPLES}}; do \
just --justfile "examples/$EXAMPLE/justfile" audit; \
done
# Calculate MSRV
msrv:
# NOTE: Updating the msrv is considered a breaking change and must
# result in a higher version number. Keep this in mind while updating
# dependencies in the future.
@echo "Determine MSRV"
@echo "-------------------"
cargo msrv find --features "systemd toml yaml json agnostic tokio"
@echo
# Apply all precommit checks
precommit: format build test clippy machete audit