Skip to content

Commit

Permalink
chore: add codecov.io support
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Dec 22, 2023
1 parent d0198b3 commit 2f0203e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .docker/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ case "-$BUILD_TYPE-" in
*-ubsan-*)
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_UBSAN=1"
;;
*-coverage-*)
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_COVERAGE=1"
;;
*)
echo "missing build type: $BUILD_TYPE"
exit 1
Expand Down Expand Up @@ -91,8 +94,22 @@ cmake ../dwarfs/ $CMAKE_ARGS

$BUILD_TOOL

if [[ "-$BUILD_TYPE-" == *-coverage-* ]]; then
export LLVM_PROFILE_FILE="$PWD/profile/%32m.profraw"
fi

ctest --output-on-failure -j$(nproc)

if [[ "-$BUILD_TYPE-" == *-coverage-* ]]; then
unset LLVM_PROFILE_FILE
rm -rf /tmp-runner/coverage
mkdir -p /tmp-runner/coverage
llvm-profdata-17 merge -sparse profile/* -o dwarfs.profdata
for binary in mkdwarfs dwarfs dwarfsck dwarfsextract; do
llvm-cov-17 show -instr-profile=dwarfs.profdata $binary >/tmp-runner/coverage/$binary.txt
done
fi

if [[ "-$BUILD_TYPE-" == *-static-* ]]; then
$BUILD_TOOL package_source
if [[ "$BUILD_ARCH" == "amd64" ]]; then
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ jobs:
build_type: clang-ubsan-ninja
- arch: amd64
build_type: gcc-debug-noperfmon-ninja
- arch: amd64
build_type: clang-coverage-ninja

runs-on:
- self-hosted
Expand Down Expand Up @@ -118,6 +120,7 @@ jobs:
docker run --rm \
--cap-add SYS_ADMIN --device /dev/fuse --privileged \
--mount type=bind,source=${GITHUB_WORKSPACE},target=/workspace,readonly \
--mount type=bind,source=${{ runner.temp }},target=/tmp-runner \
--mount type=bind,source=/home/mhx/github-ccache,target=/ccache \
--mount type=bind,source=/mnt/opensource/artifacts/dwarfs,target=/artifacts \
--env BUILD_TYPE=${{ matrix.build_type }} \
Expand All @@ -128,3 +131,11 @@ jobs:
--env GITHUB_RUN_NUMBER \
--env GITHUB_RUN_ATTEMPT \
dwarfs-linux-build
- name: Upload Coverage Data
if: matrix.build_type == 'clang-coverage-ninja'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ runner.temp }}/coverage/mkdwarfs.txt,${{ runner.temp }}/coverage/dwarfs.txt,${{ runner.temp }}/coverage/dwarfsck.txt,${{ runner.temp }}/coverage/dwarfsextract.txt
fail_ci_if_error: true

0 comments on commit 2f0203e

Please sign in to comment.