Skip to content

Commit

Permalink
Try to use another version of kcov
Browse files Browse the repository at this point in the history
  • Loading branch information
adinapoli-mndc committed Aug 30, 2019
1 parent bff8e8f commit 6e66175
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .buildkite/coverage.yaml
@@ -1,10 +1,10 @@
steps:
- label: 'Code Coverage (experimental)'
command: |
cargo kcov --print-install-kcov-sh | sh;
PATH=$HOME/.cargo/bin:$PATH cargo kcov -j2 -v --all -o kcov_coverage_report;
cargo kcov -j2 -v --all -o kcov_coverage_report;
kcov --merge --exclude-pattern=/cache/cargo --verify kcov_coverage_report;
bash <(curl -s https://codecov.io/bash) -s kcov_coverage_report
env:
DOCKER_IMAGE: "gcr.io/opensourcecoin/osrank-build@sha256:c36b5d85c221f8d524071ce0586fca31608ab3e01eef2157c37422df8572e80b"
DOCKER_IMAGE: "gcr.io/opensourcecoin/osrank-build@sha256:55ee1268f2ccddbcd708842476fcaa60abb18d9abf966bdfae641669649e7fea"
agents:
docker: "true"
16 changes: 5 additions & 11 deletions docker/build/Dockerfile
@@ -1,5 +1,7 @@
FROM rust:1.37.0-slim-buster

ADD install_kcov.sh /home/install_kcov.sh

# Install additional packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand All @@ -19,21 +21,13 @@ RUN apt-get update \
make \
g++ \
cmake \
git \
python3 \
python-minimal \
jq \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

# Install kcov like it is the 1987
RUN git clone https://github.com/SimonKagstrom/kcov.git \
&& cd kcov \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& make -j2 || exit 1 \
&& make install || exit 1 \
&& cd ../../ \
&& rm -rf kcov
RUN chmod +x /home/install_kcov.sh && ./home/install_kcov.sh

# Install sccache and the rest of the code coverage tools.
RUN cargo install sccache \
Expand Down
50 changes: 50 additions & 0 deletions docker/build/install_kcov.sh
@@ -0,0 +1,50 @@
#!/bin/sh
set -eu

command_exists() {
command -v $1 &> /dev/null
}

CARGO_HOME=${CARGO_HOME:-${HOME}/.cargo}
KCOV_DEFAULT_VERSION="v36"
GITHUB_KCOV="https://api.github.com/repos/SimonKagstrom/kcov/releases/latest"

# Usage: download and install the latest kcov version by default.
# Fall back to ${KCOV_DEFAULT_VERSION} from the kcov archive if the latest is unavailable.
KCOV_VERSION=$(curl --silent --show-error --fail ${GITHUB_KCOV} | jq -Mr .tag_name || echo)
KCOV_VERSION=${KCOV_VERSION:-$KCOV_DEFAULT_VERSION}

KCOV_TGZ="https://github.com/SimonKagstrom/kcov/archive/${KCOV_VERSION}.tar.gz"

rm -rf kcov-${KCOV_VERSION}/
mkdir kcov-${KCOV_VERSION}
curl -L --retry 3 "${KCOV_TGZ}" | tar xzvf - -C kcov-${KCOV_VERSION} --strip-components 1

num_proc=1
# If PARALLEL_BUILD environment variable is set then parallel build is enabled
if [ "${PARALLEL_BUILD:-}" != "" ]; then
# If PARALLEL_BUILD content is a number then use it as number of parallel jobs
if [ ! -z "${PARALLEL_BUILD##*[!0-9]*}" ]; then
num_proc=${PARALLEL_BUILD}
else
# Try to determine the number of available CPUs
if command_exists nproc; then
num_proc=$(nproc)
elif command_exists sysctl; then
num_proc=$(sysctl -n hw.ncpu)
fi
fi
fi

cd kcov-${KCOV_VERSION}
mkdir build
cd build
if [ "$(uname)" = Darwin ]; then
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -GXcode ..
xcodebuild -configuration Release
cp src/Release/kcov src/Release/libkcov_system_lib.so "${CARGO_HOME}/bin"
else
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make -j ${num_proc}
cp src/kcov src/libkcov_sowrapper.so "${CARGO_HOME}/bin"
fi

0 comments on commit 6e66175

Please sign in to comment.