diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 36ec8d8..495d60d 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -10,6 +10,16 @@ jobs: build: runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.3 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: activmind_test + MYSQL_USER: root + MYSQL_PASSWORD: root + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: max-parallel: 4 matrix: @@ -33,6 +43,9 @@ jobs: # python -c "import mysql.connector; conn = mysql.connector.connect(user='root', password='root', host='localhost', port='3306', database='activmind'); cursor = conn.cursor(); cursor.execute('CREATE DATABASE IF NOT EXISTS activmind')" # python manage.py makemigrations # python manage.py migrate + - name: Run database migrations + run: | + python manage.py migrate --database=test - name: Run Tests working-directory: ./activmindback run: python manage.py test diff --git a/activmindback/activmindback/settings.py b/activmindback/activmindback/settings.py index a8c6790..e14320d 100644 --- a/activmindback/activmindback/settings.py +++ b/activmindback/activmindback/settings.py @@ -97,6 +97,18 @@ 'init_command': "SET default_storage_engine=INNODB", 'collation': 'utf8mb4_general_ci', }, + }, + 'test': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'activmind_test', + 'HOST': 'mysql', + 'USER': 'root', + 'PASSWORD': 'root', + 'OPTIONS': { + 'charset': 'utf8mb4', + 'init_command': "SET default_storage_engine=INNODB", + 'collation': 'utf8mb4_general_ci', + }, } }