-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspelbuild.sh
More file actions
153 lines (143 loc) · 4.64 KB
/
Copy pathspelbuild.sh
File metadata and controls
153 lines (143 loc) · 4.64 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
CWD=$(pwd)
LOGFILE=/home/vkoshura/spelbuild.log
TESTSFILE=/home/vkoshura/spelbuildtests.log
USRFILE=/home/vkoshura/spelbuildbot.usr
LOCKFILE=/home/vkoshura/spelbuild.lock
TESTSSUMMARYFILE=/home/vkoshura/testssummary.log
SEPARATETESTFILE=/home/vkoshura/separatetest.log
LOGS=/home/vkoshura/linuxlogs.7z
ERRORFLAG=0
if mkdir "$LOCKFILE"; then
echo "Start SPEL Build"
else
exit 1
fi
cd /home/vkoshura/pose/
echo -e "Start build:\n\n" > "$LOGFILE"
hg pull &>> "$LOGFILE"
if [ $? -eq 0 ]; then
hg up &>> "$LOGFILE"
if [ $? -eq 0 ]; then
cd build
make clean &>> "$LOGFILE"
if [ $? -eq 0 ]; then
cmake ../src/ &>> "$LOGFILE"
if [ $? -eq 0 ]; then
make -j2 &>> "$LOGFILE"
if [ $? -eq 0 ]; then
cd tests
./speltests &> "$TESTSFILE"
if [ -f "$TESTSFILE" ]; then
echo -e "Tests Summary:\n\n" > $TESTSSUMMARYFILE
while IFS= read -r LINE || [[ -n "$LINE" ]]; do
[[ "$LINE" =~ (\[[-=[:alpha:][:space:]]{10}\].+) ]]
if [ -n "${BASH_REMATCH[1]}" ]; then
echo -e "${BASH_REMATCH[1]}" >> $TESTSSUMMARYFILE
fi
if [ -f "$SEPARATETESTFILE" ]; then
rm "$SEPARATETESTFILE"
fi
[[ "$LINE" =~ \[[[:space:]]RUN[[:space:]]{6}\][[:space:]](.+) ]]
if [ -n "${BASH_REMATCH[1]}" ]; then
mysql -u root -pXXXXXXXX -e "insert into pose_mediawiki.unittests (testname) select * from (select '"${BASH_REMATCH[1]}"') as t where not exists (select 1 from pose_mediawiki.unittests where testname = '"${BASH_REMATCH[1]}"');"
./speltests --gtest_filter="${BASH_REMATCH[1]}" &> "$SEPARATETESTFILE"
if [ -f "$SEPARATETESTFILE" ]; then
while IFS= read -r LINE || [[ -n "$LINE" ]]; do
[[ "$LINE" =~ \[[[:space:]]{7}OK[[:space:]]\][[:space:]](.+)[[:space:]]\(.+\) ]]
if [ -n "${BASH_REMATCH[1]}" ]; then
mysql -u root -pXXXXXXXX -e "update pose_mediawiki.unittests set linux=1 where testname = '"${BASH_REMATCH[1]}"';"
break
fi
[[ "$LINE" =~ \[[[:space:]]{2}FAILED[[:space:]]{2}\][[:space:]](.+)[[:space:]]\(.+\) ]]
if [ -n "${BASH_REMATCH[1]}" ]; then
mysql -u root -pXXXXXXXX -e "update pose_mediawiki.unittests set linux=0 where testname = '"${BASH_REMATCH[1]}"';"
break
fi
done < "$SEPARATETESTFILE"
fi
fi
done < "$TESTSFILE"
fi
else
ERRORFLAG=4
fi
else
ERRORFLAG=3
fi
else
ERRORFLAG=2
fi
else
ERRORFLAG=1
fi
else
ERRORFLAG=1
fi
if [ "$ERRORFLAG" -eq 0 ]; then
STATUS="SUCCESSFULL"
elif [ "$ERRORFLAG" -eq 1 ]; then
STATUS="FAILED: Repository update failed"
elif [ "$ERRORFLAG" -eq 2 ]; then
STATUS="FAILED: Clean failed"
elif [ "$ERRORFLAG" -eq 3 ]; then
STATUS="FAILED: CMake rebuild failed"
elif [ "$ERRORFLAG" -eq 4 ]; then
STATUS="FAILED: SPEL rebuild failed"
else
STATUS="FAILED: Unknown reason"
fi
if [ -f "$LOGS" ]; then
rm "$LOGS"
fi
if [ "$ERRORFLAG" -eq 0 ]; then
if [ -f "$TESTSFILE" ]; then
7z a "$LOGS" "$LOGFILE" "$TESTSFILE"
if [ -f "$LOGS" ]; then
if [ -f "$USRFILE" ]; then
while IFS='' read -r LINE || [[ -n "$LINE" ]]; do
if [ -f "$TESTSSUMMARYFILE" ]; then
mutt -a "$LOGS" -s "SPEL Build Bot: Build Report: $STATUS" -- "$LINE" < "$TESTSSUMMARYFILE"
else
echo -e "Build complete\n" | mutt -a "$LOGS" -s "SPEL Build Bot: Build Report: $STATUS" -- "$LINE"
fi
done < "$USRFILE"
fi
fi
else
7z a "$LOGS" "$LOGFILE"
if [ -f "$LOGS" ]; then
if [ -f "$USRFILE" ]; then
while IFS='' read -r LINE || [[ -n "$LINE" ]]; do
echo -e "Tests log is not present" | mutt -a "$LOGS" -s "SPEL Build Bot: Build Report: $STATUS" -- "$LINE"
done < "$USRFILE"
fi
fi
fi
else
7z a "$LOGS" "$LOGFILE"
if [ -f "$LOGS" ]; then
if [ -f "$USRFILE" ]; then
while IFS='' read -r LINE || [[ -n "$LINE" ]]; do
echo -e "Tests log is not present" | mutt -a "$LOGS" -s "SPEL Build Bot: Build Report: $STATUS" -- "$LINE"
done < "$USRFILE"
fi
fi
fi
if [ -f "$LOGS" ]; then
rm "$LOGS"
fi
if [ -f "$LOGFILE" ]; then
rm "$LOGFILE"
fi
if [ -f "$TESTSFILE" ]; then
rm "$TESTSFILE"
fi
if [ -f "$TESTSSUMMARYFILE" ]; then
rm "$TESTSSUMMARYFILE"
fi
if [ -f "$EPARATETESTFILE" ]; then
rm "$SEPARATETESTFILE"
fi
rm -r "$LOCKFILE"
cd "$CWD"