-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
152 lines (124 loc) · 4.37 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
project_name = synapse
APPS = $(shell ls bin | grep console | sed s/console_//g)
#
# Dev environment
#
init: vm-up vm-ssh
vm-ssh:
vagrant ssh
vm-up:
vagrant up
vm-halt:
vagrant halt
vm-provision:
vagrant up --no-provision
vagrant provision
vm-destroy:
vagrant destroy
vm-rebuild: vm-destroy vm-provision
#
# Main tasks
#
install: install-infra install-vendors install-database clean
build: build-database
update: update-composer update-database
#
# Install
#
install-npm:
npm install
install-composer: bin/composer
./bin/composer install
install-local-parameters:
$(foreach app,$(APPS),cp -n apps/$(app)/config/parameters.yml.dist apps/$(app)/config/parameters.yml;)
install-directories:
$(foreach app,$(APPS),mkdir -p web/assets/$(app);)
install-vendors: install-composer install-local-parameters
#
# Directories & files
#
bin/composer:
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin --filename=composer
chmod +x bin/composer || /bin/true
bin/php-cs-fixer:
wget http://get.sensiolabs.org/php-cs-fixer.phar -O bin/php-cs-fixer
chmod +x bin/php-cs-fixer || /bin/true
bin/phpunit:
ln -fs ../vendor/phpunit/phpunit/phpunit bin/phpunit
wallet:
mkdir -p wallet
update-bin: bin/composer bin/php-cs-fixer
./bin/composer self-update
php bin/php-cs-fixer self-update
.git/hooks/pre-commit:
curl https://raw.githubusercontent.com/LinkValue/symfony-git-hooks/master/pre-commit -o .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit || /bin/true
install-infra: wallet update-bin .git/hooks/pre-commit
#
# Database
#
install-database:
$(foreach app,$(APPS),php bin/console_$(app) doctrine:database:create --if-not-exists;)
$(foreach app,$(APPS),php bin/console_$(app) doctrine:migrations:migrate -n --allow-no-migration;)
build-database: install-database
$(foreach app,$(APPS),php bin/console_$(app) doctrine:fixtures:load -n;)
$(foreach app,$(APPS),php bin/console_$(app) doctrine:fixtures:load -n --em="synapse";)
update-database: install-database
$(foreach app,$(APPS),php bin/console_$(app) doctrine:schema:validate || test "$$?" -gt 1;)
$(foreach app,$(APPS),php bin/console_$(app) doctrine:migrations:diff --filter-expression="/^$(app)/";)
$(foreach app,$(APPS),php bin/console_$(app) doctrine:migrations:diff --filter-expression="/^synapse_.+/" --em=synapse;)
$(foreach app,$(APPS),php bin/console_$(app) doctrine:migrations:migrate -n;)
trash-database:
$(foreach app,$(APPS),php bin/console_$(app) doctrine:database:drop --force --if-exists;)
rm -rf web/assets/* || /bin/true
trash-uncommitted-migrations:
$(foreach app,$(APPS),git status apps/$(app)/DoctrineMigrations --porcelain | grep "??" | sed "s/?? //g" | xargs -I {} rm {};)
squash-migrations: trash-uncommitted-migrations trash-database update-database
rebuild-database: trash-database build-database
#
# Clean
#
clean: bin/composer
rm -rf vendor/composer/autoload* || /bin/true
rm var/bootstrap.php.cache || /bin/true
rm -rf web/bundles || /bin/true
./bin/composer dump-autoload
./bin/composer run-script setup-bootstrap -vv
rm -rf var/cache/$(project_name) || /bin/true
rm -rf var/logs/$(project_name) || /bin/true
test -d /dev/shm/$(project_name) && rm -rf /dev/shm/$(project_name) || /bin/true
$(foreach app,$(APPS),php bin/console_$(app) cache:warmup;)
$(foreach app,$(APPS),php bin/console_$(app) cache:warmup --env=prod;)
$(foreach app,$(APPS),php bin/console_$(app) assets:install --symlink;)
#
# Update
#
update-composer: bin/composer
./bin/composer update --no-scripts
#
# Git
#
push-subrepo:
git subrepo push src/Synapse/Cmf --force
git subrepo push src/Synapse/Admin --force
git subrepo push src/Synapse/Page --force
#
# Tests
#
tests: bin/phpunit
./bin/phpunit -c . --testsuite synapse_cmf
tests-covered: bin/phpunit
rm -rf web/coverage || true
php -dzend_extension=xdebug.so bin/phpunit -c phpunit.xml.dist --testsuite synapse_cmf --coverage-html web/coverage
@echo "\nCoverage report : \n\033[1;32m http://tests.synapse.dev/coverage/index.html\033[0m\n"
#
# CI
#
ci-install-composer: bin/composer
./bin/composer install --prefer-dist
bin/ocular:
wget https://scrutinizer-ci.com/ocular.phar -O bin/ocular
chmod +x bin/ocular || /bin/true
travis: ci-install-composer bin/ocular
./vendor/phpunit/phpunit/phpunit src -c phpunit.xml.dist --testsuite synapse_cmf --coverage-clover=coverage.clover
(test -f coverage.clover && php bin/ocular code-coverage:upload --format=php-clover coverage.clover) || true