#!/bin/bash if [ -z "$CI" ]; then # kill all subprocess on exit trap "exit" INT TERM ERR trap "kill 0" EXIT else echo "CI is set to $CI"; fi # script should fail when any process returns non zero code set -ev # handle arguments SKIP_SETUP=false START_BACKGROUND=false PROXY_VUE=false for i in "$@" do case $i in --start-background) START_BACKGROUND=true shift # past argument ;; --skip-setup) SKIP_SETUP=true shift # past argument with no value ;; --proxy-vue) PROXY_VUE=true shift # past argument with no value ;; *) # unknown option ;; esac done echo "SKIP_SETUP = ${SKIP_SETUP}" DJANGO_SETTINGS_MODULE=config.settings.test_cypress CYPRESS_DB=vbv_lernwelt_cypress if [ "$SKIP_SETUP" = false ]; then if [ -z "$PG_PORT" ]; then # if the port is set in the env, use iterg DB_PORT=""; else DB_PORT="-p $PG_PORT"; fi if [ -z "$PG_USER" ]; then # if the user is set in the env, use it DB_USER=""; else DB_USER="-U $PG_USER"; fi echo "psql -h localhost $DB_PORT $DB_USER -c 'drop database if exists $CYPRESS_DB;'" # create database psql -h localhost $DB_PORT $DB_USER -c "drop database if exists $CYPRESS_DB;" psql -h localhost $DB_PORT $DB_USER -c "create database $CYPRESS_DB;" # reset data # python3 src/manage.py randomdata --settings="$DJANGO_SETTINGS_MODULE" python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE" python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE" # make django translations (cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE") else echo "else" # python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE" fi if [ "$PROXY_VUE" = true ]; then export DJANGO_VUE_LANDINGPAGE_PROXY=http://localhost:8080/ fi # install cypress here to avoid problems with `npm install` on the iesc servers #CYPRESS_INSTALLED=0 ##npx --no-install cypress --version || CYPRESS_INSTALLED=$? #if [ $CYPRESS_INSTALLED -ne 0 ]; then # echo "install cypress" ## npm install cypress@5.6.0 @testing-library/cypress@7.0.2 --no-save #fi if [ "$START_BACKGROUND" = true ]; then python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" > /dev/null & else python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" fi