xref: /5.5.2/couchdb/test/ci/dobuild (revision 80992523)
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 $BRANCH"
165git checkout $BRANCH 1>>$WORKSPACE/make.log 2>&1 || error_exit "git checkout $BRANCH"
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
179if [ "$GERRIT" != "" ]; then
180  for patch_id in $GERRIT;
181  do
182    cd $WORKSPACE/goproj/src/github.com/couchbase/couchdb
183    revspec=`git ls-remote -q http://review.couchbase.org/couchdb refs/changes/*/$patch_id/* | awk '{print $2}' | sort -n -t/ -k5 | tail -1`
184    echo Pulling in uncommitted change "http://review.couchbase.org/couchdb $revspec"
185    git fetch -q http://review.couchbase.org/couchdb $revspec && git cherry-pick FETCH_HEAD
186  done
187fi
188
189cd $WORKSPACE/couchstore
190current="`git rev-parse HEAD`"
191test -f ~/couchstore.good || (echo $current > ~/couchstore.good)
192good="`cat ~/couchstore.good`"
193echo -n "couchstore is at <a href='https://github.com/couchbase/couchstore/commit/$current'>${current:0:7}</a>, changes since last good build: "
194if [ "$current" != "$good" ]; then
195  echo
196  git log --pretty='format: <a href="https://github.com/couchbase/couchstore/commit/%H">%h</a> %s' $good..HEAD
197  echo
198else
199  echo "none"
200fi
201
202cd $WORKSPACE/forestdb
203current="`git rev-parse HEAD`"
204test -f ~/forestdb.good || (echo $current > ~/forestdb.good)
205good="`cat ~/forestdb.good`"
206echo -n "forestdb is at <a href='https://github.com/couchbase/forestdb/commit/$current'>${current:0:7}</a>, changes since last good build: "
207if [ "$current" != "$good" ]; then
208  echo
209  git log --pretty='format: <a href="https://github.com/couchbase/forestdb/commit/%H">%h</a> %s' $good..HEAD
210  echo
211else
212  echo "none"
213fi
214
215cd $WORKSPACE/geocouch
216current="`git rev-parse HEAD`"
217test -f ~/geocouch.good || (echo $current > ~/geocouch.good)
218good="`cat ~/geocouch.good`"
219echo -n "geocouch is at <a href='https://github.com/couchbase/geocouch/commit/$current'>${current:0:7}</a>, changes since last good build: "
220if [ "$current" != "$good" ]; then
221  echo
222  git log --pretty='format: <a href="https://github.com/couchbase/geocouch/commit/%H">%h</a> %s' $good..HEAD
223  echo
224else
225  echo "none"
226fi
227
228cd $WORKSPACE/kv_engine
229current="`git rev-parse HEAD`"
230test -f ~/kv_engine.good || (echo $current > ~/kv_engine.good)
231good="`cat ~/kv_engine.good`"
232echo -n "kv_engine is at <a href='https://github.com/couchbase/kv_engine/commit/$current'>${current:0:7}</a>, changes since last good build: "
233if [ "$current" != "$good" ]; then
234  echo
235  git log --pretty='format: <a href="https://github.com/couchbase/kv_engine/commit/%H">%h</a> %s' $good..HEAD
236  echo
237else
238  echo "none"
239fi
240
241cd $WORKSPACE/testrunner
242current="`git rev-parse HEAD`"
243test -f ~/testrunner.good || (echo $current > ~/testrunner.good)
244good="`cat ~/testrunner.good`"
245echo -n "testrunner is at <a href='https://github.com/couchbase/testrunner/commit/$current'>${current:0:7}</a>, changes since last good build: "
246if [ "$current" != "$good" ]; then
247  echo
248  git log --pretty='format: <a href="https://github.com/couchbase/testrunner/commit/%H">%h</a> %s' $good..HEAD
249  echo
250else
251  echo "none"
252fi
253
254cd $WORKSPACE
255PRODUCT_VERSION=${RELEASE}-${BLD_NUM}-rel
256rm -f *.rpm *.deb
257rm -rf ~/rpmbuild
258rm -rf $WORKSPACE/voltron/build/deb
259rm -rf $WORKSPACE/install/*
260find goproj godeps -name \*.a -print0 | xargs -0 rm -f
261
262cd $WORKSPACE
263mkdir -p build
264cd build
265
266echo "Building main product"
267cmake -D CMAKE_INSTALL_PREFIX=$WORKSPACE/install \
268      -D CMAKE_PREFIX_PATH=$WORKSPACE/install \
269      -D CMAKE_BUILD_TYPE=RelWithDebInfo \
270      -D PRODUCT_VERSION=${PRODUCT_VERSION} \
271      -D BUILD_ENTERPRISE=TRUE \
272      -D CB_DOWNLOAD_DEPS=1 \
273      -D SNAPPY_OPTION=Disable \
274      .. 1>>$WORKSPACE/make.log 2>&1
275test $? -eq 0 || error_exit "Main build"
276
277make -j8 install 1>>$WORKSPACE/make.log 2>&1
278test $? -eq 0 || error_exit "Making Install"
279
280cd $WORKSPACE
281repo manifest -r > current.xml
282repo manifest -r > manifest.xml
283
284echo "Actual Versions:" >> $WORKSPACE/versions.cfg
285cd $WORKSPACE
286repo forall -c 'echo "$REPO_PROJECT `git log --oneline HEAD...HEAD^`"' 2>/dev/null 1>>$WORKSPACE/versions.cfg
287
288chmod a+r /var/www/*
289
290