-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
185 lines (152 loc) · 5.74 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
include .env
NAME := $(or $(BASE_IMAGE),$(BASE_IMAGE),drupalwxt/site-wxt)
VERSION := $(or $(VERSION),$(VERSION),'latest')
PLATFORM := $(shell uname -s)
DB_NAME := $(or $(DB_NAME),$(DB_NAME),'wxt')
DB_TYPE := $(or $(DB_TYPE),$(DB_TYPE),'mysql')
DB_PORT := $(or $(DB_PORT),$(DB_PORT),'3306')
PROFILE_NAME := $(or $(PROFILE_NAME),$(PROFILE_NAME),'wxt')
all: base
base:
mkdir -p config/sync html/modules/custom html/themes/custom
docker build -f docker/Dockerfile \
-t $(NAME):$(VERSION) \
--build-arg SSH_PRIVATE_KEY="$$(test -f $$HOME/.ssh/id_rsa && base64 $$HOME/.ssh/id_rsa)" \
--no-cache \
--build-arg http_proxy=$$HTTP_PROXY \
--build-arg HTTP_PROXY=$$HTTP_PROXY \
--build-arg https_proxy=$$HTTP_PROXY \
--build-arg HTTPS_PROXY=$$HTTP_PROXY \
--build-arg no_proxy=$$NO_PROXY \
--build-arg NO_PROXY=$$NO_PROXY \
--build-arg GIT_USERNAME=$(GIT_USERNAME) \
--build-arg GIT_PASSWORD=$(GIT_PASSWORD) .
behat:
./docker/bin/behat -vv -c behat.yml --colors
build: all
clean: clean_composer
clean_composer:
rm -rf html
rm -rf vendor
rm -f composer.lock
composer clear-cache
clean_docker:
rm -rf docker
git clone $(DOCKER_REPO) docker
[ "$(shell docker images -q --filter "dangling=true")" = "" ] || docker rmi -f $(shell docker images -q --filter "dangling=true")
[ "$(shell docker ps -a -q -f name=${DOCKER_NAME}_)" = "" ] || docker rm -f $(shell docker ps -a -q -f name=${DOCKER_NAME}_)
[ "$(shell docker images -q -f reference=${DOCKER_IMAGE}_*)" = "" ] || docker rmi -f $(shell docker images -q -f reference=*${DOCKER_IMAGE}_*)
[ "$(shell docker images -q -f reference=${NAME})" = "" ] || docker rmi -f $(shell docker images -q -f reference=${NAME})
clean_drupal: clean_composer composer_install docker_stop docker_start drupal_install
clean_site: clean_composer composer_install clean_docker base docker_build drupal_install
./docker/bin/drush cr
composer_install:
composer install
docker_build:
docker compose build --no-cache
docker compose up -d
docker_start:
docker compose up -d
docker_stop:
docker compose down
drupal_cs:
mkdir -p html/core/
cp docker/conf/drupal/phpcs.xml html/core/phpcs.xml
cp docker/conf/drupal/phpunit.xml html/core/phpunit.xml
drupal_install:
if [ "$(CI)" ]; then \
docker compose exec -T cli bash /var/www/docker/bin/cli drupal-first-run $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
else \
docker compose exec cli bash /var/www/docker/bin/cli drupal-first-run $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
fi
drupal_init:
if [ "$(CI)" ]; then \
docker compose exec -T cli bash /var/www/docker/bin/cli drupal-init $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
else \
docker compose exec cli bash /var/www/docker/bin/cli drupal-init $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
fi
drupal_migrate:
if [ "$(CI)" ]; then \
docker compose exec -T cli bash /var/www/docker/bin/cli drupal-migrate $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
else \
docker compose exec cli bash /var/www/docker/bin/cli drupal-migrate $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
fi
drupal_perm:
if [ "$(CI)" ]; then \
docker compose exec -T cli bash /var/www/docker/bin/cli drupal-perm $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
else \
docker compose exec cli bash /var/www/docker/bin/cli drupal-perm $(DB_NAME) $(DB_TYPE) $(DB_PORT) $(PROFILE_NAME); \
fi
drush_archive:
./docker/bin/drush archive-dump --destination="/var/www/files_private/drupal$$(date +%Y%m%d_%H%M%S).tgz" \
--generator="Drupal"
lint:
./docker/bin/lint
# http://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
phpcs: drupal_cs
./docker/bin/phpcs --config-set installed_paths /var/www/vendor/drupal/coder/coder_sniffer
./docker/bin/phpcs --standard=/var/www/html/core/phpcs.xml \
--extensions=php,module,inc,install,test,profile,theme \
--report=full \
--colors \
--ignore=/var/www/html/profiles/$(PROFILE_NAME)/modules/custom/wxt_test \
--ignore=*.css \
--ignore=*.txt \
--ignore=*.md \
--ignore=/var/www/html/*/custom/*/*.info.yml \
/var/www/html/modules/contrib/wxt_library \
/var/www/html/themes/contrib/wxt_bootstrap \
/var/www/html/profiles/$(PROFILE_NAME)/modules/custom
./docker/bin/phpcs --standard=/var/www/html/core/phpcs.xml \
--extensions=php,module,inc,install,test,profile,theme \
--report=full \
--colors \
--ignore=*.md \
-l \
/var/www/html/profiles/$(PROFILE_NAME)
phpunit:
./docker/bin/phpunit --colors=always \
-c /var/www/html/core/phpunit.xml \
--testsuite=kernel \
--group=$(PROFILE_NAME)
./docker/bin/phpunit --colors=always \
-c /var/www/html/core/phpunit.xml \
--testsuite=unit \
--group=$(PROFILE_NAME)
release: tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make base'"; false; fi
docker push $(NAME)
@echo "*** Don't forget to create a tag. git tag rel-$(VERSION) && git push origin rel-$(VERSION)"
tag_latest:
docker tag -f $(NAME):$(VERSION) $(NAME):latest
test: phpcs phpunit behat
update: base
git pull origin 8.x
composer update
docker compose build --no-cache
docker compose up -d
.PHONY: \
all \
base \
behat \
build \
clean \
clean_composer \
clean_docker \
clean_site \
composer_install \
docker_build \
drupal_cs \
drupal_install \
drupal_migrate \
drush_archive \
lint \
list \
phpcs \
phpunit \
release \
tag_latest \
test \
update