From d766f255ef8ea3874f4887d1a7b7a0ffdb42f7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 7 May 2023 02:38:54 +0200 Subject: [PATCH] Let job fail, when an error occurs during the legacy test script --- .../legacy_import/test_legacy_import.sh | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/assets/legacy_import/test_legacy_import.sh b/.github/assets/legacy_import/test_legacy_import.sh index ffddd408..9ac76690 100644 --- a/.github/assets/legacy_import/test_legacy_import.sh +++ b/.github/assets/legacy_import/test_legacy_import.sh @@ -24,14 +24,31 @@ SQL_FILES_TO_TEST=("db_minimal.sql" "db_jbtronics.sql") DB_NAME="test" +DB_USER="root" +DB_PASSWORD="root" # Iterate over all given SQL files and import them into the mysql database with the given name, drop the database if it already exists before for SQL_FILE in "${SQL_FILES_TO_TEST[@]}" do echo "Testing for $SQL_FILE" - mysql -u root -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;" + mysql -u $DB_USER --password=$DB_PASSWORD -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;" + # If the last command failed, exit the script + if [ $? -ne 0 ]; then + echo "Failed to create database $DB_NAME" + exit 1 + fi # Import the SQL file into the database. The file pathes are relative to the current script location - mysql -u root $DB_NAME < .github/assets/legacy_import/$SQL_FILE + mysql -u DB_USER --password=$DB_PASSWORD $DB_NAME < .github/assets/legacy_import/$SQL_FILE + # If the last command failed, exit the script + if [ $? -ne 0 ]; then + echo "Failed to import $SQL_FILE into database $DB_NAME" + exit 1 + fi # Run doctrine migrations, this will migrate the database to the current version. This process should not fail php bin/console doctrine:migrations:migrate -n + # If the last command failed, exit the script + if [ $? -ne 0 ]; then + echo "Failed to migrate database $DB_NAME" + exit 1 + fi done \ No newline at end of file