rework phpstan task to use inotifywait

This commit is contained in:
Andrew Dolgov 2022-07-31 11:13:17 +03:00
parent ff18453205
commit d5c043e846
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
2 changed files with 21 additions and 18 deletions

21
.vscode/tasks.json vendored
View File

@ -3,11 +3,11 @@
"tasks": [
{
"type": "shell",
"label": "phpstan-8.1 (background)",
"label": "phpstan 8.1 (watcher)",
"isBackground": true,
"problemMatcher": {
"fileLocation": ["relative", "${workspaceRoot}"],
"owner": "phpstan-8.1",
"owner": "phpstan-watcher-8.1",
"pattern": {
"regexp": "^/app/(.*?):([0-9\\?]*):(.*)$",
"file": 1,
@ -21,22 +21,7 @@
}
},
"command": "while true; do docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.1:/tmp/phpstan --workdir /app php:8.1-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw || true; echo 'All done'; sleep 30; done",
},
{
"type": "shell",
"label": "phpstan-8.0 (run once)",
"problemMatcher": {
"fileLocation": ["relative", "${workspaceRoot}"],
"owner": "phpstan-8.0",
"pattern": {
"regexp": "^/app/(.*?):([0-9\\?]*):(.*)$",
"file": 1,
"line": 2,
"message": 3
}
},
"command": "docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.0:/tmp/phpstan --workdir /app php:8.0-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw || true",
"command": "${workspaceRoot}/utils/phpstan-watcher.sh",
},
{
"type": "gulp",

18
utils/phpstan-watcher.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/sh
PHP_VERSION="$1"
[ -z "$PHP_VERSION" ] && PHP_VERSION=8.1
echo PHP_VERSION: ${PHP_VERSION}
echo PWD: $(pwd)
while true; do
inotifywait . -e close_write -r -t 300 | grep -q .php && \
(
docker run --rm -v $(pwd):/app -v /tmp/phpstan-8.1:/tmp/phpstan \
--workdir /app php:${PHP_VERSION}-cli php -d memory_limit=-1 ./vendor/bin/phpstan --memory-limit=2G --error-format=raw
echo All done, RC=$?.
)
sleep 1
done