.DEFAULT_GOAL := help
.PHONY: help test test-without-nextest build release workflow clean coverage coverage-html coverage-ci lint fmt fmt-check clippy clippy-fix doc doc-check check all ci ensure-tools
CARGO_NEXTEST := $(shell command -v cargo-nextest 2>/dev/null)
CARGO_LLVM_COV := $(shell command -v cargo-llvm-cov 2>/dev/null)
ensure-tools:
ifndef CARGO_NEXTEST
@echo "Installing cargo-nextest..."
@cargo install cargo-nextest --locked
endif
ifndef CARGO_LLVM_COV
@echo "Installing cargo-llvm-cov..."
@cargo install cargo-llvm-cov --locked
endif
help:
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
test: ensure-tools
@ cargo nextest run --all-targets --all-features --examples --test-threads 1
test-without-nextest:
@ cargo test --all-targets --all-features --examples -- --test-threads 1
build:
cargo build --all-targets --all-features --examples
release:
cargo build --all-targets --all-features --examples --release
workflow: release
cp target/release/examples/random_user workflow/
cp target/release/examples/sleep workflow/
cp target/release/examples/url_items workflow/
cp target/release/examples/static_output workflow/
run-example-%:
cargo run --example $*
check:
cargo check --all-targets --all-features --examples
fmt:
cargo fmt --all
fmt-check:
cargo fmt --all -- --check
clippy:
cargo clippy --all-targets --all-features --examples -- -D warnings
clippy-fix:
cargo clippy --all-targets --all-features --examples --fix -- -D warnings
lint: fmt clippy
clean:
cargo clean
cargo llvm-cov clean
doc:
cargo doc --no-deps --open
doc-check:
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
coverage: ensure-tools
@ cargo llvm-cov --all-features --examples --tests --show-missing-lines -- --test-threads 1
coverage-html: ensure-tools
@ cargo llvm-cov --all-features --examples --tests --html --open -- --test-threads 1
coverage-ci: ensure-tools
@ cargo llvm-cov clean --workspace
@ cargo llvm-cov --all-features --examples --tests --lcov --output-path lcov.info -- --test-threads 1
all: ensure-tools fmt lint build test
ci: ensure-tools fmt-check lint build doc-check test