From a86f0c13d1c62c8fdd554480549b08f2dc812f59 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 11 Jun 2020 16:40:20 +0200 Subject: [PATCH] MOBILE-3294: Configure travis to run behat tests --- .travis.yml | 18 +++++++++++++++ scripts/test_e2e.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 scripts/test_e2e.sh diff --git a/.travis.yml b/.travis.yml index d815bf211..bb544ad1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -105,3 +105,21 @@ jobs: - DEBUG=electron-windows-store - BUILD_PLATFORM='windows' script: scripts/aot.sh + - stage: test + name: "End to end tests (mod_forum, mod_messages and mod_comments)" + services: + - docker + if: env(TRAVIS_EVENT_TYPE) = cron + script: scripts/test_e2e.sh "@app&&@mod_forum" "@app&&@mod_messages" "@app&&@mod_comments" + - stage: test + name: "End to end tests (mod_data, mod_survey, mod_course, core_course and mod_courses)" + services: + - docker + if: env(TRAVIS_EVENT_TYPE) = cron + script: scripts/test_e2e.sh "@app&&@mod_data" "@app&&@mod_survey" "@app&&@mod_course" "@app&&@core_course" "@app&&@mod_courses" + - stage: test + name: "End to end tests (others)" + services: + - docker + if: env(TRAVIS_EVENT_TYPE) = cron + script: scripts/test_e2e.sh "@app&&~@mod_forum&&~@mod_messages&&~@mod_comments&&~@mod_data&&~@mod_survey&&~@mod_course&&~@core_course&&~@mod_courses" diff --git a/scripts/test_e2e.sh b/scripts/test_e2e.sh new file mode 100755 index 000000000..87174db70 --- /dev/null +++ b/scripts/test_e2e.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Prepare variables +basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" +dockerscripts="$HOME/moodle-docker/bin/" +dockercompose="$dockerscripts/moodle-docker-compose" + +export MOODLE_DOCKER_DB=pgsql +export MOODLE_DOCKER_BROWSER=chrome +export MOODLE_DOCKER_WWWROOT="$HOME/moodle" +export MOODLE_DOCKER_PHP_VERSION=7.3 +export MOODLE_DOCKER_APP_PATH=$basedir + +# Prepare dependencies +echo "Preparing dependencies" +git clone --branch master --depth 1 git://github.com/moodle/moodle $HOME/moodle +git clone --branch master --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $HOME/moodle/local/moodlemobileapp +# git clone --branch master --depth 1 git://github.com/moodlehq/moodle-docker $HOME/moodle-docker + +# TODO replace with commented line above once https://github.com/moodlehq/moodle-docker/pull/126 is merged +mkdir $HOME/moodle-docker +cd $HOME/moodle-docker +git init +git remote add origin git://github.com/moodlehq/moodle-docker +git fetch --depth 1 origin c604d5f9792c72fb9d83f6fec1f4b1defd778e9a +git checkout FETCH_HEAD +cd - + +cp $HOME/moodle-docker/config.docker-template.php $HOME/moodle/config.php + +# Build app +echo "Building app" +npm install +npm run setup + +# Start containers +echo "Starting containers" +$dockercompose pull +$dockercompose up -d +$dockerscripts/moodle-docker-wait-for-db +$dockerscripts/moodle-docker-wait-for-app +$dockercompose exec -T webserver php admin/tool/behat/cli/init.php + +# Run tests +for tags in "$@" +do + echo "Running e2e tests ($tags)" + + $dockercompose exec -T webserver php admin/tool/behat/cli/run.php --tags="$tags" +done + +# Clean up +$dockercompose down