mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
85 lines
3.1 KiB
YAML
85 lines
3.1 KiB
YAML
# evennia/setup-database
|
|
|
|
# Use this action in a workflow for when you need to do initialization of database services
|
|
# (such as with PostgreSQL and MySQL) before you initiate unit tests that will employ that
|
|
# database service.
|
|
|
|
# NOTE: This action was intended for use with the core Evennia workflows ONLY.
|
|
|
|
name: Set up Evennia database service
|
|
author: dvoraen
|
|
description: "Activates the database server for the passed in service and ensures it's ready for use."
|
|
|
|
inputs:
|
|
database:
|
|
description: "Database service being initialized."
|
|
required: true
|
|
|
|
runs:
|
|
using: "composite"
|
|
|
|
steps:
|
|
- name: Wait for PostgreSQL to be ready
|
|
if: ${{ inputs.database == 'postgresql' }}
|
|
run: |
|
|
# Wait for PostgreSQL service container to be healthy
|
|
until pg_isready -h localhost -U evennia -d evennia; do
|
|
sleep 1
|
|
echo -n .
|
|
done
|
|
echo "PostgreSQL is ready"
|
|
shell: bash
|
|
env:
|
|
PGPASSWORD: password
|
|
|
|
- name: Wait for MySQL to be ready
|
|
if: ${{ inputs.database == 'mysql' }}
|
|
run: |
|
|
# Wait for MySQL service container to be healthy
|
|
until mysqladmin ping -h 127.0.0.1 -u root -proot_password --silent; do
|
|
sleep 1
|
|
echo -n .
|
|
done
|
|
echo "MySQL is ready"
|
|
shell: bash
|
|
|
|
- name: Set up MySQL Privileges and Character Set
|
|
if: ${{ inputs.database == 'mysql' }}
|
|
run: |
|
|
# Set global character set and collation
|
|
mysql -u root -proot_password -h 127.0.0.1 mysql <<EOF
|
|
SET GLOBAL character_set_server = 'utf8mb4';
|
|
SET GLOBAL collation_server = 'utf8mb4_unicode_ci';
|
|
EOF
|
|
# Set InnoDB settings for utf8mb4 support (allows longer keys)
|
|
# Note: innodb_large_prefix is ON by default in MySQL 8.0
|
|
# Ensure default row format is DYNAMIC (default in MySQL 8.0, but explicit for clarity)
|
|
mysql -u root -proot_password -h 127.0.0.1 mysql <<EOF
|
|
SET GLOBAL innodb_default_row_format = 'DYNAMIC';
|
|
EOF
|
|
# Ensure user exists and has proper privileges
|
|
mysql -u root -proot_password -h 127.0.0.1 mysql <<EOF
|
|
CREATE USER IF NOT EXISTS 'evennia'@'%' IDENTIFIED BY 'password';
|
|
GRANT ALL PRIVILEGES ON \`evennia%\`.* TO 'evennia'@'%';
|
|
GRANT PROCESS ON *.* TO 'evennia'@'%';
|
|
FLUSH PRIVILEGES;
|
|
EOF
|
|
# Set database character set
|
|
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
|
ALTER DATABASE evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
EOF
|
|
# Verify settings are correct
|
|
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
|
SELECT @@innodb_default_row_format, @@character_set_server, @@collation_server;
|
|
EOF
|
|
shell: bash
|
|
|
|
# get logs from db start
|
|
- name: Database container logs
|
|
if: ${{ inputs.database == 'postgresql' || inputs.database == 'mysql' }}
|
|
uses: jwalton/gh-docker-logs@v2
|
|
|
|
- name: Check running containers
|
|
if: ${{ inputs.database == 'postgresql' || inputs.database == 'mysql' }}
|
|
run: docker ps -a
|
|
shell: bash
|