CI: Working to get MySQL server collaborate with CI env
This commit is contained in:
parent
0f0088cd9b
commit
bf138d8a6f
4 changed files with 40 additions and 6 deletions
34
.github/actions/run-tests/action.yml
vendored
34
.github/actions/run-tests/action.yml
vendored
|
|
@ -64,7 +64,41 @@ runs:
|
||||||
evennia --init testing_mygame
|
evennia --init testing_mygame
|
||||||
cp .github/workflows/${{ inputs.testing-db }}_settings.py testing_mygame/server/conf/settings.py
|
cp .github/workflows/${{ inputs.testing-db }}_settings.py testing_mygame/server/conf/settings.py
|
||||||
cd testing_mygame
|
cd testing_mygame
|
||||||
|
# For MySQL, ensure default row format is set before migrations
|
||||||
|
if [ "${{ inputs.testing-db }}" == "mysql" ]; then
|
||||||
|
python -c "
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.conf.settings')
|
||||||
|
django.setup()
|
||||||
|
from django.db import connection
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute('SET GLOBAL innodb_default_row_format = \"DYNAMIC\"')
|
||||||
|
cursor.execute('SELECT @@innodb_default_row_format')
|
||||||
|
result = cursor.fetchone()
|
||||||
|
print(f'MySQL default row format: {result[0]}')
|
||||||
|
"
|
||||||
|
fi
|
||||||
evennia migrate
|
evennia migrate
|
||||||
|
# For MySQL, ensure all existing tables use DYNAMIC row format
|
||||||
|
if [ "${{ inputs.testing-db }}" == "mysql" ]; then
|
||||||
|
python -c "
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.conf.settings')
|
||||||
|
django.setup()
|
||||||
|
from django.db import connection
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(\"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND ENGINE = 'InnoDB'\")
|
||||||
|
tables = [row[0] for row in cursor.fetchall()]
|
||||||
|
for table in tables:
|
||||||
|
try:
|
||||||
|
cursor.execute(f'ALTER TABLE \`{table}\` ROW_FORMAT=DYNAMIC')
|
||||||
|
print(f'Set ROW_FORMAT=DYNAMIC for table {table}')
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Warning: Could not set ROW_FORMAT for {table}: {e}')
|
||||||
|
"
|
||||||
|
fi
|
||||||
evennia collectstatic --noinput
|
evennia collectstatic --noinput
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|
|
||||||
6
.github/actions/setup-database/action.yml
vendored
6
.github/actions/setup-database/action.yml
vendored
|
|
@ -64,13 +64,13 @@ runs:
|
||||||
GRANT PROCESS ON *.* TO 'evennia'@'%';
|
GRANT PROCESS ON *.* TO 'evennia'@'%';
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
EOF
|
EOF
|
||||||
# Set database character set and default row format
|
# Set database character set
|
||||||
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
||||||
ALTER DATABASE evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
ALTER DATABASE evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
EOF
|
EOF
|
||||||
# Set default row format for new tables (needed for long keys with utf8mb4)
|
# Verify settings are correct
|
||||||
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
||||||
SET GLOBAL default_storage_engine = 'InnoDB';
|
SELECT @@innodb_default_row_format, @@character_set_server, @@collation_server;
|
||||||
EOF
|
EOF
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ jobs:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:13
|
image: postgres:14
|
||||||
env:
|
env:
|
||||||
POSTGRES_DB: evennia
|
POSTGRES_DB: evennia
|
||||||
POSTGRES_USER: evennia
|
POSTGRES_USER: evennia
|
||||||
|
|
|
||||||
4
.github/workflows/mysql_settings.py
vendored
4
.github/workflows/mysql_settings.py
vendored
|
|
@ -48,13 +48,13 @@ DATABASES = {
|
||||||
"PORT": "", # use default port
|
"PORT": "", # use default port
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"charset": "utf8mb4",
|
"charset": "utf8mb4",
|
||||||
"init_command": "SET collation_connection=utf8mb4_unicode_ci, sql_mode='STRICT_TRANS_TABLES'",
|
"init_command": "SET collation_connection=utf8mb4_unicode_ci, sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1",
|
||||||
},
|
},
|
||||||
"TEST": {
|
"TEST": {
|
||||||
"NAME": "evennia",
|
"NAME": "evennia",
|
||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"charset": "utf8mb4",
|
"charset": "utf8mb4",
|
||||||
"init_command": "SET collation_connection=utf8mb4_unicode_ci, sql_mode='STRICT_TRANS_TABLES'",
|
"init_command": "SET collation_connection=utf8mb4_unicode_ci, sql_mode='STRICT_TRANS_TABLES', innodb_strict_mode=1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue