[TOOLS] Make PHP-CS-Fixer and PHP-Doc-check run inside the tooling container
This commit is contained in:
parent
af3d278fde
commit
6ada5e60d2
7
Makefile
7
Makefile
@ -45,8 +45,11 @@ accessibility: .PHONY
|
||||
test: tooling-docker
|
||||
docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh $(call args,'')
|
||||
|
||||
doc-check:
|
||||
bin/php-doc-check src components plugins
|
||||
cs-fixer: tooling-docker
|
||||
@bin/php-cs-fixer $(call args,'')
|
||||
|
||||
doc-check: tooling-docker
|
||||
bin/php-doc-check
|
||||
|
||||
phpstan: tooling-docker
|
||||
bin/phpstan
|
||||
|
@ -1 +0,0 @@
|
||||
../vendor/bin/php-cs-fixer
|
10
bin/php-cs-fixer
Executable file
10
bin/php-cs-fixer
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
. bin/translate_container_name.sh
|
||||
|
||||
if [ "${#}" -eq 1 ]; then
|
||||
docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -q -n --config=".php-cs-fixer.php" fix "${1}"
|
||||
else
|
||||
echo running without specific files?
|
||||
docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -n --config=".php-cs-fixer.php" fix
|
||||
fi
|
@ -1 +0,0 @@
|
||||
../vendor/bin/php-doc-check
|
5
bin/php-doc-check
Executable file
5
bin/php-doc-check
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
. bin/translate_container_name.sh
|
||||
|
||||
docker exec -it "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-doc-check src components plugins
|
@ -1,11 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
translate_container_name () {
|
||||
if docker container inspect "$1" > /dev/null 2>&1; then
|
||||
echo "$1"
|
||||
else
|
||||
echo "$1" | sed 'y/_/-/'
|
||||
fi
|
||||
}
|
||||
. bin/translate_container_name.sh
|
||||
|
||||
docker exec "$(translate_container_name tooling_php_1)" /var/tooling/phpstan.sh "$@"
|
||||
|
@ -7,21 +7,27 @@ staged_files="$(git status --porcelain | sed -rn "s/^[^ ][ ] (.*)/\1/p")"
|
||||
|
||||
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_CS_FIX?}") 2>/dev/null); then
|
||||
echo "Running php-cs-fixer on edited files"
|
||||
files=""
|
||||
for staged in ${staged_files}; do
|
||||
# work only with existing files
|
||||
if [ -f "${staged}" ] && expr "${staged}" : '^.*\.php$' > /dev/null; then
|
||||
# use php-cs-fixer and get flag of correction
|
||||
if "${root}/bin/php-cs-fixer" -q --config="${root}/.php-cs-fixer.php" fix "${staged}"; then
|
||||
git add "${staged}" # execute git add directly
|
||||
fi
|
||||
files="${staged} ${files}"
|
||||
fi
|
||||
done
|
||||
if [ -n "${files}" ]; then
|
||||
prev="${PWD}"
|
||||
cd "${root}" && make cs-fixer "${files}" || exit 1
|
||||
cd "${prev}" || exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_DOC_CHECK?}") 2>/dev/null); then
|
||||
echo "Running php-doc-checker"
|
||||
if echo "${staged_files}" | grep -F ".php"; then
|
||||
"${root}/bin/php-doc-check" src plugins components
|
||||
if echo "${staged_files}" | grep -F ".php" > /dev/null 2>&1; then
|
||||
prev="${PWD}"
|
||||
cd "${root}" && make doc-check < /dev/tty || exit 1
|
||||
cd "${prev}" || exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
9
bin/translate_container_name.sh
Executable file
9
bin/translate_container_name.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
translate_container_name () {
|
||||
if docker container inspect "$1" > /dev/null 2>&1; then
|
||||
echo "$1"
|
||||
else
|
||||
echo "$1" | sed 'y/_/-/'
|
||||
fi
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
cd /var/www/social || exit 1
|
||||
|
||||
|
||||
ARGS=$(echo "$*" | sed 's#\(/[^/]\+\)*/phpstan\.neon#phpstan.neon#') # Remove absolute path to config file
|
||||
|
||||
rm -rf /var/www/social/var/cache/*
|
||||
|
Loading…
Reference in New Issue
Block a user