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 [-f] [-b branch] [-R testroot] [-r from-address] [-w worktree] email-address ..."
25 while getopts b:fR:r:w: arg; do
34 fromaddr_arg="-r $OPTARG" ;;
38 echo "usage: $usage" >&2
42 shift $(($OPTIND - 1))
45 if [ -z "$recipients" ]; then
46 echo "usage: $usage" >&2
53 echo \$ $@ >> $logfile
57 ncpu=`sysctl -n hw.ncpuonline`
58 lockfile=$worktree/.${prog}.lock
60 cd "$worktree" || exit 1
62 lockfile -r 3 "$lockfile" || exit 1
63 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
65 rm -f regress.log failures.log
66 echo -n "$prog for branch '$branch' on " > build.log
69 printf "\nRunning on " >> build.log
70 sysctl -n kern.version >> build.log
72 printf "\n\tCleaning the work tree\n\n" >> build.log
73 log_cmd build.log got status
74 log_cmd build.log make clean
76 printf "\n\n\tUpdating the work tree\n\n" >> build.log
77 log_cmd build.log cat .got/base-commit
78 old_basecommit=`cat .got/base-commit`
79 log_cmd build.log /usr/local/bin/got update -b "$branch"
81 if [ "$update_status" -ne 0 ]; then
82 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
85 new_basecommit=`cat .got/base-commit`
87 if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
91 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
92 log_cmd build.log make obj
93 log_cmd build.log make -j $ncpu
95 if [ "$build_status" -ne 0 ]; then
96 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
99 log_cmd build.log make install
100 log_cmd build.log make -j $ncpu webd
102 if [ "$build_status" -ne 0 ]; then
103 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
106 log_cmd build.log make -j $ncpu server
108 if [ "$build_status" -ne 0 ]; then
109 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
113 printf "\n\n\tRunning tests\n\n" >> build.log
114 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot"
116 cat regress.log >> build.log
117 egrep "test.*failed" regress.log > failures.log
118 regress_failure_grep="$?"
119 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
120 printf "\n\n\t Test failures:\n\n" >> build.log
121 cat failures.log >> build.log
122 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
126 printf "\n\n\tRunning tests with pack files\n\n" >> build.log
127 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=1
129 cat regress.log >> build.log
130 egrep "test.*failed" regress.log > failures.log
131 regress_failure_grep="$?"
132 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
133 printf "\n\n\t Test failures:\n\n" >> build.log
134 cat failures.log >> build.log
135 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
139 printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
140 log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=ref-delta
142 cat regress.log >> build.log
143 egrep "test.*failed" regress.log > failures.log
144 regress_failure_grep="$?"
145 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
146 printf "\n\n\t Test failures:\n\n" >> build.log
147 cat failures.log >> build.log
148 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
152 printf "\n\n\tTesting a release build\n\n" >> build.log
153 log_cmd build.log make clean
154 log_cmd build.log make obj
155 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
156 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes webd
157 log_cmd build.log make -j $ncpu GOT_RELEASE=Yes server
159 if [ "$build_status" -ne 0 ]; then
160 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log