aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml10
-rwxr-xr-xci/run_tests.sh49
2 files changed, 53 insertions, 6 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9263e91..b187104 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,13 +20,11 @@ default:
- pip install tox
test:
+ parallel:
+ matrix:
+ - DB: ["sqlite", "postgres"]
script:
- - pip install poetry && pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ")
- - playwright install firefox
- - playwright install-deps
- - apt install -y redis-server
- - redis-server >/dev/null 2>&1 &
- - tox -e python -- --browser firefox
+ - ci/run_tests.sh $DB
# test-pypy:
# image: pypy:3
diff --git a/ci/run_tests.sh b/ci/run_tests.sh
new file mode 100755
index 0000000..f2e289a
--- /dev/null
+++ b/ci/run_tests.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+set -euxo pipefail
+
+DB=$1
+
+PPATH="/usr/lib/postgresql/13/bin/"
+
+setup_postgres() {
+ apt update
+ apt install -y postgresql postgresql-client sudo
+ echo -n "postgres" >/tmp/pw
+ mkdir /tmp/postgres-db
+ chown postgres:postgres /tmp/postgres-db
+ sudo -u postgres "$PPATH/initdb" --pwfile /tmp/pw -U postgres /tmp/postgres-db
+ sudo -u postgres "$PPATH/postgres" -D /tmp/postgres-db >/dev/null 2>&1 &
+}
+
+setup_redis() {
+ apt install -y redis-server
+ redis-server >/dev/null 2>&1 &
+}
+
+setup_playwright() {
+ pip install poetry
+ pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ")
+ playwright install firefox
+ playwright install-deps
+}
+
+case "$DB" in
+ "sqlite")
+ ;;
+
+ "postgres")
+ setup_postgres
+ sed -i 's/^sqlalchemy.url = .*$/sqlalchemy.url = "postgresql://postgres:postgres@localhost/postgres"/' testing.ini
+ ;;
+
+ *)
+ echo "Unknown database: $DB"
+ exit 1
+ ;;
+esac
+
+exit
+
+setup_playwright
+setup_redis
+tox -e python -- --browser firefox