weblate/ci/run-migrate
Michal Čihař 6aabaa9e46 Install old django version for migration tests
Signed-off-by: Michal Čihař <michal@cihar.com>
2019-08-30 14:20:59 +02:00

52 lines
1.8 KiB
Bash
Executable file

#!/bin/sh
# Migrations test executor
. ci/lib
TAGS="weblate-3.1.1 weblate-3.2.2 weblate-3.3 weblate-3.4 weblate-3.5.1 weblate-3.7.1"
for tag in $TAGS ; do
echo
echo "Testing migration from $tag on $CI_DATABASE..."
cleanup_database
git fetch --depth 1 origin tag $tag
check
git checkout $tag
pip install 'Django>=2.1,<2.2'
pip install -r requirements-optional.txt -r requirements-test.txt -r docs/requirements.txt
echo "DATABASES['default']['HOST'] = '$CI_DB_HOST'" >> weblate/settings_test.py
check
run_coverage ./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
git reset --hard
git checkout $TRAVIS_COMMIT$DRONE_COMMIT
pip install -r requirements-optional.txt -r requirements-test.txt -r docs/requirements.txt
run_coverage ./manage.py migrate
check
done
./manage.py makemigrations
check
if [ `git status -s | grep -c /migrations/` -gt 0 ] ; then
echo 'There are untracked migrations:'
git status -s --porcelain | grep /migrations/ | sed -n '/^??/ s/^?? \(.*\)/\1/p' | while read migration ; do
echo $migration
cat $migration
echo
done
exit 1
fi