Files
pulse/scripts/ci/mariadb.sh
T
jaredandClaude Opus 5.5 61991841aa
CI / Test (jest) (pull_request) Successful in 27s
CI / Lint (eslint) (pull_request) Successful in 29s
CI / Security (npm audit) (pull_request) Successful in 24s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 3m7s
CI / Integration (api) (pull_request) Successful in 4m4s
CI / UI screenshots (before/after) (pull_request) Successful in 11s
CI / UI (playwright) (pull_request) Successful in 2m2s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI: mariadb.sh avoids the unreachable Azure apt mirror and retries apt
The Playwright image's apt sources point at azure.archive.ubuntu.com, which
timed out from the runner after it moved nodes; the UI job failed at Start
MariaDB twice. Switch to archive.ubuntu.com and retry apt up to 3 times.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 02:10:22 -05:00

32 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Installs and starts a throwaway MariaDB inside a CI job container (Debian or
# Ubuntu, as root) and creates the database and user from DB_NAME, DB_USER and
# DB_PASSWORD. Used instead of a service container: the Gitea runner puts jobs on
# Docker's default bridge network, where services can't be reached by name.
set -euo pipefail
: "${DB_NAME:?}" "${DB_USER:?}" "${DB_PASSWORD:?}"
# The Playwright image points apt at Azure's Ubuntu mirror, which our runner can't
# always reach; use the main Ubuntu mirror instead, and retry transient failures.
for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do
[ -f "$f" ] && sed -i 's#http://azure\.archive\.ubuntu\.com/#http://archive.ubuntu.com/#g' "$f"
done
for attempt in 1 2 3; do
if apt-get -o Acquire::Retries=3 update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 install -y -qq --no-install-recommends mariadb-server >/dev/null; then
break
fi
[ "$attempt" = 3 ] && { echo "::error::could not install mariadb-server"; exit 1; }
echo "apt failed (attempt $attempt); retrying in 10s"
sleep 10
done
mkdir -p /run/mysqld && chown mysql:mysql /run/mysqld
if ! mariadb-admin ping --silent 2>/dev/null; then
(mariadbd --user=mysql --bind-address=127.0.0.1 --port=3306 >/tmp/mariadb.log 2>&1 &)
fi
for _ in $(seq 1 30); do mariadb-admin ping --silent 2>/dev/null && break; sleep 1; done
mariadb -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\`;
CREATE USER IF NOT EXISTS '${DB_USER}'@'127.0.0.1' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL ON \`${DB_NAME}\`.* TO '${DB_USER}'@'127.0.0.1';"
echo "node $(node --version), $(mariadb --version)"