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 ] email-address [email-address ...]"
23 args=`getopt b:fw: $*`
26 echo "usage: $usage" >&2
30 while [ $# -ne 0 ]; do
34 branch="$2"; shift; shift;;
38 worktree="$2"; shift; shift;;
45 if [ -z "$recipients" ]; then
46 echo "usage: $usage" >&2
53 echo \$ $@ >> $logfile
57 ncpu=`sysctl -n hw.ncpuonline`
58 lockfile=$worktree/.${prog}.lock
65 lockfile -r 3 "$lockfile" || exit 1
66 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM
68 rm -f regress.log failures.log
69 echo -n "$prog for branch '$branch' on " > build.log
72 printf "\nRunning on " >> build.log
73 sysctl -n kern.version >> build.log
75 printf "\n\tCleaning the work tree\n\n" >> build.log
76 log_cmd build.log got status
77 log_cmd build.log make clean
79 printf "\n\n\tUpdating the work tree\n\n" >> build.log
80 log_cmd build.log cat .got/base-commit
81 old_basecommit=`cat .got/base-commit`
82 log_cmd build.log /usr/local/bin/got update -b "$branch"
84 if [ "$update_status" != "0" ]; then
85 mail -s "$prog update failure" $recipients < build.log
89 new_basecommit=`cat .got/base-commit`
91 if [ "$force" != "1" -a "$old_basecommit" == "$new_basecommit" ]; then
96 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
97 log_cmd build.log make obj
98 log_cmd build.log make -j $ncpu
100 if [ "$build_status" != "0" ]; then
101 mail -s "$prog build failure" $recipients < build.log
105 log_cmd build.log make install
106 log_cmd build.log make -j $ncpu web
108 if [ "$build_status" != "0" ]; then
109 mail -s "$prog build failure" $recipients < build.log
114 printf "\n\n\tRunning tests\n\n" >> build.log
115 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress
117 cat regress.log >> build.log
118 egrep "test.*failed" regress.log > failures.log
119 regress_failure_grep="$?"
120 if [ "$regress_status" != "0" -o "$regress_failure_grep" == "0" ]; then
121 printf "\n\n\t Test failures:\n\n" >> build.log
122 cat failures.log >> build.log
123 mail -s "$prog regress failure" $recipients < build.log
128 printf "\n\n\tTesting a release build\n\n" >> build.log
129 log_cmd build.log make clean
130 log_cmd build.log make obj
131 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
132 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes web
134 if [ "$build_status" != "0" ]; then
135 mail -s "$prog release mode build failure" $recipients < build.log