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 [-fG] [-b branch] [-R testroot] [-r from-address] [-w worktree] email-address ..."
26 while getopts b
:fGR
:r
:w
: arg
; do
37 fromaddr_arg
="-r $OPTARG" ;;
41 echo "usage: $usage" >&2
45 shift $
(($OPTIND - 1))
48 if [ -z "$recipients" ]; then
49 echo "usage: $usage" >&2
56 echo \$ $@
>> $logfile
60 ncpu
=`sysctl -n hw.ncpuonline`
61 lockfile
=$worktree/.
${prog}.lock
63 cd "$worktree" ||
exit 1
65 lockfile
-r 3 "$lockfile" ||
exit 1
66 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
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" -ne 0 ]; then
85 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
88 new_basecommit
=`cat .got/base-commit`
90 if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
94 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
95 log_cmd build.log
make obj
96 log_cmd build.log
make -j $ncpu
98 if [ "$build_status" -ne 0 ]; then
99 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
102 log_cmd build.log
make install
103 log_cmd build.log
make -j $ncpu webd
105 if [ "$build_status" -ne 0 ]; then
106 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
109 log_cmd build.log
make -j $ncpu server
111 if [ "$build_status" -ne 0 ]; then
112 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
115 log_cmd build.log
make server-install
117 printf "\n\n\tRunning tests\n\n" >> build.log
118 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot"
120 cat regress.log
>> build.log
121 egrep "test.*failed" regress.log
> failures.log
122 regress_failure_grep
="$?"
123 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 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
130 printf "\n\n\tRunning tests with pack files\n\n" >> build.log
131 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_PACK
=1
133 cat regress.log
>> build.log
134 egrep "test.*failed" regress.log
> failures.log
135 regress_failure_grep
="$?"
136 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
137 printf "\n\n\t Test failures:\n\n" >> build.log
138 cat failures.log
>> build.log
139 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
143 printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
144 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_PACK
=ref-delta
146 cat regress.log
>> build.log
147 egrep "test.*failed" regress.log
> failures.log
148 regress_failure_grep
="$?"
149 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
150 printf "\n\n\t Test failures:\n\n" >> build.log
151 cat failures.log
>> build.log
152 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
156 if [ $gotd -ne 0 ]; then
157 printf "\n\n\tRunning gotd tests\n\n" >> build.log
158 log_cmd regress.log doas env PATH
=$HOME/bin
:$PATH make server-regress
160 cat regress.log
>> build.log
161 egrep "test.*failed" regress.log
> failures.log
162 regress_failure_grep
="$?"
163 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
164 printf "\n\n\t Test failures:\n\n" >> build.log
165 cat failures.log
>> build.log
166 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
171 printf "\n\n\tTesting a release build\n\n" >> build.log
172 log_cmd build.log
make clean
173 log_cmd build.log
make obj
174 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes
175 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes webd
176 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes server
178 if [ "$build_status" -ne 0 ]; then
179 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log