From e933c09cdf516f22571b0589b7138af1a7f6992f Mon Sep 17 00:00:00 2001
From: Camille Simiand <camille.simiand@tetras-libre.fr>
Date: Mon, 10 Jan 2022 11:59:29 +0100
Subject: [PATCH] Fix pre-commit hook scripts order and remove ESLint for now

---
 tools/git-hooks/pre-commit | 48 +++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 16 deletions(-)

diff --git a/tools/git-hooks/pre-commit b/tools/git-hooks/pre-commit
index 003df60..e4148de 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}"
-- 
GitLab