[TOOLS][PHPStan][TESTS][Docker] Rework testing Docker container into a more generic tooling container. Keep services up and run coverage and phpstan as commands, for performance and ease of use
This commit is contained in:
parent
9742a07bae
commit
9d7f43cd28
14
Makefile
14
Makefile
|
@ -24,8 +24,14 @@ psql-shell: .PHONY
|
|||
database-force-schema-update:
|
||||
docker exec -it $(strip $(DIR))_php_1 sh -c "/var/www/social/bin/console doctrine:schema:update --dump-sql --force"
|
||||
|
||||
test: .PHONY
|
||||
cd docker/testing && docker-compose run php; docker-compose down
|
||||
tooling-docker: .PHONY
|
||||
@cd docker/tooling && docker-compose up -d > /dev/null 2>&1
|
||||
|
||||
stop-test: .PHONY
|
||||
cd docker/testing && docker-compose down
|
||||
test: tooling-docker
|
||||
docker exec tooling_php_1 /var/tooling/coverage.sh
|
||||
|
||||
phpstan: tooling-docker
|
||||
docker exec tooling_php_1 /var/tooling/phpstan.sh
|
||||
|
||||
stop-tooling: .PHONY
|
||||
cd docker/tooling && docker-compose down
|
||||
|
|
|
@ -9,11 +9,9 @@ if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_CS_FIX?}") 2>/dev/null);
|
|||
echo "Running php-cs-fixer on edited files"
|
||||
for staged in ${staged_files}; do
|
||||
# work only with existing files
|
||||
if [ -f "${staged}" ] && expr "${staged}" : '^.*\.php$'
|
||||
then
|
||||
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 fix "${staged}"
|
||||
then
|
||||
if "${root}/bin/php-cs-fixer" -q fix "${staged}"; then
|
||||
git add "${staged}" # execute git add directly
|
||||
fi
|
||||
fi
|
||||
|
@ -29,7 +27,7 @@ fi
|
|||
|
||||
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_PHPSTAN?}") 2>/dev/null); then
|
||||
echo "Running phpstan"
|
||||
"${root}/vendor/bin/phpstan" --memory-limit=2G analyse src tests components plugins
|
||||
make phpstan
|
||||
fi
|
||||
|
||||
# Only commit if there wasn't an error
|
||||
|
|
|
@ -55,6 +55,7 @@ services:
|
|||
- ./docker/social/install.sh:/var/entrypoint.d/social_install.sh
|
||||
# Main files
|
||||
- .:/var/www/social
|
||||
- /var/www/social/docker
|
||||
env_file:
|
||||
- ./docker/social/social.env
|
||||
- ./docker/db/db.env
|
||||
|
|
|
@ -32,6 +32,7 @@ cat <<EOF
|
|||
- ./docker/social/install.sh:/var/entrypoint.d/social_install.sh
|
||||
# Main files
|
||||
- .:/var/www/social
|
||||
- /var/www/social/docker # exclude docker folder
|
||||
env_file:
|
||||
- ./docker/social/social.env
|
||||
- ./docker/db/db.env
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd /var/www/social || exit 65
|
||||
|
||||
yes yes | php bin/console doctrine:fixtures:load || exit 65
|
||||
|
||||
if runuser -u www-data -- vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report; then
|
||||
exit 64
|
||||
else
|
||||
exit 65
|
||||
fi
|
7
docker/tooling/coverage.sh
Executable file
7
docker/tooling/coverage.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd /var/www/social || exit 1
|
||||
|
||||
yes yes | php bin/console doctrine:fixtures:load || exit 1
|
||||
|
||||
runuser -u www-data -- vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report
|
|
@ -11,9 +11,11 @@ services:
|
|||
- ../php/entrypoint.sh:/entrypoint.sh
|
||||
- ../db/wait_for_db.sh:/wait_for_db.sh
|
||||
- ../social/install.sh:/var/entrypoint.d/0_social_install.sh
|
||||
- ./coverage.sh:/var/entrypoint.d/8_coverage.sh
|
||||
- ./coverage.sh:/var/tooling/coverage.sh
|
||||
- ./phpstan.sh:/var/tooling/phpstan.sh
|
||||
# Main files
|
||||
- ../../:/var/www/social
|
||||
- /var/www/social/docker # exclude docker folder
|
||||
- ./xdebug.ini:/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||
env_file:
|
||||
- social.env
|
5
docker/tooling/phpstan.sh
Executable file
5
docker/tooling/phpstan.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
cd /var/www/social || exit 1
|
||||
|
||||
vendor/bin/phpstan --ansi --no-interaction --memory-limit=2G analyse src tests components plugins
|
Loading…
Reference in New Issue
Block a user