From b44c68d2204259bdb54deb8d3086504e88b8065a Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Wed, 1 Dec 2021 11:38:43 +0100 Subject: [PATCH] [INFRA] Add coverage build --- .github/workflows/cancel.yml | 17 ---- .github/workflows/ci_linux.yml | 104 ++++++++++++++------- .github/workflows/ci_misc.yml | 7 +- .github/workflows/scripts/install_cmake.sh | 20 ---- test/unit/coverage/CMakeLists.txt | 33 +++++++ 5 files changed, 107 insertions(+), 74 deletions(-) delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/scripts/install_cmake.sh create mode 100644 test/unit/coverage/CMakeLists.txt diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 66e29ec3..00000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Cancel workflows - -on: [push, pull_request_target] - -env: - TZ: Europe/Berlin - -jobs: - cancel: - name: "Cancel previous runs" - runs-on: ubuntu-20.04 - steps: - - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: ci_linux.yml, ci_macos.yml, ci_misc.yml, ci.yml - all_but_latest: true - access_token: ${{ github.token }} diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 760e3bc7..904b81ec 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/ci_misc.yml b/.github/workflows/ci_misc.yml index e2d890f9..6bd78e60 100644 --- a/.github/workflows/ci_misc.yml +++ b/.github/workflows/ci_misc.yml @@ -77,7 +77,7 @@ jobs: fetch-depth: 3 submodules: recursive - # to reuse scripts + # To reuse scripts - name: Checkout SeqAn3 uses: actions/checkout@v2 with: @@ -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;; diff --git a/.github/workflows/scripts/install_cmake.sh b/.github/workflows/scripts/install_cmake.sh deleted file mode 100644 index d4849e90..00000000 --- a/.github/workflows/scripts/install_cmake.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -set -x -set -e - -if [ "$RUNNER_OS" == "Linux" ]; then - OS="Linux" - CMAKE_PATH="/tmp/cmake-${CMAKE_VERSION}-${OS}-x86_64/bin" -else - OS="Darwin" - CMAKE_PATH="/tmp/cmake-${CMAKE_VERSION}-${OS}-x86_64/CMake.app/Contents/bin" -fi - -if [ "$RUNNER_OS" == "Linux" ] && [[ "$BUILD" =~ ^(external_project)$ ]]; then - sudo apt-get install libidn11 # this is needed for cmake 3.4 within the external_project test -fi - -mkdir -p /tmp/cmake-download -wget --retry-connrefused --waitretry=30 --read-timeout=30 --timeout=30 --tries=20 --no-clobber --quiet --directory-prefix=/tmp/cmake-download/ https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-${OS}-x86_64.tar.gz -tar -C /tmp/ -zxf /tmp/cmake-download/cmake-${CMAKE_VERSION}-${OS}-x86_64.tar.gz -echo "${CMAKE_PATH}" >> $GITHUB_PATH # Only available in subsequent steps! diff --git a/test/unit/coverage/CMakeLists.txt b/test/unit/coverage/CMakeLists.txt new file mode 100644 index 00000000..b2c1612b --- /dev/null +++ b/test/unit/coverage/CMakeLists.txt @@ -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)