ci: Embedding CI build and test running script
This commit also unifies build and test scripts for Jenkins and Travis CI
Change-Id: Ieaf2d8793c2320a23ce9958c9cf06b3abd4d500f
diff --git a/.jenkins.d/00-deps-ndn-cxx.sh b/.jenkins.d/00-deps-ndn-cxx.sh
new file mode 100755
index 0000000..951e3f9
--- /dev/null
+++ b/.jenkins.d/00-deps-ndn-cxx.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+cd /tmp
+BUILD="no"
+if [ ! -d ndn-cxx ]; then
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+else
+ cd ndn-cxx
+ INSTALLED_VERSION=`git rev-parse HEAD || echo NONE`
+ sudo rm -Rf latest-version
+ git clone --depth 1 git://github.com/named-data/ndn-cxx latest-version
+ cd latest-version
+ LATEST_VERSION=`git rev-parse HEAD || echo UNKNOWN`
+ cd ..
+ rm -Rf latest-version
+ if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
+ cd ..
+ sudo rm -Rf ndn-cxx
+ git clone --depth 1 git://github.com/named-data/ndn-cxx
+ cd ndn-cxx
+ BUILD="yes"
+ fi
+fi
+
+sudo rm -Rf /usr/local/include/ndn-cxx
+sudo rm -f /usr/local/lib/libndn-cxx*
+sudo rm -f /usr/local/lib/pkgconfig/libndn-cxx*
+
+if [ "$BUILD" = "yes" ]; then
+ sudo ./waf distclean -j1 --color=yes
+fi
+
+./waf configure -j1 --color=yes --without-osx-keychain
+./waf -j1 --color=yes
+sudo ./waf install -j1 --color=yes
diff --git a/.jenkins.d/10-build.sh b/.jenkins.d/10-build.sh
new file mode 100755
index 0000000..b288135
--- /dev/null
+++ b/.jenkins.d/10-build.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+git submodule init
+git submodule sync
+git submodule update
+
+# Cleanup
+sudo ./waf distclean -j1 --color=yes
+
+# Configure
+COVERAGE=$( python -c "print '--with-coverage' if 'code-coverage' in '$JOB_NAME' else ''" )
+
+CXXFLAGS="-std=c++03 -pedantic -Wall -Wno-long-long -O2 -g -Werror" \
+ ./waf configure -j1 --color=yes --with-tests --without-pch $COVERAGE
+
+# Build
+./waf --color=yes -j1
+
+# Install
+sudo ./waf -j1 --color=yes install
diff --git a/.jenkins.d/20-tests.sh b/.jenkins.d/20-tests.sh
new file mode 100755
index 0000000..6385fc9
--- /dev/null
+++ b/.jenkins.d/20-tests.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+# Prepare environment
+rm -Rf ~/.ndnx ~/.ndn
+
+echo $NODE_LABELS
+IS_OSX=$( python -c "print 'yes' if 'OSX' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
+IS_LINUX=$( python -c "print 'yes' if 'Linux' in '$NODE_LABELS'.strip().split(' ') else 'no'" )
+
+if [[ $IS_OSX == "yes" ]]; then
+ security unlock-keychain -p "named-data"
+ sudo chgrp admin /dev/bpf*
+ sudo chmod g+rw /dev/bpf*
+fi
+if [[ $IS_LINUX = "yes" ]]; then
+ sudo setcap cap_net_raw,cap_net_admin=eip `pwd`/build/unit-tests-core || true
+ sudo setcap cap_net_raw,cap_net_admin=eip `pwd`/build/unit-tests-daemon || true
+ sudo setcap cap_net_raw,cap_net_admin=eip `pwd`/build/unit-tests-rib || true
+fi
+
+ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
+
+# Run unit tests
+# Core
+./build/unit-tests-core -l test_suite
+
+# Daemon
+./build/unit-tests-daemon -l test_suite
+
+# RIB
+./build/unit-tests-rib -l test_suite
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
new file mode 100755
index 0000000..e462884
--- /dev/null
+++ b/.jenkins.d/30-coverage.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+set -x
+set -e
+
+IS_COVR=$( python -c "print 'yes' if 'code-coverage' in '$JOB_NAME' else 'no'" )
+
+if [[ $IS_COVR == "yes" ]]; then
+ BASE="`pwd | sed -e 's|/|\\\/|g'`\\"
+ (cd build && gcovr -x -f $BASE/core -f $BASE/daemon -f $BASE/rib -r ../ -o coverage.xml ./)
+fi