This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/tests/setup-db.sh

34 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
2024-01-15 21:26:55 +00:00
set -eux
DATABASE=$1
mkdir -p data/config
2024-01-15 21:26:55 +00:00
if [ "$DATABASE" = "pgsql" ]; then
sudo systemctl start postgresql
psql --version
sudo -u postgres psql -c "SELECT set_config('log_statement', 'all', false);" -U postgres
sudo -u postgres psql -c "CREATE USER shimmie WITH PASSWORD 'shimmie';" -U postgres
sudo -u postgres psql -c "CREATE DATABASE shimmie WITH OWNER shimmie;" -U postgres
export TEST_DSN="pgsql:user=shimmie;password=shimmie;host=127.0.0.1;dbname=shimmie"
fi
2024-01-15 21:26:55 +00:00
if [ "$DATABASE" == "mysql" ]; then
sudo systemctl start mysql
mysql --version
mysql -e "SET GLOBAL general_log = 'ON';" -uroot -proot
mysql -e "CREATE DATABASE shimmie;" -uroot -proot
export TEST_DSN="mysql:user=root;password=root;host=127.0.0.1;dbname=shimmie"
fi
2024-01-15 21:26:55 +00:00
if [ "$DATABASE" = "sqlite" ]; then
sudo apt update && sudo apt-get install -y sqlite3
sqlite3 --version
export TEST_DSN="sqlite:data/shimmie.sqlite"
fi
2024-01-15 21:26:55 +00:00
if [ -n "$GITHUB_ENV" ]; then
echo "TEST_DSN=$TEST_DSN" >> $GITHUB_ENV
2024-01-05 16:03:04 +00:00
echo "INSTALL_DSN=$TEST_DSN" >> $GITHUB_ENV
fi