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 ] [-R testroot] email-address [email-address ...]"
25 args=`getopt b:fw:r:R: $*`
28 echo "usage: $usage" >&2
32 while [ $# -ne 0 ]; do
36 branch="$2"; shift; shift;;
40 worktree="$2"; shift; shift;;
42 fromaddr_arg="-r $2"; shift; shift;;
44 testroot="$2"; shift; shift;;
51 if [ -z "$recipients" ]; then
52 echo "usage: $usage" >&2
59 echo \$ $@ >> $logfile
63 ncpu=`sysctl -n hw.ncpuonline`
64 lockfile=$worktree/.${prog}.lock
71 lockfile -r 3 "$lockfile" || exit 1
72 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM
74 rm -f regress.log failures.log
75 echo -n "$prog for branch '$branch' on " > build.log
78 printf "\nRunning on " >> build.log
79 sysctl -n kern.version >> build.log
81 printf "\n\tCleaning the work tree\n\n" >> build.log
82 log_cmd build.log got status
83 log_cmd build.log make clean
85 printf "\n\n\tUpdating the work tree\n\n" >> build.log
86 log_cmd build.log cat .got/base-commit
87 old_basecommit=`cat .got/base-commit`
88 log_cmd build.log /usr/local/bin/got update -b "$branch"
90 if [ "$update_status" != "0" ]; then
91 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
95 new_basecommit=`cat .got/base-commit`
97 if [ "$force" != "1" -a "$old_basecommit" == "$new_basecommit" ]; then
102 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
103 log_cmd build.log make obj
104 log_cmd build.log make -j $ncpu
106 if [ "$build_status" != "0" ]; then
107 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
111 log_cmd build.log make install
112 log_cmd build.log make -j $ncpu web
114 if [ "$build_status" != "0" ]; then
115 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
120 printf "\n\n\tRunning tests\n\n" >> build.log
121 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot"
123 cat regress.log >> build.log
124 egrep "test.*failed" regress.log > failures.log
125 regress_failure_grep="$?"
126 if [ "$regress_status" != "0" -o "$regress_failure_grep" == "0" ]; then
127 printf "\n\n\t Test failures:\n\n" >> build.log
128 cat failures.log >> build.log
129 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
134 printf "\n\n\tRunning tests with pack files\n\n" >> build.log
135 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=1
137 cat regress.log >> build.log
138 egrep "test.*failed" regress.log > failures.log
139 regress_failure_grep="$?"
140 if [ "$regress_status" != "0" -o "$regress_failure_grep" == "0" ]; then
141 printf "\n\n\t Test failures:\n\n" >> build.log
142 cat failures.log >> build.log
143 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
148 printf "\n\n\tTesting a release build\n\n" >> build.log
149 log_cmd build.log make clean
150 log_cmd build.log make obj
151 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
152 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes web
154 if [ "$build_status" != "0" ]; then
155 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log