-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateStatus
executable file
·128 lines (91 loc) · 3.04 KB
/
updateStatus
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
#!/bin/bash
#${JENKINS_HOME}/status/updateStatus $DSTATUS $LOGFILE ${JOB_BASE_NAME}
XDIR=$(dirname $0)
cd $XDIR
DSTATUS=$1; shift
LOGFILE=$1; shift
JOB_BASE_NAME=$*
git pull
pushd jobs > /dev/null
rm -f "${JOB_BASE_NAME}.svg"
ln -s ../images/$DSTATUS.svg "${JOB_BASE_NAME}.svg"
touch "${JOB_BASE_NAME}.$DSTATUS"
[ -s $LOGFILE ] && cp $LOGFILE "${JOB_BASE_NAME}.log"
git add "${JOB_BASE_NAME}.*"
popd > /dev/null
## rewrite readme.
JOBS=$( cd jobs ; ls -1 *.svg| sed 's/.svg//' )
cat >README.md<<XXX
## Synopsis
This file shows the status of public cen.ai tracked projects as of $(date).
## Modules
| MODULE & Logfile | Status | Detail | Test Pass | Test Fail| Build | Attempt|
| --- | --- | --- | --- | --- | --- | --- |
XXX
TODAY=$(date +'%Y-%m-%d ')
for JOBNAME in $JOBS
do
# get time stamps on each file
TP=$([ -e "jobs/$JOBNAME.TESTPASS" ] && stat -c %y "jobs/$JOBNAME.TESTPASS"| sed 's/:..\..*$//'| sed "s/$TODAY//;s/ .*$//")
TF=$([ -e "jobs/$JOBNAME.TESTFAIL" ] && stat -c %y "jobs/$JOBNAME.TESTFAIL"| sed 's/:..\..*$//'| sed "s/$TODAY//;s/ .*$//")
BP=$([ -e "jobs/$JOBNAME.BUILDPASS" ] && stat -c %y "jobs/$JOBNAME.BUILDPASS"| sed 's/:..\..*$//'| sed "s/$TODAY//;s/ .*$//")
BD=$([ -e "jobs/$JOBNAME.svg" ] && stat -c %y "jobs/$JOBNAME.svg"| sed 's/:..\..*$//'| sed "s/$TODAY//;s/ .*$//")
# get real file
MF=$(readlink -f "jobs/$JOBNAME.svg" | sed "s|$(pwd)||")
# get formatting for log file
LF=$([ -e jobs/$JOBNAME.log ] && echo "[$JOBNAME](jobs/$JOBNAME.log)" || echo "$JOBNAME")
if egrep -q '\*\*\*(Failed|Exception)' "jobs/$JOBNAME.log"
then
LM=$(grep 'tests passed' "jobs/$JOBNAME.log" | tail -1)
ANCHOR=$(echo '#'$JOBNAME|tr A-Z a-z)
LM=$(echo '['$LM']('$ANCHOR')')
else
LM=$([ -e "jobs/$JOBNAME.log" ] && grep 'tests passed' "jobs/$JOBNAME.log" | tail -1)
fi
# print
cat >>README.md<<YYY
| $LF | ![Status]($MF) | $LM | $TP | $TF | $BP | $BD |
YYY
done
cat >>README.md <<ZZZ
( Times are currently EST/EDT GMT-5/-4)
## Error Detail
ZZZ
for JOBNAME in $JOBS
do
if egrep -q '\*\*\*(Failed|Exception)' "jobs/$JOBNAME.log"
then
echo >>README.md
echo '### ' $JOBNAME >>README.md
echo '```' >>README.md
egrep '\*\*\*(Failed|Exception)' "jobs/$JOBNAME.log" | tail -24 >>README.md
echo '```' >>README.md
echo >>README.md
echo See the log file at this link: '['$JOBNAME'](jobs/'$JOBNAME.log') for more detail.'>>README.md
echo >>README.md
fi
done
cat >>README.md <<ZZZ5
## Benchmarks
ZZZ5
for JOBNAME in $JOBS
do
if egrep -q 'BENCHMARK START' "jobs/$JOBNAME.log"
then
echo >>README.md
echo '### ' $JOBNAME >>README.md
echo '```' >>README.md
sed -n '/*#*#*# BENCHMARK START/,/*#*#*# BENCHMARK END/p' "jobs/$JOBNAME.log" | grep -v '*#*#*#' >>README.md
echo '```' >>README.md
echo >>README.md
echo >>README.md
fi
done
cat >>README.md <<ZZZ4
## Contributors
Ed Guy.
## License
MIT license.
ZZZ4
git commit -am "${JOB_BASE_NAME} $DSTATUS "
git push