forked from theia-ide/theia-apps
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_changed.sh
executable file
·62 lines (48 loc) · 1.77 KB
/
check_changed.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
# This script is called by Travis during the install step.
# It returns 1 if no files where changed. In that case
# no further building/test is required for this image
IMAGE_NAME=$1
echo "Travis event type: $TRAVIS_EVENT_TYPE"
if [ "$TRAVIS_EVENT_TYPE" != "pull_request" ]
then
# trigger via travis dashboard or cron job
# test all
echo "Trigger all tests"
exit 0
fi
CHANGED_FILES=$(git diff --name-status HEAD~1...HEAD "$IMAGE_NAME-docker")
if [ "$IMAGE_NAME" == "theia" ]
then
if [ -z "$CHANGED_FILES" ]
then
# there were no changes in theia-docker
# we want to build the theia-docker image also
# in the case that there were changes in other
# non theia*-docker folders
# eg. build scripts
CHANGED_FILES_NON_DOCKER=$(git diff --name-status HEAD~1...HEAD .)
while read -r line; do
# the output of the git diff is of the form "M theia-somename-docker/xyz"
if [[ $line =~ ^[[:space:]]*.[[:space:]]+theia(.)*-docker(.)+ ]]; then
# there was a change to an theia*-docker folder (not theia-docker)
# this will be picked up by another build
:
else
# there was a change in a non theia*-docker folder
# build theia-docker to be sure no utility scripts are broken
CHANGED_FILES="$line"$'\n'"$CHANGED_FILES"
fi
done <<< "$CHANGED_FILES_NON_DOCKER"
fi
fi
if [ -z "$CHANGED_FILES" ]
then
# nothing changed, skip building
echo "No changes in $IMAGE_NAME, terminate"
# this indicates to the parent script that the build can be terminated
exit 137
fi
echo "There were changes in $IMAGE_NAME changes: $CHANGED_FILES"
exit 0