From 1e651de59e32cc5f8eaf39807db93d5894532be7 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 15 Jun 2021 16:30:20 +0200 Subject: [PATCH] MOBILE-3320 e2e: Switch back to Travis --- .github/workflows/e2e.yml | 45 ----------------------------------- .travis.yml | 18 ++++++++++++++ scripts/test_e2e.sh | 50 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/e2e.yml create mode 100644 scripts/test_e2e.sh diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 77b5a6289..000000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: E2E - -on: - schedule: - - cron: '0 0 * * *' # every day at midnight - -jobs: - e2e: - runs-on: ubuntu-latest - env: - MOODLE_DOCKER_DB: pgsql - MOODLE_DOCKER_BROWSER: chrome - MOODLE_DOCKER_PHP_VERSION: 7.3 - steps: - - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 - with: - node-version: '12.x' - - name: Install npm packages - run: npm ci - - name: Additional checkouts - run: | - git clone --branch master --depth 1 git://github.com/moodle/moodle $GITHUB_WORKSPACE/moodle - git clone --branch ionic5 --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $GITHUB_WORKSPACE/moodle/local/moodlemobileapp - git clone --branch MOBILE-3738 --depth 1 git://github.com/NoelDeMartin/moodle-docker $GITHUB_WORKSPACE/moodle-docker - - name: Setup docker machine - run: | - export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle - export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE - cp $GITHUB_WORKSPACE/moodle-docker/config.docker-template.php $GITHUB_WORKSPACE/moodle/config.php - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose pull - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose up -d - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-db - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-wait-for-app - - name: Init behat - run: | - export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle - export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/init.php" - - name: Run tests - run: | - export MOODLE_DOCKER_WWWROOT=$GITHUB_WORKSPACE/moodle - export MOODLE_DOCKER_APP_PATH=$GITHUB_WORKSPACE - $GITHUB_WORKSPACE/moodle-docker/bin/moodle-docker-compose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --tags="@app" --auto-rerun" diff --git a/.travis.yml b/.travis.yml index f82e73c91..014e77b3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,3 +56,21 @@ jobs: if: env(DEPLOY) = 1 AND env(BUILD_IOS) = 1 os: osx osx_image: xcode12.4 + - stage: test + name: "End to end tests (mod_forum and mod_messages)" + services: + - docker + if: type = cron + script: scripts/test_e2e.sh "@app&&@mod_forum" "@app&&@mod_messages" + - stage: test + name: "End to end tests (mod_course, core_course and mod_courses)" + services: + - docker + if: type = cron + script: scripts/test_e2e.sh "@app&&@mod_course" "@app&&@core_course" "@app&&@mod_courses" + - stage: test + name: "End to end tests (others)" + services: + - docker + if: type = cron + script: scripts/test_e2e.sh "@app&&~@mod_forum&&~@mod_messages&&~@mod_course&&~@core_course&&~@mod_courses" diff --git a/scripts/test_e2e.sh b/scripts/test_e2e.sh new file mode 100644 index 000000000..6e363aa24 --- /dev/null +++ b/scripts/test_e2e.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +source "scripts/functions.sh" + +# 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.4 +export MOODLE_DOCKER_APP_PATH=$basedir + +# Prepare dependencies +print_title "Preparing dependencies" +git clone --branch master --depth 1 git://github.com/moodle/moodle $HOME/moodle +git clone --branch ionic5 --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $HOME/moodle/local/moodlemobileapp + +# TODO replace for moodlehq/moodle-docker after merging https://github.com/moodlehq/moodle-docker/pull/156 +git clone --branch MOBILE-3738 --depth 1 git://github.com/NoelDeMartin/moodle-docker $HOME/moodle-docker + +cp $HOME/moodle-docker/config.docker-template.php $HOME/moodle/config.php + +# Build app +print_title "Building app" +npm ci + +# Start containers +print_title "Starting containers" +$dockercompose pull +$dockercompose up -d +$dockerscripts/moodle-docker-wait-for-db +$dockerscripts/moodle-docker-wait-for-app + +$dockercompose exec -T webserver sh -c "php admin/tool/behat/cli/init.php" +notify_on_error_exit "e2e failed initializing behat" + +print_title "Running e2e tests" + +# Run tests +for tags in "$@" +do + $dockercompose exec -T webserver sh -c "php admin/tool/behat/cli/run.php --tags=\"$tags\" --auto-rerun" + notify_on_error_exit "Some e2e tests are failing, please review" +done + +# Clean up +$dockercompose down