-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdashboard-release.sh
executable file
·60 lines (47 loc) · 1.35 KB
/
dashboard-release.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
#!/usr/bin/env bash
#
# This script checks whether all tests passed in the latest batch,
# and then merges the master with the release branch.
#
# Use as
# dashboard-release.sh
# to check and merge the latest revision that was executed, or
# dashboard-release.sh <REVISION>
# for a specific revision.
#
echo Executing $0
# make it robust for running as a cron job
AWK=/usr/bin/awk
GIT=/usr/bin/git
GREP=/usr/bin/grep
LS=/usr/bin/ls
MAIL=/usr/bin/mail
RSYNC=/usr/bin/rsync
# specify working directories
PROJECTDIR=/project/3031000.02
DASHBOARDDIR=$PROJECTDIR/dashboard
FIELDTRIPDIR=$PROJECTDIR/fieldtrip
REVISION=$1
if [ -z "$REVISION" ] ; then
# determine the revision of the latest version that ran
REVISION=$(cat $DASHBOARDDIR/logs/latest/revision)
fi
# stop here if the revision cannot be determined
[ -z "$REVISION" ] && exit 1
LOGDIR=$DASHBOARDDIR/logs/$REVISION
BRANCH=$(cat $LOGDIR/branch)
FAILED=$($GREP FAILED $LOGDIR/*.txt | wc -l)
PASSED=$($GREP PASSED $LOGDIR/*.txt | wc -l)
echo $FAILED of the tests failed
echo $PASSED of the tests passed
if [ "$BRANCH" == "master" ]; then
if [ $FAILED -eq 0 ]; then
if [ $PASSED -gt 600 ]; then
echo merging $LATEST into release
cd $FIELDTRIPDIR && $GIT checkout master && $GIT pull upstream master && $GIT checkout release
$GIT log -1 $REVISION || exit 1
$GIT merge $REVISION
$GIT push upstream release
fi
fi
fi