-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
185 lines (150 loc) · 5.81 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
SHELL := /bin/sh
.DEFAULT_GOAL := help
# Shell colors
GREEN = \033[0;32m
NOCOLOR = \033[0m
YELLOW = \033[0;33m
# Shell commands
DC = docker-compose -f ./docker-compose.yml
DCR = $(DC) run
DCU = $(DC) up
MAKE = make
RM = rm -rf
#############################################################################
## Container tasks
#############################################################################
.PHONY: build
.SILENT: build
build: ; $(info Building the custom images needed)
$(DC) build ${ARGS}
.PHONY: flush
.SILENT: flush
flush: ; $(info Removing created containers (stopping, if needed))
$(DC) rm -fs ${ARGS}
.PHONY: inside
.SILENT: inside
inside: ; $(info Opening a shell within the container ${ARGS})
$(DCR) ${ARGS} sh
.PHONY: list
.SILENT: list
list: ; $(info Listing current containers)
$(DC) ps -a ${ARGS}
#############################################################################
## Dependency tasks
#############################################################################
.PHONY: install
.SILENT: install
install: ; $(info Installing all the project dependencies)
$(DCR) composer install ${ARGS}
.PHONY: reinstall
.SILENT: reinstall
reinstall: remove install
.PHONY: remove
.SILENT: remove
remove: ; $(info Removing all content from dependencies)
$(RM) composer.lock
$(RM) vendor
.PHONY: update
.SILENT: update
update: ; $(info Updating the project dependencies)
$(DCR) composer update ${ARGS}
#############################################################################
## Project tasks
#############################################################################
.PHONY: archive
.SILENT: archive
archive: ; $(info Generating a tar archive of the cleaned project)
$(eval ARCHIVE = $(shell basename "$$PWD"))
mkdir var/$(ARCHIVE)
cp -a Makefile README.md bin/ composer.json config/ docker-compose.yml phpunit.xml.dist public src tests var/$(ARCHIVE)
cd var/$(ARCHIVE)
tar -czpf $(ARCHIVE).tar.gz -C var $(ARCHIVE)
rm -rf var/$(ARCHIVE)
ls -l $(ARCHIVE).tar.gz
.PHONY: clean
.SILENT: clean
clean: ; $(info Cleaning any generated file)
$(RM) .phpunit.result.cache
$(RM) composer.lock
$(RM) coverage
$(RM) var/*
$(RM) vendor
.PHONY: help
.SILENT: help
help:
@printf "$$help"
#############################################################################
## Testing tasks
#############################################################################
.PHONY: coverage
.SILENT: coverage
coverage: ; $(info Generate coverage report in HTML format)
$(DCR) fpm ./vendor/bin/phpunit --configuration=./phpunit.xml.dist --testsuite=unit --coverage-html=coverage ${ARGS}
.PHONY: tests
.SILENT: tests
tests: ; $(info Running all kind of testing available)
$(DCR) phpstan --configuration=./phpstan.neon.dist analyze
$(DCR) phpunit --configuration=./phpunit.xml.dist --colors=always
.PHONY: acceptance
.SILENT: acceptance
acceptance: start; $(info Running only the acceptance suite tests)
$(DCR) phpunit --configuration=./phpunit.xml.dist --testsuite=acceptance ${ARGS}
.PHONY: functional
.SILENT: functional
functional: ; $(info Running only the functional suite tests)
$(DCR) phpunit --configuration=./phpunit.xml.dist --testsuite=functional ${ARGS}
.PHONY: integration
.SILENT: integration
integration: ; $(info Running only the integration suite tests)
$(DCR) phpunit --configuration=./phpunit.xml.dist --testsuite=integration ${ARGS}
.PHONY: unit
.SILENT: unit
unit: ; $(info Running only the unit suite tests)
$(DCR) phpunit --configuration=./phpunit.xml.dist --testsuite=unit ${ARGS}
#############################################################################
## Web service tasks
#############################################################################
.PHONY: start
.SILENT: start
start: ; $(info Starting the web services in http://localhost:8080)
$(DCU) -d nginx
.PHONY: stop
.SILENT: stop
stop: ; $(info Stopping the web services)
$(DC) down
.PHONY: restart
.SILENT: restart
restart: stop start
#############################################################################
## Prints how to use make within this project
#############################################################################
define help
$(YELLOW)Usage:$(NOCOLOR)
$(MAKE) task [ARGS=arguments]
$(YELLOW)Container tasks$(NOCOLOR)
$(GREEN)build$(NOCOLOR) Builds the custom images needed for containers
$(GREEN)flush$(NOCOLOR) Removes created containers (stops, if needed)
$(GREEN)inside ARGS=name$(NOCOLOR) Opens a shell within the container 'name'
$(GREEN)list$(NOCOLOR) List current containers
$(YELLOW)Dependency tasks$(NOCOLOR)
$(GREEN)install$(NOCOLOR) Resolves and installs the project dependencies
$(GREEN)reinstall$(NOCOLOR) Removes and reinstalls the project dependencies
$(GREEN)remove$(NOCOLOR) Removes all content from dependencies
$(GREEN)update$(NOCOLOR) Updates the project dependencies
$(YELLOW)Project tasks$(NOCOLOR)
$(GREEN)archive$(NOCOLOR) Generates a tar archive of the cleaned project
$(GREEN)clean$(NOCOLOR) Leave the project clean without generated files
$(GREEN)help$(NOCOLOR) Shows this help command usage
$(YELLOW)Testing tasks$(NOCOLOR)
$(GREEN)coverage$(NOCOLOR) Generate coverage report in HTML format
$(GREEN)tests$(NOCOLOR) Runs all kind of testing available
$(GREEN)acceptance$(NOCOLOR) Runs only the acceptance suite tests
$(GREEN)functional$(NOCOLOR) Runs only the functional suite tests
$(GREEN)integration$(NOCOLOR) Runs only the integration suite tests
$(GREEN)unit$(NOCOLOR) Runs only the unit suite tests
$(YELLOW)Web service tasks$(NOCOLOR)
$(GREEN)start$(NOCOLOR) Starts the web services
$(GREEN)stop$(NOCOLOR) Stops the web services
$(GREEN)restart$(NOCOLOR) Restarts the web services
endef
export help