Files

32 lines
1.6 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# CI only: installs PHP and a throwaway MariaDB inside the Playwright job
# container (Ubuntu, as root) and starts MariaDB on 127.0.0.1:3306. Run once per
# job, before tests/ui/stack.sh. MariaDB runs in the job container rather than
# as a service container because the Gitea runner puts jobs on Docker's default
# bridge network, where services can't be reached by name (same as Pulse).
set -euo pipefail
# 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.
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
PKGS="mariadb-server php-cli php-mysql php-mbstring php-curl php-ldap php-xml"
for attempt in 1 2 3; do
# shellcheck disable=SC2086
if apt-get -o Acquire::Retries=3 update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 install -y -qq --no-install-recommends $PKGS >/dev/null; then
break
fi
[ "$attempt" = 3 ] && { echo "::error::could not install $PKGS"; 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 USER IF NOT EXISTS 'tinker_ui'@'127.0.0.1' IDENTIFIED BY 'ci-only';"
echo "$(php --version | head -1), $(mariadb --version)"