3 18f89b62 2020-04-14 stsp # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
5 18f89b62 2020-04-14 stsp # Permission to use, copy, modify, and distribute this software for any
6 18f89b62 2020-04-14 stsp # purpose with or without fee is hereby granted, provided that the above
7 18f89b62 2020-04-14 stsp # copyright notice and this permission notice appear in all copies.
9 18f89b62 2020-04-14 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 18f89b62 2020-04-14 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 18f89b62 2020-04-14 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 18f89b62 2020-04-14 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 18f89b62 2020-04-14 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 18f89b62 2020-04-14 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 18f89b62 2020-04-14 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 18f89b62 2020-04-14 stsp prog=`basename $0`
18 125fc911 2023-12-18 op usage="$prog [-fG] [-b branch] [-R testroot] [-r from-address] [-w worktree] email-address ..."
20 18f89b62 2020-04-14 stsp worktree=$HOME/got
21 e6db6399 2020-09-20 stsp fromaddr_arg=
24 905472e8 2021-06-23 stsp testroot="/tmp"
26 125fc911 2023-12-18 op while getopts b:fGR:r:w: arg; do
29 de9bfe52 2023-01-08 op branch="$OPTARG" ;;
35 de9bfe52 2023-01-08 op worktree="$OPTARG" ;;
37 de9bfe52 2023-01-08 op fromaddr_arg="-r $OPTARG" ;;
39 de9bfe52 2023-01-08 op testroot="$OPTARG" ;;
41 de9bfe52 2023-01-08 op echo "usage: $usage" >&2
45 de9bfe52 2023-01-08 op shift $(($OPTIND - 1))
47 18f89b62 2020-04-14 stsp recipients="$@"
48 18f89b62 2020-04-14 stsp if [ -z "$recipients" ]; then
49 18f89b62 2020-04-14 stsp echo "usage: $usage" >&2
56 18f89b62 2020-04-14 stsp echo \$ $@ >> $logfile
57 18f89b62 2020-04-14 stsp $* >> $logfile 2>&1
60 18f89b62 2020-04-14 stsp ncpu=`sysctl -n hw.ncpuonline`
61 18f89b62 2020-04-14 stsp lockfile=$worktree/.${prog}.lock
63 243a8f15 2023-01-08 op cd "$worktree" || exit 1
65 18f89b62 2020-04-14 stsp lockfile -r 3 "$lockfile" || exit 1
66 243a8f15 2023-01-08 op trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
68 18f89b62 2020-04-14 stsp rm -f regress.log failures.log
69 18f89b62 2020-04-14 stsp echo -n "$prog for branch '$branch' on " > build.log
70 18f89b62 2020-04-14 stsp date -u >> build.log
72 18f89b62 2020-04-14 stsp printf "\nRunning on " >> build.log
73 18f89b62 2020-04-14 stsp sysctl -n kern.version >> build.log
75 18f89b62 2020-04-14 stsp printf "\n\tCleaning the work tree\n\n" >> build.log
76 18f89b62 2020-04-14 stsp log_cmd build.log got status
77 18f89b62 2020-04-14 stsp log_cmd build.log make clean
79 18f89b62 2020-04-14 stsp printf "\n\n\tUpdating the work tree\n\n" >> build.log
80 18f89b62 2020-04-14 stsp log_cmd build.log cat .got/base-commit
81 18f89b62 2020-04-14 stsp old_basecommit=`cat .got/base-commit`
82 18f89b62 2020-04-14 stsp log_cmd build.log /usr/local/bin/got update -b "$branch"
83 18f89b62 2020-04-14 stsp update_status="$?"
84 bcfa81c7 2023-02-17 op if [ "$update_status" -ne 0 ]; then
85 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
88 18f89b62 2020-04-14 stsp new_basecommit=`cat .got/base-commit`
90 bcfa81c7 2023-02-17 op if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
94 18f89b62 2020-04-14 stsp printf "\n\n\tTesting a regular dev build\n\n" >> build.log
95 18f89b62 2020-04-14 stsp log_cmd build.log make obj
96 18f89b62 2020-04-14 stsp log_cmd build.log make -j $ncpu
97 18f89b62 2020-04-14 stsp build_status="$?"
98 bcfa81c7 2023-02-17 op if [ "$build_status" -ne 0 ]; then
99 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
102 18f89b62 2020-04-14 stsp log_cmd build.log make install
103 06991378 2022-12-30 tracey log_cmd build.log make -j $ncpu webd
104 18f89b62 2020-04-14 stsp build_status="$?"
105 bcfa81c7 2023-02-17 op if [ "$build_status" -ne 0 ]; then
106 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
109 d35c69f0 2023-02-17 op log_cmd build.log make -j $ncpu server
110 d35c69f0 2023-02-17 op build_status="$?"
111 d35c69f0 2023-02-17 op if [ "$build_status" -ne 0 ]; then
112 d35c69f0 2023-02-17 op mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
115 d4b583a2 2023-12-19 op log_cmd build.log make server-install
117 18f89b62 2020-04-14 stsp printf "\n\n\tRunning tests\n\n" >> build.log
118 905472e8 2021-06-23 stsp log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot"
119 18f89b62 2020-04-14 stsp regress_status="$?"
120 18f89b62 2020-04-14 stsp cat regress.log >> build.log
121 18f89b62 2020-04-14 stsp egrep "test.*failed" regress.log > failures.log
122 18f89b62 2020-04-14 stsp regress_failure_grep="$?"
123 bcfa81c7 2023-02-17 op if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
124 18f89b62 2020-04-14 stsp printf "\n\n\t Test failures:\n\n" >> build.log
125 18f89b62 2020-04-14 stsp cat failures.log >> build.log
126 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
130 c5c77d29 2021-10-14 stsp printf "\n\n\tRunning tests with pack files\n\n" >> build.log
131 c5c77d29 2021-10-14 stsp log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=1
132 c5c77d29 2021-10-14 stsp regress_status="$?"
133 c5c77d29 2021-10-14 stsp cat regress.log >> build.log
134 c5c77d29 2021-10-14 stsp egrep "test.*failed" regress.log > failures.log
135 c5c77d29 2021-10-14 stsp regress_failure_grep="$?"
136 bcfa81c7 2023-02-17 op if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
137 c5c77d29 2021-10-14 stsp printf "\n\n\t Test failures:\n\n" >> build.log
138 c5c77d29 2021-10-14 stsp cat failures.log >> build.log
139 c5c77d29 2021-10-14 stsp mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
143 bfeaf206 2023-02-17 op printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
144 bfeaf206 2023-02-17 op log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=ref-delta
145 bfeaf206 2023-02-17 op regress_status="$?"
146 bfeaf206 2023-02-17 op cat regress.log >> build.log
147 bfeaf206 2023-02-17 op egrep "test.*failed" regress.log > failures.log
148 bfeaf206 2023-02-17 op regress_failure_grep="$?"
149 bfeaf206 2023-02-17 op if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
150 bfeaf206 2023-02-17 op printf "\n\n\t Test failures:\n\n" >> build.log
151 bfeaf206 2023-02-17 op cat failures.log >> build.log
152 bfeaf206 2023-02-17 op mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
156 125fc911 2023-12-18 op if [ $gotd -ne 0 ]; then
157 125fc911 2023-12-18 op printf "\n\n\tRunning gotd tests\n\n" >> build.log
158 125fc911 2023-12-18 op log_cmd regress.log doas env PATH=$HOME/bin:$PATH make server-regress
159 125fc911 2023-12-18 op regress_status=$?
160 125fc911 2023-12-18 op cat regress.log >> build.log
161 125fc911 2023-12-18 op egrep "test.*failed" regress.log > failures.log
162 125fc911 2023-12-18 op regress_failure_grep="$?"
163 125fc911 2023-12-18 op if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
164 125fc911 2023-12-18 op printf "\n\n\t Test failures:\n\n" >> build.log
165 125fc911 2023-12-18 op cat failures.log >> build.log
166 125fc911 2023-12-18 op mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
171 18f89b62 2020-04-14 stsp printf "\n\n\tTesting a release build\n\n" >> build.log
172 18f89b62 2020-04-14 stsp log_cmd build.log make clean
173 18f89b62 2020-04-14 stsp log_cmd build.log make obj
174 bc90a07f 2020-05-05 stsp log_cmd build.log make -j $ncpu GOT_RELEASE=Yes
175 06991378 2022-12-30 tracey log_cmd build.log make -j $ncpu GOT_RELEASE=Yes webd
176 d35c69f0 2023-02-17 op log_cmd build.log make -j $ncpu GOT_RELEASE=Yes server
177 18f89b62 2020-04-14 stsp build_status="$?"
178 bcfa81c7 2023-02-17 op if [ "$build_status" -ne 0 ]; then
179 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log