-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (107 loc) · 4.17 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
PEGJS_TAG="node:8-alpine"
PHP_80="floip-php:8.0-alpine"
PHP_81="floip-php:8.1-alpine"
DOCKER_RUN=docker run $(DOCKER_OPTS) -v `pwd`:/src -u `id -u` -w '/src' -e COMPOSER_HOME=.composer
PEGJS=$(DOCKER_RUN) $(PEGJS_TAG) npx pegjs
PARSER_NAME=Parser
PARSER_SOURCE=src/pegjs/floip.pegjs
PARSER_CLASS=BaseExpressionParser
PHP_OUT=dist/$(PARSER_CLASS).php
PHPEGJS_OPTIONS={"cache" : "true", "phpegjs":{"parserNamespace": "Viamo", "parserClassName": "$(PARSER_CLASS)"}}
TSPEGJS_OPTIONS={"cache" : "true", "tspegjs":{}}
JS_OUT=dist/$(PARSER_NAME).js
TS_OUT=src/ts/$(PARSER_NAME).ts
USE_DOCKER=true
ENV=local
DOCKER_OPTS=--rm
.PHONY: clean \
default \
parsers \
parse-php \
parse-js \
parse-ts \
docker-php \
testall \
prepare-for-test \
docker-php-80 \
docker-php-81
default: parsers
node_modules: package.json
ifeq ($(USE_DOCKER),true)
docker run --rm -v `pwd`:`pwd` -w `pwd` -u `id -u` $(PEGJS_TAG) npm install
else
npm install
endif
$(PHP_OUT): node_modules $(PARSER_SOURCE)
ifeq ($(USE_DOCKER),true)
$(PEGJS) --plugin phpegjs -o $(PHP_OUT) --extra-options '$(PHPEGJS_OPTIONS)' $(PARSER_SOURCE)
else
npx pegjs --plugin phpegjs -o $(PHP_OUT) --extra-options '$(PHPEGJS_OPTIONS)' $(PARSER_SOURCE)
endif
$(TS_OUT): node_modules $(PARSER_SOURCE)
ifeq ($(USE_DOCKER),true)
$(PEGJS) --plugin ts-pegjs -o $(TS_OUT) --extra-options '$(TSPEGJS_OPTIONS)' $(PARSER_SOURCE)
$(DOCKER_RUN) $(PEGJS_TAG) npm run build
else
npx pegjs --plugin ts-pegjs -o $(TS_OUT) --extra-options '$(TSPEGJS_OPTIONS)' $(PARSER_SOURCE)
npm run build
endif
parse-php: $(PHP_OUT)
parse-js: $(JS_OUT)
parse-ts: $(TS_OUT)
parsers: parse-php parse-ts
vendor: composer.json
ifeq ($(USE_DOCKER),true)
$(DOCKER_RUN) $(PHP_81) composer install --ignore-platform-reqs
else
composer install
endif
docker-php-80:
docker build -t $(PHP_80) .docker/php/8.0
docker-php-81:
docker build -t $(PHP_81) .docker/php/8.1
prepare-for-test: docker-php
# since we are testing against different environments we must be fresh
touch composer.lock
rm -rf vendor
.ci/8.0/composerL6.lock: composer.json
make prepare-for-test
cp composer.json .ci/8.0/composerL6.json
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL6.json $(PHP_80) php -d memory_limit=-1 /usr/bin/composer require --dev "orchestra/testbench:~4.0" --no-suggest
.ci/8.0/composerL7.lock: composer.json
make prepare-for-test
cp composer.json .ci/8.0/composerL7.json
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL7.json $(PHP_80) php -d memory_limit=-1 /usr/bin/composer require --dev "orchestra/testbench:~5.0" --no-suggest
.ci/8.0/composerL8.lock: composer.json
make prepare-for-test
cp composer.json .ci/8.0/composerL8.json
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL8.json $(PHP_80) php -d memory_limit=-1 /usr/bin/composer require --dev "orchestra/testbench:~6.0" --no-suggest
.ci/8.1/composerL8.lock: composer.json
make prepare-for-test
cp composer.json .ci/8.1/composerL8.json
$(DOCKER_RUN) -e COMPOSER=.ci/8.1/composerL8.json $(PHP_81) php -d memory_limit=-1 /usr/bin/composer require --dev "orchestra/testbench:~6.0" --no-suggest
test80: prepare-for-test docker-php-80 .ci/8.0/composerL6.lock .ci/8.0/composerL7.lock .ci/8.0/composerL8.lock
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL6.json $(PHP_80) composer install --no-suggest
$(DOCKER_RUN) $(PHP_80) ./vendor/bin/phpunit
rm .ci/8.0/composer*.lock
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL7.json $(PHP_80) composer install --no-suggest
$(DOCKER_RUN) $(PHP_80) ./vendor/bin/phpunit
rm .ci/8.0/composer*.lock
$(DOCKER_RUN) -e COMPOSER=.ci/8.0/composerL8.json $(PHP_80) composer install --no-suggest
$(DOCKER_RUN) $(PHP_80) ./vendor/bin/phpunit
rm .ci/8.0/composer*.lock
test81: prepare-for-test docker-php-81 .ci/8.1/composerL8.lock
$(DOCKER_RUN) -e COMPOSER=.ci/8.1/composerL8.json $(PHP_81) composer install --no-suggest
$(DOCKER_RUN) $(PHP_81) ./vendor/bin/phpunit
rm .ci/8.1/composer*.lock
test:
make test80 && make test81
clean:
rm -rf node_modules
rm -rf vendor
rm -rf .composer
docker rmi $(PHP_80) 2>/dev/null || true
docker rmi $(PHP_81) 2>/dev/null || true
rector-81:
$(DOCKER_RUN) -e COMPOSER=.ci/8.1/composerL8.json $(PHP_81) composer install --no-suggest
$(DOCKER_RUN) $(PHP_81) vendor/bin/rector process