Skip to content

Commit

Permalink
Add MySQL service and database migration for test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
FeloxleF committed Mar 16, 2024
1 parent 777847d commit eb3745f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
12 changes: 12 additions & 0 deletions activmindback/activmindback/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
}
}

Expand Down

0 comments on commit eb3745f

Please sign in to comment.