Skip to content

Commit 3eaddc5

Browse files
committed
MOBILE-3401 travis: Add notifications on Telegram
1 parent 8508cf6 commit 3eaddc5

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

scripts/functions.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,21 @@ function print_title {
4848
echo
4949
tput setaf 5; echo "$stepnumber $1"; tput sgr0
5050
tput setaf 5; echo '=================='; tput sgr0
51-
}
51+
}
52+
53+
function telegram_notify {
54+
if [ ! -z $TELEGRAM_APIKEY ] && [ ! -z $TELEGRAM_CHATID ] ; then
55+
MESSAGE="Travis error: $1%0ABranch: $TRAVIS_BRANCH%0ARepo: $TRAVIS_REPO_SLUG"
56+
URL="https://api.telegram.org/bot$TELEGRAM_APIKEY/sendMessage"
57+
58+
curl -s -X POST $URL -d chat_id=$TELEGRAM_CHATID -d text="$MESSAGE"
59+
fi
60+
}
61+
62+
function notify_on_error_exit {
63+
if [ $? -ne 0 ]; then
64+
print_error "$1"
65+
telegram_notify "$1"
66+
exit 1
67+
fi
68+
}

scripts/mirror.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ if [ "$TRAVIS_BRANCH" == 'master' ]; then
6363
git commit -m 'Update licenses [ci skip]'
6464

6565
git push origin HEAD:$TRAVIS_BRANCH
66-
check_success_exit "Unsuccessful push, stopping..."
66+
notify_on_error_exit "MIRROR: Unsuccessful push, stopping..."
6767
fi
6868

6969
if [ "$TRAVIS_BRANCH" == 'integration' ] || [ "$TRAVIS_BRANCH" == 'master' ] || [ "$TRAVIS_BRANCH" == 'desktop' ] ; then
7070
print_title "Mirror repository"
7171
git remote add mirror https://$GIT_TOKEN@github.com/$GIT_ORG_PRIVATE/moodleapp.git
7272
git fetch -q --unshallow mirror
73-
check_success_exit "Unsuccessful fetch of mirror, stopping..."
73+
notify_on_error_exit "MIRROR: Unsuccessful fetch of mirror, stopping..."
7474
git fetch -q origin --depth=100
75-
check_success_exit "Unsuccessful fetch of origin, stopping..."
75+
notify_on_error_exit "MIRROR: Unsuccessful fetch of origin, stopping..."
7676
git push -f mirror HEAD:$TRAVIS_BRANCH
77-
check_success_exit "Unsuccessful mirror, stopping..."
77+
notify_on_error_exit "MIRROR: Unsuccessful mirror, stopping..."
7878
git push -f mirror --tags
79-
check_success_exit "Unsuccessful mirror tags, stopping..."
79+
notify_on_error_exit "MIRROR: Unsuccessful mirror tags, stopping..."
8080
fi

scripts/test_e2e.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
source "scripts/functions.sh"
4+
35
# Prepare variables
46
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
57
dockerscripts="$HOME/moodle-docker/bin/"
@@ -12,7 +14,7 @@ export MOODLE_DOCKER_PHP_VERSION=7.3
1214
export MOODLE_DOCKER_APP_PATH=$basedir
1315

1416
# Prepare dependencies
15-
echo "Preparing dependencies"
17+
print_title "Preparing dependencies"
1618
git clone --branch master --depth 1 git://github.com/moodle/moodle $HOME/moodle
1719
git clone --branch master --depth 1 git://github.com/moodlehq/moodle-local_moodlemobileapp $HOME/moodle/local/moodlemobileapp
1820
# git clone --branch master --depth 1 git://github.com/moodlehq/moodle-docker $HOME/moodle-docker
@@ -29,12 +31,12 @@ cd -
2931
cp $HOME/moodle-docker/config.docker-template.php $HOME/moodle/config.php
3032

3133
# Build app
32-
echo "Building app"
34+
print_title "Building app"
3335
npm install
3436
npm run setup
3537

3638
# Start containers
37-
echo "Starting containers"
39+
print_title "Starting containers"
3840
$dockercompose pull
3941
$dockercompose up -d
4042
$dockerscripts/moodle-docker-wait-for-db
@@ -44,9 +46,10 @@ $dockercompose exec -T webserver php admin/tool/behat/cli/init.php
4446
# Run tests
4547
for tags in "$@"
4648
do
47-
echo "Running e2e tests ($tags)"
49+
print_title "Running e2e tests ($tags)"
4850

4951
$dockercompose exec -T webserver php admin/tool/behat/cli/run.php --tags="$tags"
52+
notify_on_error_exit "e2e failed on $tags"
5053
done
5154

5255
# Clean up

0 commit comments

Comments
 (0)