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 ..."
27 while getopts b
:fGR
:r
:w
: arg
; do
40 fromaddr_arg
="-r $OPTARG" ;;
44 echo "usage: $usage" >&2
48 shift $
(($OPTIND - 1))
51 if [ -z "$recipients" ]; then
52 echo "usage: $usage" >&2
59 echo \$ $@
>> $logfile
63 ncpu
=`sysctl -n hw.ncpuonline`
64 lockfile
=$worktree/.
${prog}.lock
66 cd "$worktree" ||
exit 1
68 lockfile
-r 3 "$lockfile" ||
exit 1
69 trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
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" -ne 0 ]; then
88 mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
91 new_basecommit
=`cat .got/base-commit`
93 if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
97 printf "\n\n\tTesting a regular dev build\n\n" >> build.log
98 log_cmd build.log
make obj
99 log_cmd build.log
make -j $ncpu
101 if [ "$build_status" -ne 0 ]; then
102 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
105 log_cmd build.log
make install
106 log_cmd build.log
make -j $ncpu webd
108 if [ "$build_status" -ne 0 ]; then
109 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
112 log_cmd build.log
make -j $ncpu server
114 if [ "$build_status" -ne 0 ]; then
115 mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
118 log_cmd build.log
make server-install
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" -ne 0 -o "$regress_failure_grep" -eq 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
133 printf "\n\n\tRunning tests with pack files\n\n" >> build.log
134 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_PACK
=1
136 cat regress.log
>> build.log
137 egrep "test.*failed" regress.log
> failures.log
138 regress_failure_grep
="$?"
139 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
140 printf "\n\n\t Test failures:\n\n" >> build.log
141 cat failures.log
>> build.log
142 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
146 printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
147 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_PACK
=ref-delta
149 cat regress.log
>> build.log
150 egrep "test.*failed" regress.log
> failures.log
151 regress_failure_grep
="$?"
152 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
153 printf "\n\n\t Test failures:\n\n" >> build.log
154 cat failures.log
>> build.log
155 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
159 printf "\n\n\tRunning tests with sha256\n\n" >> build.log
160 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_ALGO
=sha256
162 cat regress.log
>> build.log
163 egrep "test.*failed" regress.log
> failures.log
164 regress_failure_grep
="$?"
165 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
166 printf "\n\n\t Test failures:\n\n" >> build.log
167 cat failures.log
>> build.log
168 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
172 printf "\n\n\tRunning tests with sha256 and pack files\n\n" >> build.log
173 log_cmd regress.log env PATH
=$HOME/bin
:$PATH make regress GOT_TEST_ROOT
="$testroot" GOT_TEST_ALGO
=sha256 GOT_TEST_PACK
=1
175 cat regress.log
>> build.log
176 egrep "test.*failed" regress.log
> failures.log
177 regress_failure_grep
="$?"
178 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
179 printf "\n\n\t Test failures:\n\n" >> build.log
180 cat failures.log
>> build.log
181 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
185 if [ $gotd -ne 0 ]; then
186 printf "\n\n\tRunning gotd tests\n\n" >> build.log
187 log_cmd regress.log doas env PATH
=$HOME/bin
:$PATH make server-regress
189 cat regress.log
>> build.log
190 egrep "test.*failed" regress.log
> failures.log
191 regress_failure_grep
="$?"
192 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
193 printf "\n\n\t Test failures:\n\n" >> build.log
194 cat failures.log
>> build.log
195 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
200 if [ $webd -ne 0 ]; then
201 printf "\n\n\tRunning gotwebd tests\n\n" >> build.log
202 log_cmd regress.log doas env PATH
=$HOME/bin
:$PATH make webd-regress
204 cat regress.log
>> build.log
205 egrep "test.*failed" regress.log
> failures.log
206 regress_failure_grep
="$?"
207 if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
208 printf "\n\n\t Test failures:\n\n" >> build.log
209 cat failures.log
>> build.log
210 mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
215 printf "\n\n\tTesting a release build\n\n" >> build.log
216 log_cmd build.log
make clean
217 log_cmd build.log
make obj
218 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes
219 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes webd
220 log_cmd build.log
make -j $ncpu GOT_RELEASE
=Yes server
222 if [ "$build_status" -ne 0 ]; then
223 mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log