-include .env
define run_cmd
if [ "$(LOCAL_DEV)" = true ] ; \
then \
$(1); \
else \
docker run --rm --user "$(id -u)":"$(id -g)" --volume "${PWD}":/tmp/workspace --workdir /tmp/workspace kisiodigital/rust-ci:latest sh -c "$(1)"; \
fi
endef
CARGO_FMT=cargo fmt --all -- --check
fmt: format
format:
@echo "--> Running '$(CARGO_FMT)'"
@$(call run_cmd, rustup component add rustfmt && $(CARGO_FMT))
CARGO_CLIPPY=cargo clippy --workspace --all-features --all-targets -- --warn clippy::cargo --allow clippy::multiple_crate_versions --deny warnings
clippy: lint
lint:
@echo "--> Running '$(CARGO_CLIPPY)'"
@$(call run_cmd, rustup component add clippy && $(CARGO_CLIPPY))
CARGO_TEST=cargo test --workspace --all-features --all-targets
test:
@echo "--> Running '$(CARGO_TEST)'"
@$(call run_cmd, $(CARGO_TEST))
help:
@grep -E '^[a-zA-Z_-]+:.*## .*$$' $(CURDIR)/$(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: fmt format clippy lint test help
.DEFAULT_GOAL := help