-
Notifications
You must be signed in to change notification settings - Fork 98
/
Makefile
executable file
·156 lines (127 loc) · 5.46 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
# Makefile
#
# This file contains the commands most used in DEV, plus the ones used in CI and PRD environments.
#
# The commands are to be organized semantically and alphabetically, so that similar commands are nex to each other
# and we can compare them and update them easily.
#
# For example in a format like `subject-action-environment`, ie:
#
# box-build-base: # box is a generic term, we don't care if it is a virtual machine or a container
# box-build-ci:
# box-build-dev:
# box-push-base:
# box-push-prd:
# cs-fix: # here we don't use the env because we only do it in dev
# dep-install: # again, by default the env is dev
# dep-install-ci:
# dep-install-prd:
# dep-update:
# test: # here we don't even have a subject because it is the app itself, and by default the env is dev
# test-ci: # here we don't even have a subject because it is the app itself
#
# Mute all `make` specific output. Comment this out to get some debug information.
.SILENT:
# .DEFAULT: If the command does not exist in this makefile
# default: If no command was specified
.DEFAULT default:
if [ -f ./Makefile.custom ]; then \
$(MAKE) -f Makefile.custom "$@"; \
else \
if [ "$@" != "" ]; then echo "Command '$@' not found."; fi; \
$(MAKE) help; \
if [ "$@" != "" ]; then exit 2; fi; \
fi
help:
@echo "Usage:"
@echo " make [command]"
@echo
@echo "Available commands:"
@grep '^[^#[:space:]].*:' Makefile | grep -v '^default' | grep -v '^\.' | grep -v '=' | grep -v '^_' | sed 's/://' | xargs -n 1 echo ' -'
########################################################################################################################
CONTAINER_NAME_BASE="hgraca/explicit-architecture:app.sfn.base"
CONTAINER_NAME_PRD="hgraca/explicit-architecture:app.sfn.prd"
COVERAGE_REPORT_PATH="var/coverage.clover.xml"
DB_PATH='var/data/blog.sqlite'
box-build-base:
docker build -t ${CONTAINER_NAME_BASE} -f ./build/container/app.base.dockerfile .
box-build-ci:
docker-compose -f build/container/ci/docker-compose.yml build --force-rm app
box-build-dev:
docker-compose -f build/container/dev/docker-compose.yml build --force-rm app
box-build-prd:
docker-compose -f build/container/prd/docker-compose.yml build --force-rm app
box-push-base:
docker push ${CONTAINER_NAME_BASE}
box-push-prd:
docker push ${CONTAINER_NAME_PRD}
# We run this in tst ENV so that we never run it with xdebug on
cs-fix:
ENV='tst' ./bin/run php vendor/bin/php-cs-fixer fix --verbose
db-setup:
ENV='dev' ./bin/run make db-setup-guest
db-setup-guest:
mkdir -p ./var/data
php bin/console doctrine:database:drop -n --force
php bin/console doctrine:database:create -n
php bin/console doctrine:schema:create -n
php bin/console doctrine:fixtures:load -n
dep-clearcache-guest:
composer clearcache
dep-install:
ENV='dev' ./bin/run composer install
# We use this only when building the box used in the CI
dep-install-ci-guest:
composer install --optimize-autoloader --no-ansi --no-interaction --no-progress --no-scripts
# We use this only when building the box used in PRD
dep-install-prd-guest:
composer install --no-dev --optimize-autoloader --no-ansi --no-interaction --no-progress --no-scripts
dep-update:
ENV='dev' ./bin/run composer update
shell:
docker exec -it app.sfn.dev sh
test:
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='tst' ./bin/run
ENV='tst' ./bin/run make db-setup-guest
$(MAKE) cs-fix
ENV='tst' ./bin/run php vendor/bin/phpunit
ENV='tst' ./bin/stop
$(MAKE) test-acc
test-acc:
- ENV='tst' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='tst' ./bin/run make db-setup-guest
ENV='tst' docker-compose -f build/container/tst/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
ENV='tst' ./bin/stop
test-acc-ci:
- ENV='prd' ./bin/stop # Just in case some container is left over stopped, as is the case after PHPStorm runs tests
ENV='prd' docker-compose -f build/container/prd/docker-compose.yml up -d -t 0
php vendor/bin/codecept run acceptance
ENV='prd' ./bin/stop
test-ci:
$(MAKE) box-build-prd
$(MAKE) box-build-ci # This is always run by default in the Ci, but having it here makes it possible to run in dev
ENV='ci' ./bin/run
ENV='ci' ./bin/run make db-setup-guest
ENV='ci' ./bin/run php vendor/bin/php-cs-fixer fix --verbose --dry-run
ENV='ci' ./bin/run make test_cov-guest
docker exec -it app.sfn.ci cat ${COVERAGE_REPORT_PATH} > ${COVERAGE_REPORT_PATH}
$(MAKE) test-acc-ci
test_cov:
ENV='tst' ./bin/run make test_cov-guest
# We use phpdbg because is part of the core and so that we don't need to install xdebug just to get the coverage.
# Furthermore, phpdbg gives us more info in certain conditions, ie if the memory_limit has been reached.
test_cov-guest:
phpdbg -qrr vendor/bin/phpunit --coverage-text --coverage-clover=${COVERAGE_REPORT_PATH}
test_cov-publish:
bash -c 'bash <(curl -s https://codecov.io/bash)'
up:
if [ ! -f ${DB_PATH} ]; then $(MAKE) db-setup; fi
$(eval UP=ENV=dev docker-compose -f build/container/dev/docker-compose.yml up -t 0)
$(eval DOWN=ENV=dev docker-compose -f build/container/dev/docker-compose.yml down -t 0)
- bash -c "trap '${DOWN}' EXIT; ${UP}"
up-prd:
$(eval UP=ENV=prd docker-compose -f build/container/prd/docker-compose.yml up -t 0)
$(eval DOWN=ENV=prd docker-compose -f build/container/prd/docker-compose.yml down -t 0)
- bash -c "trap '${DOWN}' EXIT; ${UP}"