xref: /5.5.2/couchdb/test/ci/dobuild (revision 3bb9ea77)
1#!/bin/bash
2
3source ~/.cienv
4
5if [ "$WORKSPACE" = "" ]; then
6  echo 'WORKSPACE not set'
7  exit 2
8fi
9
10if [ "$RELEASE" = "" ]; then
11  echo 'RELEASE not set'
12  exit 2
13fi
14
15if [ "$MANIFEST" = "" ]; then
16  echo 'MANIFEST not set'
17  exit 2
18fi
19
20if [ "$PEGGED" = "" ]; then
21  export BLD_NUM=0
22else
23  export BLD_NUM=$PEGGED
24fi
25
26error_exit() {
27  echo "</pre><h3>Server build failed: $1</h3><pre>"
28  exit 2
29}
30
31echo '</pre><h3>Building</h3><pre>'
32> $WORKSPACE/versions.cfg
33> $WORKSPACE/make.log
34
35if [ ! -d ~/.reference ]; then
36  mkdir ~/.reference
37  cd ~/.reference
38  repo init -u https://github.com/couchbase/manifest -b master -m $MANIFEST -g all --mirror 1>>$WORKSPACE/make.log 2>&1
39  test $? -eq 0 || error_exit "Repo Init"
40fi
41
42test "$BLD_NUM" = "0" || echo "Using pegged server, $BLD_NUM build"
43echo "Calculating base"
44rm -rf ~/.manifests
45git clone https://github.com/couchbase/build-team-manifests ~/.manifests 1>>$WORKSPACE/make.log 2>&1
46cd ~/.manifests
47
48test "$BLD_NUM" = "0" && BLD_NUM="`git log --oneline | grep "couchbase-server" | grep "$RELEASE-[0-9]" | head -1 | awk -F- '{print $3}'`"
49SHA=`git log --oneline | grep "couchbase-server" | grep "$RELEASE-$BLD_NUM" | head -1 | awk '{print $1}'`
50git branch thisrun $SHA 1>>$WORKSPACE/make.log 2>&1
51
52echo "Updating mirror"
53cd ~/.reference
54repo sync --jobs=32 1>>$WORKSPACE/make.log 2>&1
55
56echo "Basing run on $RELEASE-$BLD_NUM <a href=https://github.com/couchbase/build-team-manifests/blob/$SHA/$MANIFEST>$SHA</a>"
57find $WORKSPACE -mindepth 1 -not -name '*.log' -exec rm -rf {} + 1>>$WORKSPACE/make.log 2>&1
58mkdir -p $WORKSPACE 1>>$WORKSPACE/make.log 2>&1
59cd $WORKSPACE
60repo init -u ~/.manifests -b thisrun -m $MANIFEST -g all --reference=~/.reference 1>>$WORKSPACE/make.log 2>&1
61test $? -eq 0 || error_exit "Repo Init at $SHA"
62
63echo "Updating tree for run $TS"
64cd $WORKSPACE
65repo sync --jobs=32 1>>$WORKSPACE/make.log 2>&1
66test $? -eq 0 || error_exit "Updating tree"
67test $WORKSPACE/cbbuild && test $WORKSPACE/voltron || error_exit "Unable to find voltron"
68
69cd $WORKSPACE
70chmod a+w CMakeLists.txt
71
72cd $WORKSPACE/goproj/src/github.com/couchbase/plasma
73current="`git rev-parse HEAD`"
74test -f ~/plasma.good || (echo $current > ~/plasma.good)
75good="`cat ~/plasma.good`"
76echo -n "plasma is at <a href='https://github.com/couchbase/plasma/commit/$current'>${current:0:7}</a>, changes since last good build: "
77if [ "$current" != "$good" ]; then
78  echo
79  git log --pretty='format: <a href="https://github.com/couchbase/plasma/commit/%H">%h</a> %s' $good..HEAD
80  echo
81else
82  echo "none"
83fi
84
85cd $WORKSPACE/goproj/src/github.com/couchbase/nitro
86current="`git rev-parse HEAD`"
87test -f ~/nitro.good || (echo $current > ~/nitro.good)
88good="`cat ~/nitro.good`"
89echo -n "nitro is at <a href='https://github.com/couchbase/nitro/commit/$current'>${current:0:7}</a>, changes since last good build: "
90if [ "$current" != "$good" ]; then
91  echo
92  git log --pretty='format: <a href="https://github.com/couchbase/nitro/commit/%H">%h</a> %s' $good..HEAD
93  echo
94else
95  echo "none"
96fi
97
98cd $WORKSPACE/goproj/src/github.com/couchbase/indexing
99current="`git rev-parse HEAD`"
100test -f ~/indexing.good || (echo $current > ~/indexing.good)
101good="`cat ~/indexing.good`"
102echo -n "indexing is at <a href='https://github.com/couchbase/indexing/commit/$current'>${current:0:7}</a>, changes since last good build: "
103if [ "$current" != "$good" ]; then
104  echo
105  git log --pretty='format: <a href="https://github.com/couchbase/indexing/commit/%H">%h</a> %s' $good..HEAD
106  echo
107else
108  echo "none"
109fi
110
111cd $WORKSPACE/goproj/src/github.com/couchbase/eventing
112current="`git rev-parse HEAD`"
113test -f ~/eventing.good || (echo $current > ~/eventing.good)
114good="`cat ~/eventing.good`"
115echo -n "eventing is at <a href='https://github.com/couchbase/eventing/commit/$current'>${current:0:7}</a>, changes since last good build: "
116if [ "$current" != "$good" ]; then
117  echo
118  git log --pretty='format: <a href="https://github.com/couchbase/eventing/commit/%H">%h</a> %s' $good..HEAD
119  echo
120else
121  echo "none"
122fi
123
124cd $WORKSPACE/goproj/src/github.com/couchbase/query
125current="`git rev-parse HEAD`"
126test -f ~/query.good || (echo $current > ~/query.good)
127good="`cat ~/query.good`"
128echo -n "query is at <a href='https://github.com/couchbase/query/commit/$current'>${current:0:7}</a>, changes since last good build: "
129if [ "$current" != "$good" ]; then
130  echo
131  git log --pretty='format: <a href="https://github.com/couchbase/query/commit/%H">%h</a> %s' $good..HEAD
132  echo
133else
134  echo "none"
135fi
136
137cd $WORKSPACE/goproj/src/github.com/couchbase/gometa
138current="`git rev-parse HEAD`"
139test -f ~/gometa.good || (echo $current > ~/gometa.good)
140good="`cat ~/gometa.good`"
141echo -n "gometa is at <a href='https://github.com/couchbase/gometa/commit/$current'>${current:0:7}</a>, changes since last good build: "
142if [ "$current" != "$good" ]; then
143  echo
144  git log --pretty='format: <a href="https://github.com/couchbase/gometa/commit/%H">%h</a> %s' $good..HEAD
145  echo
146else
147  echo "none"
148fi
149
150cd $WORKSPACE/ns_server
151current="`git rev-parse HEAD`"
152test -f ~/ns_server.good || (echo $current > ~/ns_server.good)
153good="`cat ~/ns_server.good`"
154echo -n "ns_server is at <a href='https://github.com/couchbase/ns_server/commit/$current'>${current:0:7}</a>, changes since last good build: "
155if [ "$current" != "$good" ]; then
156  echo
157  git log --pretty='format: <a href="https://github.com/couchbase/ns_server/commit/%H">%h</a> %s' $good..HEAD
158  echo
159else
160  echo "none"
161fi
162
163cd $WORKSPACE/couchdb
164echo "Switching couchdb to unstable"
165git checkout unstable 1>>$WORKSPACE/make.log 2>&1 || error_exit "git checkout unstable"
166git pull 1>>$WORKSPACE/make.log 2>&1 || error_exit "git pull"
167current="`git rev-parse HEAD`"
168test -f ~/couchdb.good || (echo $current > ~/couchdb.good)
169good="`cat ~/couchdb.good`"
170echo -n "couchdb is at <a href='https://github.com/couchbase/couchdb/commit/$current'>${current:0:7}</a>, changes since last good build: "
171if [ "$current" != "$good" ]; then
172  echo
173  git log --pretty='format: <a href="https://github.com/couchbase/couchdb/commit/%H">%h</a> %s' $good..HEAD
174  echo
175else
176  echo "none"
177fi
178
179cd $WORKSPACE/couchstore
180current="`git rev-parse HEAD`"
181test -f ~/couchstore.good || (echo $current > ~/couchstore.good)
182good="`cat ~/couchstore.good`"
183echo -n "couchstore is at <a href='https://github.com/couchbase/couchstore/commit/$current'>${current:0:7}</a>, changes since last good build: "
184if [ "$current" != "$good" ]; then
185  echo
186  git log --pretty='format: <a href="https://github.com/couchbase/couchstore/commit/%H">%h</a> %s' $good..HEAD
187  echo
188else
189  echo "none"
190fi
191
192cd $WORKSPACE/forestdb
193current="`git rev-parse HEAD`"
194test -f ~/forestdb.good || (echo $current > ~/forestdb.good)
195good="`cat ~/forestdb.good`"
196echo -n "forestdb is at <a href='https://github.com/couchbase/forestdb/commit/$current'>${current:0:7}</a>, changes since last good build: "
197if [ "$current" != "$good" ]; then
198  echo
199  git log --pretty='format: <a href="https://github.com/couchbase/forestdb/commit/%H">%h</a> %s' $good..HEAD
200  echo
201else
202  echo "none"
203fi
204
205cd $WORKSPACE/kv_engine
206current="`git rev-parse HEAD`"
207test -f ~/kv_engine.good || (echo $current > ~/kv_engine.good)
208good="`cat ~/kv_engine.good`"
209echo -n "kv_engine is at <a href='https://github.com/couchbase/kv_engine/commit/$current'>${current:0:7}</a>, changes since last good build: "
210if [ "$current" != "$good" ]; then
211  echo
212  git log --pretty='format: <a href="https://github.com/couchbase/kv_engine/commit/%H">%h</a> %s' $good..HEAD
213  echo
214else
215  echo "none"
216fi
217
218cd $WORKSPACE/testrunner
219current="`git rev-parse HEAD`"
220test -f ~/testrunner.good || (echo $current > ~/testrunner.good)
221good="`cat ~/testrunner.good`"
222echo -n "testrunner is at <a href='https://github.com/couchbase/testrunner/commit/$current'>${current:0:7}</a>, changes since last good build: "
223if [ "$current" != "$good" ]; then
224  echo
225  git log --pretty='format: <a href="https://github.com/couchbase/testrunner/commit/%H">%h</a> %s' $good..HEAD
226  echo
227else
228  echo "none"
229fi
230
231cd $WORKSPACE
232PRODUCT_VERSION=${RELEASE}-${BLD_NUM}-rel
233rm -f *.rpm *.deb
234rm -rf ~/rpmbuild
235rm -rf $WORKSPACE/voltron/build/deb
236rm -rf $WORKSPACE/install/*
237find goproj godeps -name \*.a -print0 | xargs -0 rm -f
238
239cd $WORKSPACE
240mkdir -p build
241cd build
242
243echo "Building main product"
244cmake -D CMAKE_INSTALL_PREFIX=$WORKSPACE/install \
245      -D CMAKE_PREFIX_PATH=$WORKSPACE/install \
246      -D CMAKE_BUILD_TYPE=RelWithDebInfo \
247      -D PRODUCT_VERSION=${PRODUCT_VERSION} \
248      -D BUILD_ENTERPRISE=TRUE \
249      -D CB_DOWNLOAD_DEPS=1 \
250      -D SNAPPY_OPTION=Disable \
251      .. 1>>$WORKSPACE/make.log 2>&1
252test $? -eq 0 || error_exit "Main build"
253
254make -j8 install 1>>$WORKSPACE/make.log 2>&1
255test $? -eq 0 || error_exit "Making Install"
256
257cd $WORKSPACE
258repo manifest -r > current.xml
259repo manifest -r > manifest.xml
260
261echo "Actual Versions:" >> $WORKSPACE/versions.cfg
262cd $WORKSPACE
263repo forall -c 'echo "$REPO_PROJECT `git log --oneline HEAD...HEAD^`"' 2>/dev/null 1>>$WORKSPACE/versions.cfg
264
265chmod a+r /var/www/*
266
267