weblate/ci/run-migrate
Michal Čihař 43f3a83fd9 CI: Attempt to fetch tags from the upstream repo
On forks, the tags are often missing, so try to fetch them from upstream.
2020-05-15 17:15:54 +02:00

86 lines
2.5 KiB
Bash
Executable file
Vendored

#!/bin/sh
# Migrations test executor
. ci/lib
if [ -n "$1" ] ; then
TAG="weblate-$1"
else
echo "Missing version to migrate from!"
exit 1
fi
HEAD_COMMIT=$(git rev-parse HEAD)
# Install fixed version to avoid breakage with 1.0.0
pip install httpretty==0.9.7
print_step "Testing migration from $TAG on $CI_DATABASE..."
cleanup_database
check
git fetch --depth 1 origin tag $TAG
if [ $? -ne 0 ] ; then
git remote add upstream https://github.com/WeblateOrg/weblate.git
git fetch --depth 1 upstream tag $TAG
fi
check
git checkout $TAG
check
case $TAG in
weblate-3.[12345].* | weblate-3.[12345])
# Older versions do not support Django 2.2
pip install 'Django>=2.1,<2.2'
;;
*)
pip install 'Django>=2.2,<3.0'
;;
esac
check
pip install -r requirements-optional.txt -r docs/requirements.txt
check
if [ -f requirements-test.txt ] ; then pip install -r requirements-test.txt ; fi
check
if pip show Django | grep -q '^Version: 3' ; then pip install django-compressor==2.4 ; fi
check
echo "DATABASES['default']['HOST'] = '$CI_DB_HOST'" >> weblate/settings_test.py
check
if [ -n "$CI_DB_PASSWORD" ] ; then
echo "DATABASES['default']['PASSWORD'] = '$CI_DB_PASSWORD'" >> weblate/settings_test.py
check
fi
if [ -n "$CI_DB_PORT" ] ; then
echo "DATABASES['default']['PORT'] = '$CI_DB_PORT'" >> weblate/settings_test.py
check
fi
./manage.py migrate
check
./manage.py shell -c 'from weblate.lang.models import Language; Language.objects.all().delete()'
check
# Load basic project fixture
./manage.py loaddata simple-project.json
check
# Enable suggestion voting
./manage.py shell -c 'from weblate.trans.models import Component; Component.objects.all().update(suggestion_voting=True, suggestion_autoaccept=2)'
check
# Add suggestions
./manage.py add_suggestions test test cs weblate/trans/tests/data/cs.po
check
# Add vote for suggestion
./manage.py shell -c 'from weblate.trans.models import Vote, Suggestion; s = Suggestion.objects.all()[0]; vote = Vote(suggestion=s, user=s.user); vote.value = 1; vote.positive = True; vote.save()'
check
# Load translation memory
if [ -f ./weblate/trans/tests/data/memory.json ] ; then
./manage.py import_memory ./weblate/trans/tests/data/memory.json
check
fi
git reset --hard
check
git checkout $HEAD_COMMIT
check
pip install -r requirements-optional.txt -r requirements-test.txt -r docs/requirements.txt
check
run_coverage ./manage.py migrate
check
# Check migrated vote exists
./manage.py shell -c 'from weblate.trans.models import Vote; Vote.objects.get(value=1)'
check