1
1
# set user to "root" to run commands as root in docker
2
2
USER =$$(whoami )
3
3
# The docker command to execute commands directly in docker
4
- DOCKER =docker-compose exec -T --user="$(USER ) " backend-php
4
+ DOCKER =docker-compose exec -T -w /app - -user="$(USER ) " backend-php
5
5
# The PHP binary to use, you may add arguments to PHP here
6
6
PHP =php
7
7
# directories writeable by webserver
@@ -20,9 +20,10 @@ default:
20
20
@echo " make stop-docker stop docker environment"
21
21
@echo " make cli run bash in docker environment"
22
22
@echo " make bash alias for 'make cli'"
23
+ @echo " make lint Run OpenAPI linter"
23
24
24
25
25
- .PHONY : start stop start-docker stop-docker clean test bash cli
26
+ .PHONY : start stop start-docker stop-docker clean test bash cli lint lint-php lint-js
26
27
27
28
28
29
# # PHP runtime ##
@@ -81,6 +82,19 @@ backend/config/cookie-validation.key:
81
82
test -s $@ || php -r ' echo bin2hex(random_bytes(20));' > $@
82
83
83
84
85
+ # Lint API spec
86
+
87
+ lint : lint-php lint-js
88
+
89
+ lint-php :
90
+ $(DOCKER ) ./vendor/bin/php-openapi validate openapi/schema.yaml
91
+
92
+ lint-js : node_modules/.bin/spectral
93
+ docker-compose run -T --no-deps --rm --user=" $$ (id -u)" -e FORCE_COLOR=1 -w /app nodejs ./node_modules/.bin/spectral lint openapi/schema.yaml -f stylish --ruleset .spectral.yml
94
+
95
+ node_modules/.bin/spectral : package.json
96
+ docker-compose run -T --no-deps --rm --user=" $$ (id -u)" -e FORCE_COLOR=1 -w /app nodejs npm install
97
+
84
98
# # Docker Runtime Tests ##
85
99
86
100
test : tests/_data/dump.sql
0 commit comments