-
Notifications
You must be signed in to change notification settings - Fork 827
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (47 loc) · 1.82 KB
/
Makefile
File metadata and controls
63 lines (47 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# mruby is using Rake (https://ruby.github.io/rake/) as a build tool.
RAKE = rake
DOCKER_COMPOSE = docker-compose
PRE_COMMIT = prek
define check_command
@command -v $(1) >/dev/null 2>&1 || { \
echo "Error: $(1) is not installed or not in PATH."; \
exit 1; \
}
endef
# For colors
ifneq ($(shell tty -s),)
CYAN := $(shell tput setaf 6)
RESET := $(shell tput sgr0)
else
CYAN :=
RESET :=
endif
.PHONY: all test clean check checkinstall checkupdate composecheck composetest check_rake check_docker_compose check_pre_commit help
.DEFAULT_GOAL := all
all: check_rake ## build all targets, install (locally) in-repo
$(RAKE)
test: check_rake all ## build and run all mruby tests
$(RAKE) test
clean: check_rake ## clean all built and in-repo installed artifacts
$(RAKE) clean
check: check_pre_commit ## run all prek hooks against all files
$(PRE_COMMIT) run --all-files
checkinstall: check_pre_commit ## install the prek hooks
$(PRE_COMMIT) install
checkupdate: check_pre_commit ## check the prek hooks for updates
$(PRE_COMMIT) autoupdate
composecheck: check_docker_compose check_pre_commit ## run all prek hooks against all files with docker-compose
$(DOCKER_COMPOSE) -p mruby run test $(PRE_COMMIT) run --all-files
composetest: check_docker_compose ## build and run all mruby tests with docker-compose
$(DOCKER_COMPOSE) -p mruby run test
check_rake: ## check if Rake is installed
$(call check_command, $(RAKE))
check_docker_compose: ## check if docker-compose is installed
$(call check_command, $(DOCKER_COMPOSE))
check_pre_commit: ## check if prek is installed
$(call check_command, $(PRE_COMMIT))
help: ## display this help message
@echo "Usage: make <target>"
@echo
@echo "Available targets:"
@grep -E '^[a-z_-]+:.*##' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*## *"}; {printf " $(CYAN)%-20s$(RESET) %s\n", $$1, $$2}'