diff --git a/.gitignore b/.gitignore index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..97a21092b10904c2727302e0103ac6c6520ad2c7 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,3 @@ +/build +/installs +/coverage.out diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..f50abfabb4a7e75902b584af63a38d8d97e4f090 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: go +go: + - 1.6 +# - tip # broken for 1.7 +sudo: false +#notifications: +# slack: +# secure: <INSERT ENCRYPTED SLACK KEY HERE> +addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.8 + packages: + - clang-3.8 + - libbz2-dev + - libsnappy-dev + - zlib1g-dev +env: + - CC=clang-3.8 CXX=clang++-3.8 +cache: + apt: true + directories: + - $HOME/build +install: + - bash contrib/build-rocksdb.sh $HOME/build +before_script: + - go get github.com/mattn/goveralls + - go get github.com/kardianos/govendor +script: + - govendor sync + - bash contrib/cover.sh $HOME/build coverage.out + - goveralls -service=travis-ci -coverprofile=coverage.out diff --git a/contrib/README.md b/contrib/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a75357901ae0607a3b93c1e9f276e695b4c7242d --- /dev/null +++ b/contrib/README.md @@ -0,0 +1,4 @@ +The `contrib` directory contains scripts, images, and other helpful things +which are not part of the core dgraph distribution. Please note that they +could be out of date, since they do not receive the same attention as the +rest of the repository. diff --git a/contrib/build-rocksdb.sh b/contrib/build-rocksdb.sh new file mode 100755 index 0000000000000000000000000000000000000000..f24ba482ed19bf66b0de37e21fbfc2d44e0e6c49 --- /dev/null +++ b/contrib/build-rocksdb.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +ROCKSDBVER="4.2" +ROCKSDBURL="https://github.com/facebook/rocksdb/archive/v${ROCKSDBVER}.tar.gz" +ROCKSDBFILE="rocksdb-${ROCKSDBVER}.tar.gz" +ROCKSDBDIR=rocksdb-${ROCKSDBVER} +ROCKSDBLIB=librocksdb.so.${ROCKSDBVER} + +SRC="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." + +BUILD=$1 +if [ -z "$1" ]; then + BUILD=$SRC/build +fi + +[ -d $BUILD ] || mkdir -p $BUILD + +set -e + +pushd $BUILD &> /dev/null + +# download +if [ ! -f $ROCKSDBFILE ]; then + wget -O $ROCKSDBFILE $ROCKSDBURL +fi + +# extract +if [ ! -d $ROCKSDBDIR ]; then + tar -zxf $ROCKSDBFILE +fi + +# configure, build +if [ ! -e $ROCKSDBDIR/${ROCKSDBLIB} ]; then + cd $ROCKSDBDIR + make shared_lib +fi + +popd &> /dev/null diff --git a/contrib/cover.sh b/contrib/cover.sh new file mode 100755 index 0000000000000000000000000000000000000000..8254b82468efa18e2b7a7f3f72b24e1fa1990603 --- /dev/null +++ b/contrib/cover.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SRC="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.." +TMP=$(mktemp -p /tmp dgraph-coverage-XXXXX.txt) + +BUILD=$1 +if [ -z "$1" ]; then + BUILD=$SRC/build +fi + +OUT=$2 +if [ -z "$OUT" ]; then + OUT=$SRC/coverage.out +fi +rm -f $OUT + +ROCKSDBDIR=$BUILD/rocksdb-4.2 + +set -e + +pushd $SRC &> /dev/null + +# build flags needed for rocksdb +export CGO_CFLAGS="-I${ROCKSDBDIR}/include" +export CGO_LDFLAGS="-L${ROCKSDBDIR}" +export LD_LIBRARY_PATH="${ROCKSDBDIR}:${LD_LIBRARY_PATH}" + +# create coverage output +echo 'mode: atomic' > $OUT +for PKG in $(go list ./...|grep -v '/vendor/'); do + echo "TESTING: $PKG" + go test -v -covermode=atomic -coverprofile=$TMP $PKG + tail -n +2 $TMP >> $OUT +done + +# open in browser if not in a build environment +if [ ! -z "$DISPLAY" ]; then + go tool cover -html=$OUT +fi + +popd &> /dev/null