diff --git a/tools/git-hooks/pre-commit b/tools/git-hooks/pre-commit index 003df608e1afd2484f1f0f7f1b0a511e4b9e9e63..e4148de69ef45023c8bb42c91996d353501c0947 100755 --- a/tools/git-hooks/pre-commit +++ b/tools/git-hooks/pre-commit @@ -10,15 +10,6 @@ fi composer="$docker composer" npm="$docker npm" -echo -e "\n ${BOLD} Starting Unit and Functional Tests...\n ${NORMAL}" -$composer tests -if [ $? != 0 ]; then - echo -e "\n ${REDBOLD} Unit tests failed \n ${NORMAL}" - exit 1; -else - echo -e "\n ${GREENBOLD} Unit and functional tests passed successfully! ${NORMAL} \n" -fi - echo -e "\n ${BOLD} Starting PHP_CodeSniffer... \n ${NORMAL}" $composer phpcs if [ $? != 0 ]; then @@ -34,16 +25,41 @@ if [ $? != 0 ]; then echo -e "\n ${REDBOLD} PHPStan verification failed \n ${NORMAL}" exit 1; else - echo -e "\n ${GREENBOLD} Your code passed static analysis successfully! \n - \n Committing your changes now... \n ${NORMAL}" + echo -e "\n ${GREENBOLD} Your code passed static analysis successfully! \n${NORMAL}" fi -echo -e "\n ${BOLD} Starting ESLint... \n ${NORMAL}" -$npm run lint +echo -e "\n ${BOLD} Starting prepare database for tests... \n ${NORMAL}" +$docker php bin/console doctrine:database:drop --if-exists --force --no-interaction --env=test && \ +$docker php bin/console doctrine:database:create --if-not-exists --no-interaction --env=test && \ +$docker php bin/console doctrine:migration:migrate --all-or-nothing --no-interaction --env=test && \ +#$docker php bin/console doctrine:schema:validate --env=test && \ +$docker php bin/console doctrine:fixture:load --no-interaction --env=test + if [ $? != 0 ]; then - echo -e "\n ${REDBOLD} ESLint verification failed \n ${NORMAL}" + echo -e "\n ${REDBOLD} Database preparation for tests failed \n ${NORMAL}" + exit 1; +else + echo -e "\n ${GREENBOLD} Database preparation for tests passed successfully \n ${NORMAL}" +fi + +echo -e "\n ${BOLD} Starting Unit and Functional Tests...\n ${NORMAL}" +$composer tests +if [ $? != 0 ]; then + echo -e "\n ${REDBOLD} Unit tests failed \n ${NORMAL}" exit 1; else - echo -e "\n ${GREENBOLD} Your code passed JS linter successfully! \n - \n Committing your changes now... \n ${NORMAL}" + echo -e "\n ${GREENBOLD} Unit and functional tests passed successfully! ${NORMAL} \n" fi + + +#echo -e "\n ${BOLD} Starting ESLint... \n ${NORMAL}" +#$npm run lint +#if [ $? != 0 ]; then +# echo -e "\n ${REDBOLD} ESLint verification failed \n ${NORMAL}" +# exit 1; +#else +# echo -e "\n ${GREENBOLD} Your code passed JS linter successfully! \n +# \n Committing your changes now... \n ${NORMAL}" +#fi + +echo -e "\n${GREENBOLD}Committing your changes now... \n ${NORMAL}"