RUST_VERSION ?= stable
TEST_FEATURES ?= --all-features
TEST_TIMEOUT ?= 300
BUILD_FEATURES ?= --all-features
BUILD_MODE ?= debug
COVERAGE_OUTPUT ?= html
.PHONY: help
help:
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: dev
dev:
@echo "Setting up development environment..."
rustup toolchain install $(RUST_VERSION)
rustup component add rustfmt clippy llvm-tools-preview
cargo install cargo-tarpaulin cargo-criterion divan-cli cargo-audit
@echo "โ
Development environment ready!"
.PHONY: check
check:
@echo "๐ Running basic checks..."
cargo fmt --all -- --check
cargo clippy $(BUILD_FEATURES) -- -D warnings
cargo check $(BUILD_FEATURES)
@echo "โ
Basic checks passed!"
.PHONY: fmt
fmt:
cargo fmt --all
.PHONY: clippy
clippy:
cargo clippy $(BUILD_FEATURES) -- -D warnings
.PHONY: fix
fix:
cargo fmt --all
cargo clippy $(BUILD_FEATURES) --fix --allow-staged --allow-dirty
.PHONY: test
test:
@echo "๐งช Running all tests..."
cargo test $(TEST_FEATURES)
@echo "โ
All tests passed!"
.PHONY: test-unit
test-unit:
@echo "๐งช Running unit tests..."
cargo test --lib $(TEST_FEATURES)
.PHONY: test-integration
test-integration:
@echo "๐งช Running integration tests..."
cargo test --test '*' $(TEST_FEATURES)
.PHONY: test-doc
test-doc:
@echo "๐งช Running documentation tests..."
cargo test --doc $(TEST_FEATURES)
.PHONY: test-examples
test-examples:
@echo "๐งช Testing examples..."
@if [ -d "examples" ]; then \
for example in examples/*/; do \
if [ -f "$$example/Cargo.toml" ]; then \
echo "Testing $$example"; \
cargo check --manifest-path "$$example/Cargo.toml"; \
fi; \
done; \
else \
echo "No examples directory found"; \
fi
.PHONY: test-watch
test-watch:
cargo watch -x 'test $(TEST_FEATURES)'
.PHONY: test-features
test-features:
@echo "๐งช Testing feature combinations..."
cargo test --no-default-features
cargo test --no-default-features --features ssr
cargo test --no-default-features --features csr
cargo test --no-default-features --features og-images
cargo test --features ssr,og-images,json-ld
cargo test --all-features
.PHONY: bench
bench:
@echo "โก Running benchmarks..."
cargo bench $(BUILD_FEATURES)
.PHONY: bench-compare
bench-compare:
@echo "โก Running benchmark comparison..."
cargo bench $(BUILD_FEATURES) -- --save-baseline current
@if [ -f "target/criterion/baseline/estimates.json" ]; then \
echo "Comparing with baseline..."; \
cargo bench $(BUILD_FEATURES) -- --baseline current; \
else \
echo "No baseline found, saving current as baseline"; \
cp -r target/criterion/current target/criterion/baseline; \
fi
.PHONY: perf
perf:
@echo "โก Running performance regression tests..."
cargo test --release --test performance_regression_test
.PHONY: coverage
coverage:
@echo "๐ Generating coverage report..."
cargo tarpaulin --all-features --out $(COVERAGE_OUTPUT) --output-dir target/coverage
@echo "๐ Coverage report generated in target/coverage/"
.PHONY: coverage-xml
coverage-xml:
cargo tarpaulin --all-features --out Xml --output-dir target/coverage
.PHONY: audit
audit:
@echo "๐ Running security audit..."
cargo audit
.PHONY: outdated
outdated:
@echo "๐ฆ Checking for outdated dependencies..."
cargo outdated
.PHONY: e2e
e2e:
@echo "๐ Running E2E tests..."
@if ! command -v npx > /dev/null; then \
echo "โ Node.js/npm required for E2E tests"; \
exit 1; \
fi
npx playwright install --with-deps
cargo test --test e2e $(TEST_FEATURES)
.PHONY: e2e-visual
e2e-visual:
@echo "๐ผ๏ธ Running visual regression tests..."
cargo test --test visual_regression_test $(TEST_FEATURES)
.PHONY: build
build:
@echo "๐จ Building project..."
cargo build $(BUILD_FEATURES)
.PHONY: build-release
build-release:
@echo "๐จ Building in release mode..."
cargo build --release $(BUILD_FEATURES)
.PHONY: build-docs
build-docs:
@echo "๐ Building documentation..."
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc $(BUILD_FEATURES) --no-deps
.PHONY: serve-docs
serve-docs: build-docs
@echo "๐ Serving documentation at http://localhost:8000"
python3 -m http.server 8000 -d target/doc
.PHONY: pre-release
pre-release:
@echo "๐ Running pre-release checks..."
$(MAKE) check
$(MAKE) test
$(MAKE) test-features
$(MAKE) audit
$(MAKE) build-docs
@echo "โ
Pre-release checks passed!"
.PHONY: release-dry-run
release-dry-run:
@echo "๐ Dry-run release..."
cargo publish --dry-run $(BUILD_FEATURES)
.PHONY: clean
clean:
@echo "๐งน Cleaning..."
cargo clean
rm -rf target/coverage/
rm -rf tests/fixtures/visual/*-current.png
.PHONY: clean-all
clean-all: clean
@echo "๐งน Deep cleaning..."
rm -rf ~/.cargo/registry/cache/
rm -rf ~/.cargo/git/
.PHONY: deps
deps:
@echo "๐ฆ Updating dependencies..."
cargo update
.PHONY: tree
tree:
cargo tree $(BUILD_FEATURES)
.PHONY: ci
ci:
@echo "๐ค Running CI pipeline..."
$(MAKE) check
$(MAKE) test
$(MAKE) test-features
$(MAKE) audit
$(MAKE) coverage-xml
@echo "โ
CI pipeline completed!"
.PHONY: nightly
nightly:
@echo "๐ Running nightly tests..."
$(MAKE) perf
$(MAKE) bench
$(MAKE) e2e
@echo "โ
Nightly tests completed!"
.PHONY: docker-build
docker-build:
@if [ -f "Dockerfile" ]; then \
echo "๐ณ Building Docker image..."; \
docker build -t leptos-next-metadata .; \
else \
echo "โ No Dockerfile found"; \
exit 1; \
fi
.PHONY: docker-test
docker-test:
@if [ -f "Dockerfile" ]; then \
echo "๐ณ Running tests in Docker..."; \
docker run --rm leptos-next-metadata cargo test --all-features; \
else \
echo "โ No Dockerfile found"; \
exit 1; \
fi
.PHONY: env-check
env-check:
@echo "๐ Checking development environment..."
@echo "Rust version: $$(rustc --version)"
@echo "Cargo version: $$(cargo --version)"
@echo "Available targets: $$(rustup target list --installed)"
@echo "Available components: $$(rustup component list --installed)"
@if command -v node > /dev/null; then \
echo "Node.js version: $$(node --version)"; \
else \
echo "โ Node.js not found (required for E2E tests)"; \
fi
@if command -v npx > /dev/null; then \
echo "npm version: $$(npm --version)"; \
else \
echo "โ npm not found (required for E2E tests)"; \
fi
.PHONY: install-tools
install-tools:
@echo "๐ ๏ธ Installing development tools..."
cargo install cargo-watch cargo-expand cargo-udeps
cargo install wasm-pack
@if command -v npm > /dev/null; then \
npm install -g @playwright/test; \
npx playwright install; \
fi
@echo "โ
Development tools installed!"
.PHONY: quick-test
quick-test:
cargo test --lib --quiet
.PHONY: quick-check
quick-check:
cargo check $(BUILD_FEATURES)
.PHONY: watch
watch:
cargo watch -x 'check --all-features' -x 'test --lib'
.PHONY: test-help
test-help:
@echo "Testing Commands:"
@echo " make test - Run all tests"
@echo " make test-unit - Run unit tests only"
@echo " make test-integration - Run integration tests"
@echo " make test-features - Test feature combinations"
@echo " make e2e - Run E2E tests (requires Node.js)"
@echo " make perf - Run performance tests"
@echo " make coverage - Generate coverage report"
@echo ""
@echo "Environment Variables:"
@echo " TEST_FEATURES - Features to test (default: --all-features)"
@echo " COVERAGE_OUTPUT - Coverage format (default: html)"
@echo " BUILD_FEATURES - Features to build (default: --all-features)"