-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
172 lines (144 loc) · 5.53 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
COMMIT := $(shell git rev-parse --short=8 HEAD)
BASE_IMAGE := bmltenabled/bmlt-root-server-base
BASE_IMAGE_TAG := 8.1
BASE_IMAGE_BUILD_TAG := $(COMMIT)-$(shell date +%s)
CROUTON_JS := src/public/client_interface/html/croutonjs/crouton.js
LEGACY_STATIC_FILES := src/public/local_server/styles.css
VENDOR_AUTOLOAD := src/vendor/autoload.php
NODE_MODULES := src/node_modules/.package-lock.json
FRONTEND := src/public/build/manifest.json
ZIP_FILE := build/bmlt-root-server.zip
EXTRA_DOCKER_COMPOSE_ARGS :=
ifeq ($(CI)x, x)
DOCKERFILE := Dockerfile-debug
IMAGE := rootserver
TAG := local
COMPOSER_ARGS :=
NPM_FLAG := install
COMPOSER_PREFIX := docker run --pull=always -t --rm -v '$(shell pwd)':/code -w /code $(BASE_IMAGE):$(BASE_IMAGE_TAG)
LINT_PREFIX := docker run -t --rm -v '$(shell pwd)':/code -w /code/src $(IMAGE):$(TAG)
TEST_PREFIX := docker run -e XDEBUG_MODE=coverage,debug -t --rm -v '$(shell pwd)/src:/var/www/html/main_server' -v '$(shell pwd)/docker/test-auto-config.inc.php:/var/www/html/auto-config.inc.php' -w /var/www/html/main_server --network host $(IMAGE):$(TAG)
ifneq (,$(wildcard docker/docker-compose.dev.yml))
EXTRA_DOCKER_COMPOSE_ARGS := -f docker/docker-compose.dev.yml
endif
else
DOCKERFILE := Dockerfile
IMAGE := bmltenabled/bmlt-root-server
TAG := 3.0.0-$(COMMIT)
ifeq ($(strip $(GITHUB_REF_NAME)),main)
TAG := latest
endif
ifeq ($(strip $(GITHUB_REF_NAME)),unstable)
TAG := unstable
endif
COMPOSER_ARGS := --classmap-authoritative
NPM_FLAG := ci
ifeq ($(DEV)x, x)
COMPOSER_ARGS := $(COMPOSER_ARGS) --no-dev
endif
COMPOSER_PREFIX :=
LINT_PREFIX := cd src &&
TEST_PREFIX := cd src &&
endif
help: ## Print the help documentation
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
$(VENDOR_AUTOLOAD):
$(COMPOSER_PREFIX) composer install --working-dir=src $(COMPOSER_ARGS)
$(CROUTON_JS):
curl -sLO https://github.com/bmlt-enabled/crouton/releases/latest/download/croutonjs.zip
mkdir -p src/public/client_interface/html/croutonjs
unzip croutonjs.zip -d src/public/client_interface/html/croutonjs
rm -f croutonjs.zip
rm -f src/public/client_interface/html/croutonjs/*.html
rm -f src/public/client_interface/html/croutonjs/*.json
rm -rf src/public/client_interface/html/croutonjs/examples
$(NODE_MODULES):
cd src && npm $(NPM_FLAG)
$(FRONTEND): $(NODE_MODULES)
cd src && npm run build
$(LEGACY_STATIC_FILES):
rsync -a -m \
--include='**/*.js' \
--include='**/*.css' \
--include='**/*.png' \
--include='**/*.svg' \
--include='**/*.ttf' \
--include='**/*.woff' \
--include='**/*.woff2' \
--include='**/*.eot' \
--include='**/*.json' \
--include='**/*.gif' \
--include='*/' \
--exclude='*' \
src/legacy/ src/public
$(ZIP_FILE): $(VENDOR_AUTOLOAD) $(FRONTEND) $(CROUTON_JS) $(LEGACY_STATIC_FILES)
mkdir -p build
cp -r src build/main_server
cd build && zip -r $(shell basename $(ZIP_FILE)) main_server -x main_server/node_modules/\*
rm -rf build/main_server
.PHONY: composer
composer: $(VENDOR_AUTOLOAD) ## Runs composer install
.PHONY: npm
npm: $(NODE_MODULES) ## Runs npm install
.PHONY: crouton
crouton: $(CROUTON_JS) ## Installs crouton
.PHONY: frontend
frontend: $(FRONTEND) ## Builds the frontend
.PHONY: zip
zip: $(ZIP_FILE) ## Builds zip file
.PHONY: docker
docker: zip ## Builds Docker Image
docker build --pull -f docker/$(DOCKERFILE) . -t $(IMAGE):$(TAG)
.PHONY: docker-push
docker-push: ## Pushes docker image to Dockerhub
docker push $(IMAGE):$(TAG)
.PHONY: dev
dev: zip ## Docker Compose Up
docker-compose -f docker/docker-compose.yml $(EXTRA_DOCKER_COMPOSE_ARGS) up --build
.PHONY: test
test: ## Runs PHP Tests
$(TEST_PREFIX) php artisan test --parallel --recreate-databases --coverage-clover coverage.xml
# $(TEST_PREFIX) vendor/bin/phpunit tests/Feature/Admin/ServiceBodyPartialUpdateTest.php
# $(TEST_PREFIX) vendor/bin/phpunit --filter testUpdateServiceBodyAsServiceBodyAdmin tests/Feature/Admin/ServiceBodyPartialUpdateTest.php
.PHONY: test-js
test-js: ## Runs JavaScript tests
cd src && npm run test
.PHONY: coverage
coverage: ## Generates HTML Coverage Report
$(TEST_PREFIX) vendor/phpunit/phpunit/phpunit --coverage-html tests/reports/coverage
.PHONY: coverage-serve
coverage-serve: ## Serves HTML Coverage Report
python3 -m http.server 8100 --directory src/tests/reports/coverage
.PHONY: generate-api-json
generate-api-json: ## Generates Open API JSON
$(LINT_PREFIX) php artisan l5-swagger:generate
.PHONY: lint
lint: ## PHP Lint
$(LINT_PREFIX) vendor/squizlabs/php_codesniffer/bin/phpcs
.PHONY: lint-fix
lint-fix: ## PHP Lint Fix
$(LINT_PREFIX) vendor/squizlabs/php_codesniffer/bin/phpcbf
.PHONY: lint-js
lint-js: ## JavaScript Lint
cd src && npm run lint
.PHONY: phpstan
phpstan: ## PHP Larastan Code Analysis
$(LINT_PREFIX) vendor/bin/phpstan analyse -c .phpstan.neon --memory-limit=2G
.PHONY: docker-publish-base
docker-publish-base: ## Builds Base Docker Image
docker buildx build --platform linux/amd64,linux/arm64/v8 -f docker/Dockerfile-base docker/ -t $(BASE_IMAGE):$(BASE_IMAGE_TAG) --push
.PHONY: mysql
mysql: ## Runs mysql cli in mysql container
docker exec -it docker-db-1 mariadb -u root -prootserver rootserver
.PHONY: bash
bash: ## Runs bash shell in apache container
docker exec -it -w /var/www/html/main_server docker-bmlt-1 bash
.PHONY: clean
clean: ## Clean build
rm -rf src/public/build
rm -rf src/public/client_interface
rm -rf src/public/local_server
rm -rf src/public/semantic
rm -rf src/node_modules
rm -rf src/vendor
rm -rf build