Skip to content
run-tests-for-ci.sh 1.76 KiB
Newer Older
Andreas Klöckner's avatar
Andreas Klöckner committed
#! /bin/bash

PY_EXE=${PY_EXE:-$(poetry run which python)}

Andreas Klöckner's avatar
Andreas Klöckner committed
echo "-----------------------------------------------"
echo "Current directory: $(pwd)"
echo "Python executable: ${PY_EXE}"
echo "-----------------------------------------------"

Josh Asplund's avatar
Josh Asplund committed
echo "i18n"
Josh Asplund's avatar
Josh Asplund committed
# Testing i18n needs a local_settings file even though the rest of the tests
#   don't use it
cp local_settings_example.py local_settings.py

# Make sure i18n literals marked correctly
poetry run python manage.py makemessages --no-location --ignore=req.txt > output.txt

if [[ -n $(grep "msgid" output.txt) ]]; then
    echo "Command 'python manage.py makemessages' failed with the following info:"
    echo ""
    grep --color -E '^|warning: ' output.txt
    exit 1;
fi
poetry run python manage.py compilemessages
Dong Zhuang's avatar
Dong Zhuang committed

Josh Asplund's avatar
Josh Asplund committed
echo "Starts testing"

if [[ "$RL_CI_TEST" = "expensive" ]]; then
Josh Asplund's avatar
Josh Asplund committed
    echo "Expensive tests"
Josh Asplund's avatar
Josh Asplund committed
    poetry run pytest --slow --cov-config=setup.cfg --cov-report=xml --cov=.
elif [[ "$RL_CI_TEST" = "postgres" ]]; then
Josh Asplund's avatar
Josh Asplund committed
    export PGPASSWORD=relatepgpass

    echo "Preparing database"
    echo "import psycopg2.extensions" >> local_settings_example.py
Josh Asplund's avatar
Josh Asplund committed
    echo "DATABASES = {
            'default': {
Josh Asplund's avatar
Josh Asplund committed
                'ENGINE': 'django.db.backends.postgresql',
Josh Asplund's avatar
Josh Asplund committed
                'HOST': 'localhost',
                'USER': 'postgres',
                'PASSWORD': '${PGPASSWORD}',
                'NAME': 'test_relate',
                'OPTIONS': {
                    'isolation_level': psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE,
                },
            },
        }" >> local_settings_example.py
Josh Asplund's avatar
Josh Asplund committed
    poetry install -E pgsql
Josh Asplund's avatar
Josh Asplund committed
    echo "Database tests"
Josh Asplund's avatar
Josh Asplund committed
    poetry run pytest --cov-config=setup.cfg --cov-report=xml --cov=.
Dong Zhuang's avatar
Dong Zhuang committed
else
Josh Asplund's avatar
Josh Asplund committed
    echo "Base tests"
Josh Asplund's avatar
Josh Asplund committed
    poetry run pytest --cov-config=setup.cfg --cov-report=xml --cov=.
Dong Zhuang's avatar
Dong Zhuang committed
fi