Skip to content

Commit

Permalink
CI: test MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Feb 27, 2025
1 parent 8a260d1 commit 8b2cc35
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ jobs:
backend: Valgrind
runner: ubuntu-24.04
name: Valgrind
- lib_type: shared
backend: MySQL
runner: ubuntu-24.04
mariadb: true
name: MariaDB

runs-on: ${{ matrix.runner }}
name: ${{ format('{0} on {1}', (matrix.name != '' && matrix.name || format('{0} ({1})', matrix.backend, matrix.lib_type)), matrix.runner) }}
Expand Down Expand Up @@ -179,6 +184,9 @@ jobs:
else
set_env_var SOCI_ENABLE_UNITY_BUILD OFF
fi
if [ "${{matrix.mariadb}}" = true ]; then
set_env_var SOCI_MYSQL_USE_MARIADB YES
fi
# Ensure SOCI_CI_BACKEND is always lowercase
set_env_var SOCI_CI_BACKEND "$( echo "$SOCI_CI_BACKEND" | tr '[:upper:]' '[:lower:]' )"
Expand Down
15 changes: 10 additions & 5 deletions scripts/ci/before_build_mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
SOCI_MYSQL_USER=$(id -un)

if [ -n "${SOCI_MYSQL_ROOT_PASSWORD}" ]; then
sudo systemctl start mysql.service
if [[ "$SOCI_MYSQL_USE_MARIADB" = "YES" ]]; then
sudo systemctl start mariadb.service
else
sudo systemctl start mysql.service
fi

SOCI_MYSQL_PASSWORD_OPT="-p${SOCI_MYSQL_ROOT_PASSWORD}"
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "CREATE USER '${SOCI_MYSQL_USER}';"
sudo mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "CREATE USER '${SOCI_MYSQL_USER}';"
fi

mysql --version
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "CREATE DATABASE soci_test;"
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "GRANT ALL PRIVILEGES ON soci_test.* TO '${SOCI_MYSQL_USER}'@'%';";
sudo mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "CREATE DATABASE soci_test;"
sudo mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "GRANT ALL PRIVILEGES ON soci_test.* TO '${SOCI_MYSQL_USER}'@'%';";

# This is necessary for MySQL stored procedure unit test to work.
mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "SET GLOBAL log_bin_trust_function_creators=1";
sudo mysql -u root ${SOCI_MYSQL_PASSWORD_OPT} -e "SET GLOBAL log_bin_trust_function_creators=1";

echo 'Testing connection to the database:'
echo 'SELECT USER();' | mysql --database=soci_test
17 changes: 17 additions & 0 deletions scripts/ci/install_mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

source "${SOCI_SOURCE_DIR}/scripts/ci/common.sh"

if [[ "$SOCI_MYSQL_USE_MARIADB" = "YES" ]]; then
run_apt purge mysql*

run_apt install mariadb-server mariadb-client libmariadb-dev

sudo systemctl start mariadb

systemctl status mariadb
else
# We assume that MySQL is already installed
sudo systemctl start mysql
systemctl status mysql
fi

0 comments on commit 8b2cc35

Please sign in to comment.