3 # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 usage="$prog [-b branch] [-f] [-w worktree ] [ -r from-address ] email-address [email-address ...]"
24 args=`getopt b:fw:r: $*`
27 echo "usage: $usage" >&2
31 while [ $# -ne 0 ]; do
35 branch="$2"; shift; shift;;
39 worktree="$2"; shift; shift;;
41 fromaddr_arg="-r $2"; shift; shift;;
48 if [ -z "$recipients" ]; then
49 echo "usage: $usage" >&2
56 echo \$ $@ >> $logfile
60 ncpu=`sysctl -n hw.ncpuonline`
61 lockfile=$worktree/.${prog}.lock
68 lockfile -r 3 "$lockfile" || exit 1
69 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM
71 rm -f regress.log failures.log
72 echo -n "$prog for branch '$branch' on " > build.log
75 printf "\nRunning on " >> build.log
76 sysctl -n kern.version >> build.log
78 printf "\n\tCleaning the work tree\n\n" >> build.log
79 log_cmd build.log got status
80 log_cmd build.log make clean
82 printf "\n\n\tUpdating the work tree\n\n" >> build.log
83 log_cmd build.log cat .got/base-commit
84 old_basecommit=`cat .got/base-commit`
85 log_cmd build.log /usr/local/bin/got update -b "$branch"
87 if [ "$update_status" != "0" ]; then
88 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
92 new_basecommit=`cat .got/base-commit`
94 if [ "$force" != "1" -a "$old_basecommit" == "$new_basecommit" ]; then
99 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
100 log_cmd build.log make obj
101 log_cmd build.log make -j $ncpu
103 if [ "$build_status" != "0" ]; then
104 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
108 log_cmd build.log make install
109 log_cmd build.log make -j $ncpu web
111 if [ "$build_status" != "0" ]; then
112 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
117 printf "\n\n\tRunning tests\n\n" >> build.log
118 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress
120 cat regress.log >> build.log
121 egrep "test.*failed" regress.log > failures.log
122 regress_failure_grep="$?"
123 if [ "$regress_status" != "0" -o "$regress_failure_grep" == "0" ]; then
124 printf "\n\n\t Test failures:\n\n" >> build.log
125 cat failures.log >> build.log
126 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
131 printf "\n\n\tTesting a release build\n\n" >> build.log
132 log_cmd build.log make clean
133 log_cmd build.log make obj
134 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
135 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes web
137 if [ "$build_status" != "0" ]; then
138 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log