From 73c15d6be1796b607d2c8446b6040c19ef07b9d5 Mon Sep 17 00:00:00 2001 From: Ali Mehraji Date: Tue, 23 Dec 2025 04:21:04 +0330 Subject: [PATCH] Add: rust installation in Makefile (#1188) Signed-off-by: Ali Mehraji Signed-off-by: houseme Co-authored-by: houseme Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Makefile | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 60bfce83..40ac1738 100644 --- a/Makefile +++ b/Makefile @@ -9,30 +9,53 @@ CONTAINER_NAME ?= rustfs-dev DOCKERFILE_PRODUCTION = Dockerfile DOCKERFILE_SOURCE = Dockerfile.source +# Fatal check +# Checks all required dependencies and exits with error if not found +# (e.g., cargo, rustfmt) +check-%: + @command -v $* >/dev/null 2>&1 || { \ + echo >&2 "โŒ '$*' is not installed."; \ + exit 1; \ + } + +# Warning-only check +# Checks for optional dependencies and issues a warning if not found +# (e.g., cargo-nextest for enhanced testing) +warn-%: + @command -v $* >/dev/null 2>&1 || { \ + echo >&2 "โš ๏ธ '$*' is not installed."; \ + } + +# For checking dependencies use check- or warn- +.PHONY: core-deps fmt-deps test-deps +core-deps: check-cargo +fmt-deps: check-rustfmt +test-deps: warn-cargo-nextest + # Code quality and formatting targets .PHONY: fmt -fmt: +fmt: core-deps fmt-deps @echo "๐Ÿ”ง Formatting code..." cargo fmt --all .PHONY: fmt-check -fmt-check: +fmt-check: core-deps fmt-deps @echo "๐Ÿ“ Checking code formatting..." cargo fmt --all --check .PHONY: clippy -clippy: +clippy: core-deps @echo "๐Ÿ” Running clippy checks..." cargo clippy --fix --allow-dirty cargo clippy --all-targets --all-features -- -D warnings .PHONY: check -check: +check: core-deps @echo "๐Ÿ”จ Running compilation check..." cargo check --all-targets .PHONY: test -test: +test: core-deps test-deps @echo "๐Ÿงช Running tests..." @if command -v cargo-nextest >/dev/null 2>&1; then \ cargo nextest run --all --exclude e2e_test; \ @@ -42,16 +65,16 @@ test: fi cargo test --all --doc -.PHONY: pre-commit -pre-commit: fmt clippy check test - @echo "โœ… All pre-commit checks passed!" - .PHONY: setup-hooks setup-hooks: @echo "๐Ÿ”ง Setting up git hooks..." chmod +x .git/hooks/pre-commit @echo "โœ… Git hooks setup complete!" +.PHONY: pre-commit +pre-commit: fmt clippy check test + @echo "โœ… All pre-commit checks passed!" + .PHONY: e2e-server e2e-server: sh $(shell pwd)/scripts/run.sh @@ -186,8 +209,6 @@ docker-dev-push: --push \ . - - # Local production builds using direct buildx (alternative to docker-buildx.sh) .PHONY: docker-buildx-production-local docker-buildx-production-local: @@ -247,8 +268,6 @@ dev-env-stop: .PHONY: dev-env-restart dev-env-restart: dev-env-stop dev-env-start - - # ======================================================================================== # Build Utilities # ========================================================================================