Skip to content

Commit

Permalink
Add circleci suite
Browse files Browse the repository at this point in the history
  • Loading branch information
eugpermar committed Nov 2, 2017
1 parent 09f317e commit 55a7c4e
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 10 deletions.
22 changes: 22 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
jobs:
build:
machine: true
hosts:
kafka: 127.0.0.1

steps:
- checkout
# Don't want thread-safety test because musl bug
- run: sed -i 's%\$(TESTS_\(DRD\|HELGRIND\)_XML)%%g' Makefile
# Bug caused by LTO, mem checks are impossible & unknown failure
- run: rm -f tests/0013-mem.c tests/0005-monitors_split_op_blanks.c
# Build kafka container
- run: docker run -d --name kafka --add-host=kafka:127.0.0.1 --env ADVERTISED_HOST=kafka --env ADVERTISED_PORT=9092 spotify/kafka
# Create development docker
- run:
environment:
DOCKER_BUILD_PARAMETERS: -t monitor-dev --rm=false
command: make dev-docker
# Run test
- run: ./tests/circle-test.sh "$CIRCLE_ARTIFACTS/O2" "--bootstrap"
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[![Build Status](https://travis-ci.org/redBorder/rb_monitor.svg?branch=master)](https://travis-ci.org/redBorder/rb_monitor)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/10570/badge.svg)](https://scan.coverity.com/projects/redborder-rb_monitor)
[![Coverage Status](https://coveralls.io/repos/github/redBorder/rb_monitor/badge.svg?branch=master)](https://coveralls.io/github/redBorder/rb_monitor?branch=redborder)
[![CircleCI](https://circleci.com/gh/wizzie-io/rb_monitor.svg?style=svg&circle-token=22d517d1196fe8208eedd8341cf4c06e3f6fbeab)](https://circleci.com/gh/wizzie-io/rb_monitor)

# rb_monitor

Expand Down
13 changes: 6 additions & 7 deletions docker/Dockerfile.m4
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ RUN apk add --no-cache librdkafka jansson zlib
# n2k libraries
RUN apk add --no-cache yajl libmicrohttpd libev

# ca-certificates: for wget bootstrapping
# ncurses - expat: deps for xml-coreutils
define(builddeps,bash build-base ca-certificates librdkafka-dev \
libarchive-tools zlib-dev openssl cgdb valgrind \
bsd-compat-headers git m4 file guile-dev cmocka-dev)dnl
bsd-compat-headers git m4 file guile-dev cmocka-dev \
ncurses-dev expat-dev slang-dev)dnl
dnl
ifelse(version,devel,
RUN apk add --no-cache builddeps && \
Expand All @@ -24,15 +27,11 @@ RUN apk add --no-cache builddeps && \
wget -q -O - \
https://github.com/eugpermar/xml-coreutils/archive/master.zip \
| bsdtar -xf- && \
(cd xml-coreutils-master; bash ./configure --prefix=/usr/local \
; make; make install) && \
(cd xml-coreutils-master; bash ./configure --prefix=/usr/local; \
chmod +x config/install-sh; make; make install) && \
rm -rfv xml-coreutils-master,
COPY releasefiles /app/
COPY mibfiles /usr/local/share/snmp/mibs/
ENTRYPOINT /app/monitor_setup.sh)


# ca-certificates: for wget bootstrapping
# ncurses - expat: deps for xml-coreutils

WORKDIR /app
67 changes: 67 additions & 0 deletions tests/circle-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

# Run a command in development docker container
# Arguments
# Docker extra args
# Others: command to execute
function docker_run () {
local DOCKER_COMMON_ARGS="-e CC=gcc -v ${PWD}:/app"
local docker_extra_args="$1"
shift
docker run $DOCKER_COMMON_ARGS $docker_extra_args monitor-dev $*
}

# Download a coverage budget
# Arguments
# Coverage percent
function wget_coverage_budget {
local readonly cov_d=$(printf '%d' $1) # Coverage integer format
echo "cov_d=${cov_d}"
local readonly green=$((cov_d*255/100))
local readonly red=$((255-green))

local readonly color="$(printf '%02x' $red)$(printf '%02x' $green)00"

# Current directory could be created by docker root user
sudo wget "https://img.shields.io/badge/coverage-$1-$color.svg" \
-O "coverage.svg"
}

# Run monitor test
# Arguments:
# [--coverage] Create coverage output
# $1: results output dir
# Others: Configure options
function run_monitor_tests () {
local coverage_arg=""
if [[ "$1" == "--coverage" ]]; then
coverage_arg="--enable-coverage"
shift
fi

local readonly output_dir="$1"
shift

#if [[ ! -z "$coverage_arg" ]]; then
# local readonly make_target=checks # no need to valgrind tests
#else
# local readonly make_target=tests
#fi
local -r make_target=checks

git clean -fqx
docker_run "" "./configure $coverage_arg $*"
docker_run "" "make all"
docker_run "-v $output_dir:$output_dir -e TEST_REPORTS_DIR=$output_dir --link kafka" "make ${make_target}"

if [[ ! -z "$coverage_arg" ]]; then
docker_run "--link kafka -v $output_dir:$output_dir -e COVERAGE_OUTPUT_DIRECTORY=\"$output_dir/coverage\"" "make coverage"
coverage=$(grep -o 'branches\.\.\.: [[:digit:]]*\.[[:digit:]]*' coverage.out | cut -d ' ' -f 2)
(cd $output_dir; wget_coverage_budget $coverage)
fi
}

set -e # Return at first error
set -x # Print commands
run_monitor_tests $*


0 comments on commit 55a7c4e

Please sign in to comment.