-
Notifications
You must be signed in to change notification settings - Fork 156
/
Makefile
91 lines (76 loc) · 3.05 KB
/
Makefile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
PIDFILE=/tmp/mailhog.pid
MAILHOG=./bin/mailhog
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
ifeq '$(findstring ;,$(PATH))' ';'
#UNAME := Windows
UNAME := $(shell uname 2>NUL || echo Windows)
else
UNAME := $(shell uname 2>/dev/null || echo Unknown)
UNAME := $(patsubst CYGWIN%,Cygwin,$(UNAME))
UNAME := $(patsubst MSYS%,MSYS,$(UNAME))
UNAME := $(patsubst MINGW%,MSYS,$(UNAME))
endif
UNAME := $(call lc,$(UNAME))
PLAT=386
# https://apple.stackexchange.com/questions/140651/why-does-arch-output-i386
# https://stackoverflow.com/questions/12763296/os-x-arch-command-incorrect
UNAME_P := $(shell sh -c 'uname -m 2>/dev/null || echo not')
ifeq ($(UNAME_P),x86_64)
PLAT := amd64
endif
ifneq ($(filter %86,$(UNAME_P)),)
PLAT := 386
endif
ifneq ($(filter arm%,$(UNAME_P)),)
PLAT := arm
endif
MAILHOG_URL=https://github.com/mailhog/MailHog/releases/download/v1.0.1/MailHog_$(UNAME)_$(PLAT)
help: ## What you're currently reading
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
clear ; \
printf "Usage: make [target]\n\n" ; \
printf "%-30s %s\n" "[target]" "help" ; \
printf "%-30s %s\n" "--------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-30s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done; \
printf "\n"; \
install: ## Installs dev dependencies
composer validate --strict
composer install
make $(MAILHOG)
touch /tmp/mailhog.log
clean: ## Removes installed dev dependencies
rm composer.lock
rm -rf ./vendor
rm -rf $(MAILHOG)
rm -rf $(PIDFILE)
rm -rf /tmp/mailhog.log
lint: ## Run phpcs
"./vendor/bin/phpcs"
test: server-start ## Runs tests
"./vendor/bin/phpunit" --no-coverage
make server-stop
coverage: server-start ## Runs tests with code coverage
XDEBUG_MODE=coverage "./vendor/bin/phpunit" --coverage-html=./coverage/ --coverage-clover=./coverage/clover.xml
make server-stop
server-start: server-stop $(PIDFILE) ## Stops and starts the smtp server
server-stop: ## Stops smtp server if it's running
./bin/stop-server.sh $(PIDFILE)
test /tmp/mailhog.log && > /tmp/mailhog.log # truncate if exists
$(PIDFILE): ## Starts the smtp server
$(MAILHOG) -api-bind-addr=127.0.0.1:8025 -ui-bind-addr=127.0.0.1:8025 -smtp-bind-addr=127.0.0.1:1025 > /tmp/mailhog.log 2>&1 & echo $$! > $@
$(MAILHOG): ## Downloads platform-specific mailhog binary
# @echo $(MAILHOG_URL)
# wget $(MAILHOG_URL) -O $@
curl -L $(MAILHOG_URL) -o $@
chmod +x $(MAILHOG)
.PHONY: help install clean lint test coverage server-start server-stop