Skip to content

Commit

Permalink
[INFRA] Add coverage build
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Dec 1, 2021
1 parent c6d164b commit b44c68d
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 74 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/cancel.yml

This file was deleted.

104 changes: 71 additions & 33 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: CI on Linux
on:
push:
branches:
# Push events to branches matching refs/heads/master
- 'master'
pull_request:

concurrency:
group: linux-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CMAKE_VERSION: 3.10.3
SEQAN3_NO_VERSION_CHECK: 1
Expand All @@ -25,50 +28,66 @@ jobs:
fail-fast: true
matrix:
include:
- name: "Coverage gcc11"
cxx: "g++-11"
cc: "gcc-11"
build_type: Coverage

- name: "Unit gcc11"
cxx: "g++-11"
cc: "gcc-11"
build: unit
build_type: Release
build_threads: 2
test_threads: 2

- name: "Unit gcc10"
cxx: "g++-10"
cc: "gcc-10"
build: unit
build_type: Release
build_threads: 2
test_threads: 2

- name: "Unit gcc9 (c++2a)"
cxx: "g++-9"
cc: "gcc-9"
build_type: Release
cxx_flags: "-std=c++2a"

steps:
- name: Checkout Sharg
- name: Checkout
uses: actions/checkout@v2
with:
path: sharg
fetch-depth: 3
fetch-depth: 2
submodules: recursive

# To reuse scripts
- name: Checkout SeqAn3
uses: actions/checkout@v2
with:
repository: seqan/seqan3
ref: 383e8f8d638f8a727a79136ce96ae7642befe39f
path: seqan3
fetch-depth: 2
submodules: false

- name: Add package source
run: |
sudo add-apt-repository --no-update --yes ppa:ubuntu-toolchain-r/ppa
sudo add-apt-repository --no-update --yes ppa:ubuntu-toolchain-r/test
sudo apt-get update
run: bash ./seqan3/.github/workflows/scripts/configure_apt.sh

- name: Install CMake
run: bash ./sharg/.github/workflows/scripts/install_cmake.sh
run: bash ./seqan3/.github/workflows/scripts/install_cmake.sh

- name: Install ccache
run: sudo apt-get install --yes ccache
run: |
conda install --yes --override-channels --channel conda-forge ccache
sudo ln -s $CONDA/bin/ccache /usr/bin/ccache
- name: Install compiler ${{ matrix.cxx }}
run: sudo apt-get install --yes ${{ matrix.cxx }}

- name: Install lcov
if: matrix.build == 'coverage'
if: matrix.build_type == 'Coverage'
env:
CC: ${{ matrix.cc }}
run: |
sudo apt-get install --yes lcov
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-7 100
sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/${CC/gcc/gcov} 100
- name: Load ccache
uses: actions/cache@v2
Expand All @@ -91,33 +110,52 @@ jobs:
CXX: ${{ matrix.cxx }}
CC: ${{ matrix.cc }}
run: |
mkdir sharg-build
cd sharg-build
cmake ../sharg/test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" -DSHARG_VERBOSE_TESTS=OFF -DSHARG_BENCHMARK_MIN_TIME=0.01
make gtest_build
mkdir build
cd build
cmake ../sharg/test/unit -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \
-DSHARG_VERBOSE_TESTS=OFF
make -j2 gtest_build
- name: Build tests
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 6
CCACHE_MAXSIZE: 1G
CCACHE_COMPRESSLEVEL: 12
CCACHE_MAXSIZE: ${{ matrix.build_type == 'Coverage' && '125M' || '50M' }}
run: |
ccache -z
cd build
make -k -j2
ccache -sv
- name: Generate coverage baseline
if: matrix.build_type == 'Coverage'
run: |
ccache -p || true
cd sharg-build
make -k -j${{ matrix.build_threads }}
ccache -s || true
lcov --directory ./build/ --zerocounters
lcov --directory ./build/ --capture --initial --output-file ./build/coverage_report.baseline
- name: Run tests
if: matrix.build != 'coverage'
run: |
cd sharg-build
ctest . -j${{ matrix.test_threads }} --output-on-failure
cd build
ctest . -j2 --output-on-failure
- name: Submit coverage build
if: matrix.build == 'coverage'
- name: Generate coverage report
if: matrix.build_type == 'Coverage'
run: |
lcov --directory ./build/ --capture --output-file ./build/coverage_report.captured
lcov -a ./build/coverage_report.baseline -a ./build/coverage_report.captured --output-file ./build/coverage_report.total
lcov --remove ./build/coverage_report.total \
'/usr/*' \
'${{ github.workspace }}/sharg/lib/*' \
'${{ github.workspace }}/sharg/test/*' \
'${{ github.workspace }}/build/vendor/*' \
--output-file ./build/coverage_report
- name: Submit coverage report
if: matrix.build_type == 'Coverage'
uses: codecov/codecov-action@v1
with:
files: ${{ github.workspace }}/sharg-build/sharg_coverage
files: ${{ github.workspace }}/build/coverage_report
root_dir: ${{ github.workspace }}/sharg
7 changes: 3 additions & 4 deletions .github/workflows/ci_misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
fetch-depth: 3
submodules: recursive

# to reuse scripts
# To reuse scripts
- name: Checkout SeqAn3
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -140,9 +140,8 @@ jobs:
cd sharg-build
cmake ../sharg/test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \
-DSEQAN3_VERBOSE_TESTS=OFF \
-DSEQAN3_BENCHMARK_MIN_TIME=0.01 \
-DSEQAN3_USE_INCLUDE_DEPENDENCIES="${{ matrix.use_include_dependencies }}"
-DSHARG_VERBOSE_TESTS=OFF \
-DSHARG_USE_INCLUDE_DEPENDENCIES="${{ matrix.use_include_dependencies }}"
case "${{ matrix.build }}" in
snippet) make -j${{ matrix.build_threads }} gtest_build;;
header) make -j${{ matrix.build_threads }} gtest_build gbenchmark_build;;
Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/scripts/install_cmake.sh

This file was deleted.

33 changes: 33 additions & 0 deletions test/unit/coverage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -----------------------------------------------------------------------------------------------------
# Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
# Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
# shipped with this file and also available at: https://github.com/seqan/raptor/blob/master/LICENSE.md
# -----------------------------------------------------------------------------------------------------

cmake_minimum_required (VERSION 3.10)

# Add a custom build type: Coverage

set (CMAKE_CXX_FLAGS_COVERAGE
"${CMAKE_CXX_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage" CACHE STRING
"Flags used by the C++ compiler during coverage builds."
FORCE)
set (CMAKE_C_FLAGS_COVERAGE
"${CMAKE_C_FLAGS_DEBUG} --coverage -fprofile-arcs -ftest-coverage" CACHE STRING
"Flags used by the C compiler during coverage builds."
FORCE)
set (CMAKE_EXE_LINKER_FLAGS_COVERAGE
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,-lgcov" CACHE STRING
"Flags used for linking binaries during coverage builds."
FORCE)
set (CMAKE_SHARED_LINKER_FLAGS_COVERAGE
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,-lgcov" CACHE STRING
"Flags used by the shared libraries linker during coverage builds."
FORCE)

mark_as_advanced (
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE)

0 comments on commit b44c68d

Please sign in to comment.