-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
133 lines (103 loc) · 3.24 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
.DEFAULT_GOAL := help
.SILENT:
.PHONY: vendor
## Colors
COLOR_RESET = \033[0m
COLOR_INFO = \033[32m
COLOR_COMMENT = \033[33m
## Help
help:
printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
printf " make [target]\n\n"
printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
##################
# Useful targets #
##################
## Install all install_* requirements and launch project.
install: env_file env_run install_vendor install_db
## Run project, install vendors and run migrations.
run: env_run install_vendor install_db
## Stop project.
stop:
docker-compose stop
## Down project and remove volumes (databases).
down:
docker-compose down -v --remove-orphans
## Run all quality assurance tools (tests and code inspection).
qa: unsued_libraries code_static_analysis code_fixer code_detect code_correct test_spec test test_behaviour
## Truncate database and import fixtures.
fixtures: down run import_dev
########
# Code #
########
## Run codesniffer to correct violations of a defined coding project standards.
code_correct:
docker-compose exec php bin/phpcs --standard=PSR2 src
## Run codesniffer to detect violations of a defined coding project standards.
code_detect:
docker-compose exec php bin/phpcbf --standard=PSR2 src tests
## Run cs-fixer to fix php code to follow project standards.
code_fixer:
docker-compose exec php bin/php-cs-fixer fix
## Run PHPStan to find errors in code.
code_static_analysis:
docker-compose exec php bin/phpstan analyse src --level max
## Check unsued libraries via composer
unsued_libraries:
docker-compose exec php bin/unused_scanner scanner_config.php
###############
# Environment #
###############
## Set defaut environment variables by copying env.dist file as .env.
env_file:
cp .env.dist .env
## Launch docker environment.
env_run:
docker-compose up -d
###############
# Import Data #
###############
## Import fixtures.
import_dev:
./docker/development/import-fixtures.sh
## Import stations states from bicing.cat provider.
import_states:
docker-compose exec php bin/console bicing-api:import:stations-states
## Import stations from bicing.cat provider.
import_stations:
docker-compose exec php bin/console bicing-api:import:stations
###########
# Install #
###########
## Run database migration.
install_db:
docker-compose run --rm php bin/console do:mi:mi -n
## Run test database migration.
install_db_test:
docker-compose exec php bin/console do:mi:mi -n --env=test
## Install vendors.
install_vendor:
docker-compose run --rm php composer install --prefer-dist --no-scripts --no-progress --no-suggest
########
# Test#
########
## Run unit&integration tests with pre-installing test database.
test: install_db_test test_unit
## Run behaviour tests.
test_behaviour:
docker-compose exec php bin/behat
## Run unit&integration tests.
test_unit:
docker-compose exec php bin/simple-phpunit
## Run php spect tests.
test_spec:
docker-compose exec php bin/phpspec run