-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathfate-recv.sh
More file actions
executable file
·124 lines (103 loc) · 3.56 KB
/
fate-recv.sh
File metadata and controls
executable file
·124 lines (103 loc) · 3.56 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
#! /bin/sh
#
# Copyright (c) 2011 Mans Rullgard <mans@mansr.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -e
export LC_ALL=C
die(){
echo "$@"
exit 1
}
test -n "$FATEDIR" || die "FATEDIR not set"
test -n "$FATE_USER" || die "FATE_USER not set"
reptmp=$(mktemp -d)
trap 'rm -r $reptmp' EXIT
cd $reptmp
tar xzk
header=$(head -n1 report)
# Can't use expr on this one because $version might be 0
version=$(echo "$header" | sed "s/^fate:\([0-9]*\):.*/\1/")
date=$(expr "$header" : "fate:$version:\([0-9]*\):")
slot=$(expr "$header" : "fate:$version:$date:\([A-Za-z0-9_.-]*\):")
rev=$(expr "$header" : "fate:$version:$date:$slot:\([A-Za-z0-9_.-]*\):")
branch=master
if [ $version -eq 1 ]; then
branch=$(expr "$header" : "fate:$version:$date:$slot:$rev:[0-9]*:[ A-Za-z0-9_.-]*:\([A-Za-z0-9_.-\/]*\):")
branch=$(echo "$branch" | sed 's,^release/,v,')
fi
test -e "$FATEDIR/branches" || touch "$FATEDIR/branches"
grep -q "^$branch$" "$FATEDIR/branches" || \
[ "$branch" = 'master' ] || \
(echo "$branch" >>"$FATEDIR/branches" && \
echo "Setting up new branch $branch" >&2)
test -n "$date" && test -n "$slot" || die "Invalid report header"
slotdir=$FATEDIR/$slot
if [ -d "$slotdir" ]; then
echo "$FATE_USER" >"$slotdir/owner"
owner=$(cat "$slotdir/owner")
test "$owner" = "$FATE_USER" || die "Slot $slot owned by somebody else"
else
echo "$slot" >> /home/fate/newslots
mkdir "$slotdir"
echo "$FATE_USER" >"$slotdir/owner"
fi
exec <report
head -n2 >summary
ntest=0
npass=0
IFS=:
exec >pass
while read name status rest; do
if [ "$status" = 0 ]; then
echo "$name:$date:$rev"
npass=$(($npass+1))
fi
ntest=$(($ntest+1))
done
exec <&- >&-
upass(){
read pname pdate prev || return 0
# Because we `sort`ed the input before passing it to upass, same tests
# always in couplets in the order of new to old.
while read lname ldate lrev; do
# If the second line describes the same test, discard it because it's
# the old result.
test "$lname" != "$pname" && echo "$pname:$pdate:$prev"
pname=$lname
pdate=$ldate
prev=$lrev
done
echo "$pname:$pdate:$prev"
}
lastpass=$slotdir/lastpass
if [ -r $lastpass ]; then
sort pass $lastpass | upass >lastpass
else
sort -o lastpass pass
fi
unset IFS
nwarn=$(grep -Eci '\<warning\>' compile.log) || nwarn=0
echo "stats:$ntest:$npass:$nwarn" >>summary
repdir=$slotdir/$date
mkdir $repdir
gzip -9 *.log
xz -8 report
cp -p summary report.xz *.log.gz $repdir
chmod 644 $repdir/*
rm -f $slotdir/previous
test -e $slotdir/latest && mv $slotdir/latest $slotdir/previous
ln -s $date $slotdir/latest
cp lastpass ${lastpass}.new && mv ${lastpass}.new $lastpass
# /home/fate/.nvm/versions/node/v4.3.1/bin/node /home/fate/mongo-experiments/process/migrate.js "$slot" "$date" "$date"
# /home/fate/.nvm/versions/node/v4.3.1/bin/node /home/fate/mongo-experiments/process/link2.js "$slot"