CI: Using an action for mysql setup instead of a docker image
This commit is contained in:
parent
706fb4cd46
commit
f369081270
3 changed files with 22 additions and 42 deletions
24
.github/actions/setup-database/action.yml
vendored
24
.github/actions/setup-database/action.yml
vendored
|
|
@ -35,40 +35,36 @@ runs:
|
||||||
- name: Wait for MySQL to be ready
|
- name: Wait for MySQL to be ready
|
||||||
if: ${{ inputs.database == 'mysql' }}
|
if: ${{ inputs.database == 'mysql' }}
|
||||||
run: |
|
run: |
|
||||||
# Wait for MySQL service container to be healthy
|
# Wait for MySQL server to be ready
|
||||||
until mysqladmin ping -h 127.0.0.1 -u root -proot_password --silent; do
|
until mysqladmin ping -u root -proot_password --silent; do
|
||||||
sleep 1
|
sleep 1
|
||||||
echo -n .
|
echo -n .
|
||||||
done
|
done
|
||||||
echo "MySQL is ready"
|
echo "MySQL is ready"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Set up MySQL Privileges
|
- name: Set up MySQL Database and Privileges
|
||||||
if: ${{ inputs.database == 'mysql' }}
|
if: ${{ inputs.database == 'mysql' }}
|
||||||
run: |
|
run: |
|
||||||
# Note: MySQL server configuration (character set, collation, row format) is set
|
# Note: MySQL server configuration (character set, collation, row format) is set
|
||||||
# at container startup via custom entrypoint script that passes command-line arguments
|
# via my-cnf in the shogo82148/actions-setup-mysql action.
|
||||||
# to mysqld, similar to how mirromutth/mysql-action works.
|
# The user 'evennia' is already created by the action, but we need to create the database
|
||||||
# Ensure user exists and has proper privileges
|
# and grant privileges.
|
||||||
mysql -u root -proot_password -h 127.0.0.1 mysql <<EOF
|
mysql -u root -proot_password mysql <<EOF
|
||||||
CREATE USER IF NOT EXISTS 'evennia'@'%' IDENTIFIED BY 'password';
|
CREATE DATABASE IF NOT EXISTS evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||||
GRANT ALL PRIVILEGES ON \`evennia%\`.* TO 'evennia'@'%';
|
GRANT ALL PRIVILEGES ON \`evennia%\`.* TO 'evennia'@'%';
|
||||||
GRANT PROCESS ON *.* TO 'evennia'@'%';
|
GRANT PROCESS ON *.* TO 'evennia'@'%';
|
||||||
GRANT SESSION_VARIABLES_ADMIN ON *.* TO 'evennia'@'%';
|
GRANT SESSION_VARIABLES_ADMIN ON *.* TO 'evennia'@'%';
|
||||||
FLUSH PRIVILEGES;
|
FLUSH PRIVILEGES;
|
||||||
EOF
|
EOF
|
||||||
# Set database character set and collation
|
|
||||||
mysql -u root -proot_password -h 127.0.0.1 evennia <<EOF
|
|
||||||
ALTER DATABASE evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
||||||
EOF
|
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
# get logs from db start
|
# get logs from db start
|
||||||
- name: Database container logs
|
- name: Database container logs
|
||||||
if: ${{ inputs.database == 'postgresql' || inputs.database == 'mysql' }}
|
if: ${{ inputs.database == 'postgresql'}}
|
||||||
uses: jwalton/gh-docker-logs@v2
|
uses: jwalton/gh-docker-logs@v2
|
||||||
|
|
||||||
- name: Check running containers
|
- name: Check running containers
|
||||||
if: ${{ inputs.database == 'postgresql' || inputs.database == 'mysql' }}
|
if: ${{ inputs.database == 'postgresql'}}
|
||||||
run: docker ps -a
|
run: docker ps -a
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
|
||||||
35
.github/workflows/github_action_test_suite.yml
vendored
35
.github/workflows/github_action_test_suite.yml
vendored
|
|
@ -56,32 +56,21 @@ jobs:
|
||||||
|
|
||||||
timeout-minutes: 35
|
timeout-minutes: 35
|
||||||
|
|
||||||
services:
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
env:
|
|
||||||
MYSQL_DATABASE: evennia
|
|
||||||
MYSQL_USER: evennia
|
|
||||||
MYSQL_PASSWORD: password
|
|
||||||
MYSQL_ROOT_PASSWORD: root_password
|
|
||||||
ports:
|
|
||||||
- 3306:3306
|
|
||||||
options: >-
|
|
||||||
--health-cmd="mysqladmin ping -h localhost"
|
|
||||||
--health-interval=10s
|
|
||||||
--health-timeout=5s
|
|
||||||
--health-retries=3
|
|
||||||
--entrypoint="/bin/bash"
|
|
||||||
-c
|
|
||||||
"printf '#!/bin/bash\nexec /usr/local/bin/docker-entrypoint.sh mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb-default-row-format=DYNAMIC \"\$@\"\n' > /tmp/mysql-entrypoint.sh && chmod +x /tmp/mysql-entrypoint.sh && exec /tmp/mysql-entrypoint.sh"
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install MySQL client
|
- name: Set up MySQL
|
||||||
run: |
|
uses: shogo82148/actions-setup-mysql@v1
|
||||||
sudo apt-get update
|
with:
|
||||||
sudo apt-get install -y default-mysql-client
|
mysql-version: "8.0"
|
||||||
timeout-minutes: 2
|
root-password: root_password
|
||||||
|
user: evennia
|
||||||
|
password: password
|
||||||
|
my-cnf: |
|
||||||
|
[mysqld]
|
||||||
|
character-set-server=utf8mb4
|
||||||
|
collation-server=utf8mb4_unicode_ci
|
||||||
|
innodb-default-row-format=DYNAMIC
|
||||||
|
|
||||||
- name: Set up database (mysql)
|
- name: Set up database (mysql)
|
||||||
uses: ./.github/actions/setup-database
|
uses: ./.github/actions/setup-database
|
||||||
|
|
|
||||||
5
.github/workflows/mysql.cnf
vendored
5
.github/workflows/mysql.cnf
vendored
|
|
@ -1,5 +0,0 @@
|
||||||
[mysqld]
|
|
||||||
character-set-server=utf8mb4
|
|
||||||
collation-server=utf8mb4_unicode_ci
|
|
||||||
innodb-default-row-format=DYNAMIC
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue