MOBILE-3401 travis: Add notifications on Telegram

main
Pau Ferrer Ocaña 2020-06-17 08:21:37 +02:00
parent 8508cf6813
commit 3eaddc517c
3 changed files with 30 additions and 10 deletions

View File

@ -48,4 +48,21 @@ function print_title {
echo
tput setaf 5; echo "$stepnumber $1"; tput sgr0
tput setaf 5; echo '=================='; tput sgr0
}
}
function telegram_notify {
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
MESSAGE="Travis error: $1%0ABranch: $TRAVIS_BRANCH%0ARepo: $TRAVIS_REPO_SLUG"
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
fi
}
function notify_on_error_exit {
if [ $? -ne 0 ]; then
print_error "$1"
telegram_notify "$1"
exit 1
fi
}

View File

@ -63,18 +63,18 @@ if [ "$TRAVIS_BRANCH" == 'master' ]; then
git commit -m 'Update licenses [ci skip]'
git push origin HEAD:$TRAVIS_BRANCH
check_success_exit "Unsuccessful push, stopping..."
notify_on_error_exit "MIRROR: Unsuccessful push, stopping..."
fi
if [ "$TRAVIS_BRANCH" == 'integration' ] || [ "$TRAVIS_BRANCH" == 'master' ] || [ "$TRAVIS_BRANCH" == 'desktop' ] ; then
print_title "Mirror repository"
git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git
git fetch -q --unshallow mirror
check_success_exit "Unsuccessful fetch of mirror, stopping..."
notify_on_error_exit "MIRROR: Unsuccessful fetch of mirror, stopping..."
git fetch -q origin --depth=100
check_success_exit "Unsuccessful fetch of origin, stopping..."
notify_on_error_exit "MIRROR: Unsuccessful fetch of origin, stopping..."
git push -f mirror HEAD:$TRAVIS_BRANCH
check_success_exit "Unsuccessful mirror, stopping..."
notify_on_error_exit "MIRROR: Unsuccessful mirror, stopping..."
git push -f mirror --tags
check_success_exit "Unsuccessful mirror tags, stopping..."
notify_on_error_exit "MIRROR: Unsuccessful mirror tags, stopping..."
fi

View File

@ -1,5 +1,7 @@
#!/bin/bash
source "scripts/functions.sh"
# Prepare variables
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
dockerscripts="$HOME/moodle-docker/bin/"
@ -12,7 +14,7 @@ export MOODLE_DOCKER_PHP_VERSION=7.3
export MOODLE_DOCKER_APP_PATH=$basedir
# Prepare dependencies
echo "Preparing dependencies"
print_title "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
@ -29,12 +31,12 @@ cd -
cp $HOME/moodle-docker/config.docker-template.php $HOME/moodle/config.php
# Build app
echo "Building app"
print_title "Building app"
npm install
npm run setup
# Start containers
echo "Starting containers"
print_title "Starting containers"
$dockercompose pull
$dockercompose up -d
$dockerscripts/moodle-docker-wait-for-db
@ -44,9 +46,10 @@ $dockercompose exec -T webserver php admin/tool/behat/cli/init.php
# Run tests
for tags in "$@"
do
echo "Running e2e tests ($tags)"
print_title "Running e2e tests ($tags)"
$dockercompose exec -T webserver php admin/tool/behat/cli/run.php --tags="$tags"
notify_on_error_exit "e2e failed on $tags"
done
# Clean up