Skip to content

Commit

Permalink
[PoC] Run CodeCov on Buildkite
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Jul 31, 2018
1 parent 0bb9743 commit 8bb3329
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 29 deletions.
49 changes: 38 additions & 11 deletions buildkite.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
#!/bin/bash

cat << 'EOF'
steps:
- command: |
echo "--- Print environment"
uname -a
make --version
\${SHELL} --version || true
c++ --version
ld -v
! command -v gdb &>/dev/null || gdb --version
! dmd --version # ensure that no dmd is the current environment
read -r -d '' LOAD_CI_FOLDER <<- EOM
echo "--- Load CI folder"
# just to be sure there isn't anything old left
git clean -ffdxq .
Expand All @@ -21,13 +11,50 @@ steps:
tar xvfz master.tar.gz --strip-components=2 ci-master/buildkite
rm -rf master.tar.gz && popd
fi
EOM

cat << EOF
steps:
- command: |
echo "--- Print environment"
uname -a
make --version
\\\${SHELL} --version || true
c++ --version
ld -v
! command -v gdb &>/dev/null || gdb --version
! dmd --version # ensure that no dmd is the current environment
${LOAD_CI_FOLDER}
./buildkite/build_distribution.sh
label: "Build"
artifact_paths: "distribution.tar.xz"
retry:
automatic:
limit: 2
EOF

case "${BUILDKITE_REPO:-x}" in
"https://github.com/dlang/dmd.git" | \
"https://github.com/dlang/druntime.git" | \
"https://github.com/dlang/phobos.git")

cat << 'EOF'
- command: |
${LOAD_CI_FOLDER}
./buildkite/test_coverage.sh
label: "Coverage"
retry:
automatic:
limit: 2
EOF
;;
*)
;;
esac

################################################################################

cat << 'EOF'
- wait
EOF

Expand Down
19 changes: 1 addition & 18 deletions buildkite/build_distribution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,7 @@ echo "--- Setting build variables"

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

origin_repo="$(echo "$BUILDKITE_REPO" | sed "s/.*\/\([^\]*\)[.]git/\1/")"
origin_target_branch="$BUILDKITE_PULL_REQUEST_BASE_BRANCH"
if [ -z "$origin_target_branch" ] ; then
origin_target_branch="$BUILDKITE_BRANCH"
fi
echo "origin_target_branch: $origin_target_branch"

echo "--- Cloning all core repositories"
for dir in dmd druntime phobos tools dub ; do
if [ "$origin_repo" == "$dir" ] ; then
# we have already cloned this repo, so let's use this data
mkdir -p $dir
cp -r $(ls -A | grep -v $dir) $dir
else
branch=$(git ls-remote --exit-code --heads https://github.com/dlang/$dir "${origin_target_branch}" > /dev/null || echo "master")
git clone -b "${branch:-master}" --depth 1 https://github.com/dlang/$dir
fi
done
"$DIR/clone_repositories.sh"

for dir in dmd druntime phobos ; do
echo "--- Building $dir"
Expand Down
34 changes: 34 additions & 0 deletions buildkite/clone_repositories.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

PS4="~> " # needed to avoid accidentally generating collapsed output
set -uexo pipefail

# Builds DMD, DRuntime, Phobos, tools and DUB + creates a "distribution" archive for latter usage.
echo "--- Setting build variables"

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

origin_repo="$(echo "$BUILDKITE_REPO" | sed "s/.*\/\([^\]*\)[.]git/\1/")"
origin_target_branch="$BUILDKITE_PULL_REQUEST_BASE_BRANCH"
if [ -z "$origin_target_branch" ] ; then
origin_target_branch="$BUILDKITE_BRANCH"
fi
echo "origin_target_branch: $origin_target_branch"

echo "--- Cloning all core repositories"
for dir in dmd druntime phobos tools dub ; do
if [ "$origin_repo" == "$dir" ] ; then
# we have already cloned this repo, so let's use this data
mkdir -p $dir
cp -r $(ls -A | grep -v $dir) $dir
else
branch=$(git ls-remote --exit-code --heads https://github.com/dlang/$dir "${origin_target_branch}" > /dev/null || echo "master")
git clone -b "${branch:-master}" --depth 1 https://github.com/dlang/$dir
fi
done

for dir in dmd druntime phobos ; do
echo "--- Building $dir"
make -C $dir -f posix.mak AUTO_BOOTSTRAP=1 --jobs=4
done

61 changes: 61 additions & 0 deletions buildkite/test_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

PS4="~> " # needed to avoid accidentally generating collapsed output
set -uexo pipefail

echo "--- Setting build variables"

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
N=2
MODEL=64
PIC=1

"$DIR/clone_repositories.sh"

echo "--- Running the testsuite with COVERAGE=1"
case "$REPO_FULL_NAME" in
"https://github.com/dlang/dmd.git")
make -j${N}
# rebuild dmd with coverage enabled
# use the just build dmd as host compiler this time
build_path=generated/linux/release/$MODEL
# `generated` gets cleaned in the next step, so we create another _generated
# The nested folder hierarchy is needed to conform to those specified in
# the generate dmd.conf
mkdir -p _${build_path}
cp $build_path/dmd _${build_path}/host_dmd
cp $build_path/dmd.conf _${build_path}
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=../_${build_path}/host_dmd PIC="$PIC" clean
make -j$N -C src -f posix.mak MODEL=$MODEL HOST_DMD=../_${build_path}/host_dmd ENABLE_COVERAGE=1 ENABLE_WARNINGS=1 PIC="$PIC"

cp $build_path/dmd _${build_path}/host_dmd_cov
make -j1 -C src -f posix.mak MODEL=$MODEL HOST_DMD=../_${build_path}/host_dmd_cov ENABLE_COVERAGE=1 PIC="$PIC" unittest
make -j1 -C test MODEL=$MODEL ARGS="-O -inline -release" DMD_TEST_COVERAGE=1 PIC="$PIC"
;;
"https://github.com/dlang/druntime.git")
# build dmd and druntime (in debug and release)
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD BUILD="debug" all
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD BUILD="release" all
TEST_COVERAGE="1" make -j$N -C . -f posix.mak MODEL=$MODEL unittest-debug
;;
"https://github.com/dlang/phobos.git")
;;
esac

################################################################################
# Send to CodeCov
################################################################################

wget "https://codecov.io/bash" -O codecov.sh
case "$REPO_FULL_NAME" in
"https://github.com/dlang/dmd.git")
# CodeCov gets confused by lst files which it can't match
rm -rf ../test/runnable/extra-files
cd src # need to run from compilation folder for gcov to find sources
# must match g++ version (on CircleCI `g++` is 4.9 and `gcov` 4.6 :/)
bash ../codecov.sh -p .. -x gcov-4.9 -t "${CODECOV_TOKEN}"
;;
*)
bash codecov.sh -t "${CODECOV_TOKEN}"
;;
esac

0 comments on commit 8bb3329

Please sign in to comment.