aboutsummaryrefslogtreecommitdiff
path: root/ci/run_tests.sh
blob: adf69b77160ba36059e63c90ca762f51292b7d46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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

pip install tox
setup_playwright
setup_redis
tox -e python -- --browser firefox