Blame


1 18f89b62 2020-04-14 stsp #!/bin/sh
2 18f89b62 2020-04-14 stsp #
3 18f89b62 2020-04-14 stsp # Copyright (c) 2020 Stefan Sperling <stsp@openbsd.org>
4 18f89b62 2020-04-14 stsp #
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.
8 18f89b62 2020-04-14 stsp #
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.
16 18f89b62 2020-04-14 stsp
17 18f89b62 2020-04-14 stsp prog=`basename $0`
18 370dd2e6 2023-12-18 thomas usage="$prog [-fG] [-b branch] [-R testroot] [-r from-address] [-w worktree] email-address ..."
19 9c1dd3ec 2021-06-23 stsp branch=main
20 18f89b62 2020-04-14 stsp worktree=$HOME/got
21 e6db6399 2020-09-20 stsp fromaddr_arg=
22 18f89b62 2020-04-14 stsp force=0
23 370dd2e6 2023-12-18 thomas gotd=0
24 905472e8 2021-06-23 stsp testroot="/tmp"
25 18f89b62 2020-04-14 stsp
26 370dd2e6 2023-12-18 thomas while getopts b:fGR:r:w: arg; do
27 b891075b 2023-01-08 thomas case $arg in
28 b891075b 2023-01-08 thomas b)
29 b891075b 2023-01-08 thomas branch="$OPTARG" ;;
30 b891075b 2023-01-08 thomas f)
31 b891075b 2023-01-08 thomas force=1 ;;
32 370dd2e6 2023-12-18 thomas G)
33 370dd2e6 2023-12-18 thomas gotd=1 ;;
34 b891075b 2023-01-08 thomas w)
35 b891075b 2023-01-08 thomas worktree="$OPTARG" ;;
36 b891075b 2023-01-08 thomas r)
37 b891075b 2023-01-08 thomas fromaddr_arg="-r $OPTARG" ;;
38 b891075b 2023-01-08 thomas R)
39 b891075b 2023-01-08 thomas testroot="$OPTARG" ;;
40 b891075b 2023-01-08 thomas ?)
41 b891075b 2023-01-08 thomas echo "usage: $usage" >&2
42 b891075b 2023-01-08 thomas exit 1 ;;
43 18f89b62 2020-04-14 stsp esac
44 18f89b62 2020-04-14 stsp done
45 b891075b 2023-01-08 thomas shift $(($OPTIND - 1))
46 18f89b62 2020-04-14 stsp
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
50 18f89b62 2020-04-14 stsp exit 1
51 18f89b62 2020-04-14 stsp fi
52 18f89b62 2020-04-14 stsp
53 18f89b62 2020-04-14 stsp log_cmd() {
54 18f89b62 2020-04-14 stsp logfile=$1
55 18f89b62 2020-04-14 stsp shift
56 18f89b62 2020-04-14 stsp echo \$ $@ >> $logfile
57 18f89b62 2020-04-14 stsp $* >> $logfile 2>&1
58 18f89b62 2020-04-14 stsp }
59 18f89b62 2020-04-14 stsp
60 18f89b62 2020-04-14 stsp ncpu=`sysctl -n hw.ncpuonline`
61 18f89b62 2020-04-14 stsp lockfile=$worktree/.${prog}.lock
62 18f89b62 2020-04-14 stsp
63 a2f760e6 2023-01-08 thomas cd "$worktree" || exit 1
64 18f89b62 2020-04-14 stsp
65 18f89b62 2020-04-14 stsp lockfile -r 3 "$lockfile" || exit 1
66 a2f760e6 2023-01-08 thomas trap "rm -f '$lockfile'" HUP INT QUIT KILL TERM EXIT
67 18f89b62 2020-04-14 stsp
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
71 18f89b62 2020-04-14 stsp
72 18f89b62 2020-04-14 stsp printf "\nRunning on " >> build.log
73 18f89b62 2020-04-14 stsp sysctl -n kern.version >> build.log
74 18f89b62 2020-04-14 stsp
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
78 18f89b62 2020-04-14 stsp
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 be1adb68 2023-02-17 thomas if [ "$update_status" -ne 0 ]; then
85 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog update failure" $recipients < build.log
86 18f89b62 2020-04-14 stsp exit 0
87 18f89b62 2020-04-14 stsp fi
88 18f89b62 2020-04-14 stsp new_basecommit=`cat .got/base-commit`
89 18f89b62 2020-04-14 stsp
90 be1adb68 2023-02-17 thomas if [ "$force" -ne 1 -a "$old_basecommit" == "$new_basecommit" ]; then
91 18f89b62 2020-04-14 stsp exit 0
92 18f89b62 2020-04-14 stsp fi
93 18f89b62 2020-04-14 stsp
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 be1adb68 2023-02-17 thomas if [ "$build_status" -ne 0 ]; then
99 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
100 18f89b62 2020-04-14 stsp exit 0
101 18f89b62 2020-04-14 stsp fi
102 18f89b62 2020-04-14 stsp log_cmd build.log make install
103 85c360aa 2023-01-02 thomas log_cmd build.log make -j $ncpu webd
104 18f89b62 2020-04-14 stsp build_status="$?"
105 be1adb68 2023-02-17 thomas if [ "$build_status" -ne 0 ]; then
106 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
107 18f89b62 2020-04-14 stsp exit 0
108 18f89b62 2020-04-14 stsp fi
109 36967ea8 2023-02-17 thomas log_cmd build.log make -j $ncpu server
110 36967ea8 2023-02-17 thomas build_status="$?"
111 36967ea8 2023-02-17 thomas if [ "$build_status" -ne 0 ]; then
112 36967ea8 2023-02-17 thomas mail $fromaddr_arg -s "$prog build failure" $recipients < build.log
113 36967ea8 2023-02-17 thomas exit 0
114 36967ea8 2023-02-17 thomas fi
115 8a1f3627 2023-12-26 thomas log_cmd build.log make server-install
116 18f89b62 2020-04-14 stsp
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 be1adb68 2023-02-17 thomas 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
127 18f89b62 2020-04-14 stsp exit 0
128 18f89b62 2020-04-14 stsp fi
129 18f89b62 2020-04-14 stsp
130 abf56c36 2021-10-15 thomas printf "\n\n\tRunning tests with pack files\n\n" >> build.log
131 abf56c36 2021-10-15 thomas log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=1
132 abf56c36 2021-10-15 thomas regress_status="$?"
133 abf56c36 2021-10-15 thomas cat regress.log >> build.log
134 abf56c36 2021-10-15 thomas egrep "test.*failed" regress.log > failures.log
135 abf56c36 2021-10-15 thomas regress_failure_grep="$?"
136 be1adb68 2023-02-17 thomas if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
137 abf56c36 2021-10-15 thomas printf "\n\n\t Test failures:\n\n" >> build.log
138 abf56c36 2021-10-15 thomas cat failures.log >> build.log
139 abf56c36 2021-10-15 thomas mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
140 abf56c36 2021-10-15 thomas exit 0
141 abf56c36 2021-10-15 thomas fi
142 abf56c36 2021-10-15 thomas
143 9020067b 2023-02-17 thomas printf "\n\n\tRunning tests with pack files using ref-delta\n\n" >> build.log
144 9020067b 2023-02-17 thomas log_cmd regress.log env PATH=$HOME/bin:$PATH make regress GOT_TEST_ROOT="$testroot" GOT_TEST_PACK=ref-delta
145 9020067b 2023-02-17 thomas regress_status="$?"
146 9020067b 2023-02-17 thomas cat regress.log >> build.log
147 9020067b 2023-02-17 thomas egrep "test.*failed" regress.log > failures.log
148 9020067b 2023-02-17 thomas regress_failure_grep="$?"
149 9020067b 2023-02-17 thomas if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
150 9020067b 2023-02-17 thomas printf "\n\n\t Test failures:\n\n" >> build.log
151 9020067b 2023-02-17 thomas cat failures.log >> build.log
152 9020067b 2023-02-17 thomas mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
153 9020067b 2023-02-17 thomas exit 0
154 9020067b 2023-02-17 thomas fi
155 9020067b 2023-02-17 thomas
156 370dd2e6 2023-12-18 thomas if [ $gotd -ne 0 ]; then
157 370dd2e6 2023-12-18 thomas printf "\n\n\tRunning gotd tests\n\n" >> build.log
158 370dd2e6 2023-12-18 thomas log_cmd regress.log doas env PATH=$HOME/bin:$PATH make server-regress
159 370dd2e6 2023-12-18 thomas regress_status=$?
160 370dd2e6 2023-12-18 thomas cat regress.log >> build.log
161 370dd2e6 2023-12-18 thomas egrep "test.*failed" regress.log > failures.log
162 370dd2e6 2023-12-18 thomas regress_failure_grep="$?"
163 370dd2e6 2023-12-18 thomas if [ "$regress_status" -ne 0 -o "$regress_failure_grep" -eq 0 ]; then
164 370dd2e6 2023-12-18 thomas printf "\n\n\t Test failures:\n\n" >> build.log
165 370dd2e6 2023-12-18 thomas cat failures.log >> build.log
166 370dd2e6 2023-12-18 thomas mail $fromaddr_arg -s "$prog regress failure" $recipients < build.log
167 370dd2e6 2023-12-18 thomas exit 0
168 370dd2e6 2023-12-18 thomas fi
169 370dd2e6 2023-12-18 thomas fi
170 370dd2e6 2023-12-18 thomas
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 85c360aa 2023-01-02 thomas log_cmd build.log make -j $ncpu GOT_RELEASE=Yes webd
176 36967ea8 2023-02-17 thomas log_cmd build.log make -j $ncpu GOT_RELEASE=Yes server
177 18f89b62 2020-04-14 stsp build_status="$?"
178 be1adb68 2023-02-17 thomas if [ "$build_status" -ne 0 ]; then
179 e6db6399 2020-09-20 stsp mail $fromaddr_arg -s "$prog release mode build failure" $recipients < build.log
180 18f89b62 2020-04-14 stsp exit 0
181 18f89b62 2020-04-14 stsp fi
182 18f89b62 2020-04-14 stsp
183 18f89b62 2020-04-14 stsp exit 0