forked from facebook/wdt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwdt_cont_build_run_diff.tcl
executable file
·165 lines (150 loc) · 5.33 KB
/
wdt_cont_build_run_diff.tcl
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
153
154
155
156
157
158
159
160
161
162
163
164
165
#! /usr/bin/env tclsh
# run _setup once and then this will run a loop and email results
# TODO: rewrite in python
set diff [lindex $argv 0]
puts "Working on diff $diff"
if {[string length $diff]==0} {
puts stderr "Need DXXXXX argument"
}
# In order for /data/users/$USER to be different than default when creating
# wdtTest for xfs test but exists and so those directory which we rm
# don't conflict with the users' normal runs we hack the USER env var:
append ::env(USER) "_wdt_contbuild"
set userdir $::env(USER)
puts "Will run script with USER env = $userdir"
set CDIR "/data/users/$userdir"
# path and ld library path
set ::env(PATH) "$CDIR/bin:$::env(PATH)"
if {[info exists ::env(LD_LIBRARY_PATH)]} {
set ::env(LD_LIBRARY_PATH) "$CDIR/lib:$::env(LD_LIBRARY_PATH)"
} else {
set ::env(LD_LIBRARY_PATH) "$CDIR/lib"
}
puts "PATH=$::env(PATH) LD_LIBRARY_PATH=$::env(LD_LIBRARY_PATH)"
# extra stuff in the topic (where this is running/patch/.... etc)
set EXTRA ""
if {[info exists ::env(WDT_CONTBUILD_EXTRA_SUBJECT)]} {
set EXTRA $::env(WDT_CONTBUILD_EXTRA_SUBJECT)
}
# Email to/from
set TO "[email protected]"
set FROM $TO
# start first build right away, helps testing, will use previous 10min TS/name
set DELTA 0
proc printDate {ts} {
puts "[clock format $ts]"
}
proc sleep {time} {
after [expr $time*1000] set end 1
vwait end
}
# we will email for the first change
set last {}
# previous hg log for wdt (will cause email first too)
set hgprev {none}
# also email every x :
set emailEvery "6 hours"
proc nextEmail {} {
global nextEmail emailEvery
set nextEmail [clock scan $emailEvery]
puts "Will email after [clock format $nextEmail]"
}
proc sendEmail {reason} {
global type msg TO FROM LOGF EXTRA diff
puts "Sending email to $TO because: $reason"
set emailFileName ${LOGF}.email
# Email headers
set f [open $emailFileName w]
puts $f "From: $FROM"
puts $f "To: $TO"
puts $f "Subject: WDT build: ${type}-${diff}${EXTRA}: $msg ($reason)"
puts $f {Content-type: text/plain; charset="UTF-8"}
puts $f ""; # seperate headers from body
puts $f "filtered log, full log at https://fburl.com/wdt_${type}_builds"
close $f
# rest of the body of the email:
# filters info and vlog and normal compilation times:
exec egrep -v {^([IV]| [0-9].[0-9][0-9]s )} $LOGF >> $emailFileName
# Sending both
exec sendmail $TO < $emailFileName
file delete $emailFileName
nextEmail
}
nextEmail
cd $CDIR/fbsource/fbcode
# only 2 types for now - either 'open source' on the mac or full otherwise
set os [exec uname]
if {$os == "Darwin"} {
set type "mac"
set extraCmds "echo done"
set targetDir "/usr/local/var/www/wdt_builds/"
set sudo ""
} else {
set type "unix"
set extraCmds "cd $CDIR/fbsource/fbcode &&\
(sudo tc qdisc del dev lo root; sudo ip6tables --flush || true) &&\
time fbconfig --clang -r wdt &&\
time fbmake opt &&\
time wdt/test/wdt_max_send_test.sh |& tail -50 &&\
time wdt/test/wdt_max_send_test.sh _bin/wdt/fbonly/wdt_fb |& tail -50 &&\
time fbconfig --sanitize address -r wdt &&\
time fbmake dbg &&\
time fbmake runtests --run-disabled --return-nonzero-on-timeouts &&\
sudo tc qdisc add dev lo root netem delay 20ms 10ms \
duplicate 1% corrupt 0.1% &&\
echo rerunning tests with tc delays &&\
time fbmake runtests --run-disabled --return-nonzero-on-timeouts &&\
sudo tc qdisc del dev lo root"
set targetDir "~/public_html/wdt_builds/"
set sudo "sudo"
}
while {1} {
# round the time to 10 minutes (in part so log files aren't growing forever)
set now [clock seconds]
printDate $now
set tenmin [expr {($now+$DELTA*60)/600*600}]
printDate $tenmin
set sleep [expr $tenmin-$now]
puts "Sleeping $sleep seconds"
sleep $sleep
# after first time, run X mins from now
set DELTA 10; # minutes
set LOGTS [clock format $tenmin -format %d%H%M]
set LOGF "$CDIR/$LOGTS.log"
puts "Logging to $LOGF"
# cleanup previous builds failure - sudo not needed/asking for passwd on mac
if {[catch {exec sh -c "set -o pipefail; set -x; date; uname -a;\
$sudo rm -rf /tmp/wdtTest_$userdir /dev/shm/wdtTest_$userdir wdtTest &&\
cd $CDIR/fbsource/fbcode && (hg book -d arcpatch-$diff || true) &&\
time hg pull && arc patch $diff &&\
( time hg rebase -d master || true ) &&\
hg bookmark -v &&\
hg log -l 2 && hg log -v -l 1 folly && hg log -v -l 2 wdt &&\
cd $CDIR/cmake_wdt_build && time make -j 4 && \
CTEST_OUTPUT_ON_FAILURE=1 time make test &&\
$extraCmds" >& $LOGF < /dev/null} results options]} {
set msg "BAD"
} else {
set msg "GOOD"
}
puts $msg
catch {exec hg log -l 2 -T "{rev}\n" wdt | tail -1} hgout
puts "wdt changeset now $hgout"
if {[string length $last]==0} {
sendEmail "contbuild restarted"
} elseif {[string compare $hgout $hgprev]} {
sendEmail "hg log wdt change"
} elseif {[string compare $last $msg]} {
# Build changed from $last to $msg
sendEmail "was $last"
} elseif {[clock seconds]>$nextEmail} {
# periodic emails
sendEmail "every $emailEvery email"
}
# works with fburl homedirs
set target "${targetDir}${LOGTS}_${msg}.log"
file copy -force $LOGF $target
puts "Copied to $target"
set last $msg
set hgprev $hgout
}