From d6be590c2b56642e1c2baf6981346521795365fa Mon Sep 17 00:00:00 2001 From: Matthew Rodusek Date: Sat, 30 Jan 2021 21:03:59 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A6=20Add=20coverage=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a Github workflow for adding coveralls code coverage support. In order for this change to be effective, the GCC/clang attribute for preventing instrumentation has been removed. --- .github/workflows/coverage.yml | 92 +++++++++++++++++++++++++++++++++ README.md | 3 ++ include/bpstd/detail/config.hpp | 6 +-- 3 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..dd1a3a5 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,92 @@ +name: "Code Coverage" + +on: + push: + paths: + - 'include/**.hpp' + - 'test/**.cpp' + - '**.cmake' + - 'conanfile.py' + - 'CMakeLists.txt' + - 'test/CMakeLists.txt' + - '.github/workflows/coverage.yml' + pull_request: + paths: + - 'include/**.hpp' + - 'test/**.cpp' + - '**.cmake' + - 'conanfile.py' + - 'CMakeLists.txt' + - 'test/CMakeLists.txt' + - '.github/workflows/coverage.yml' + +jobs: + coverage: + name: Ubuntu ${{matrix.compiler.cc}} Coverage + runs-on: ubuntu-20.04 + + env: + build-directory: build + + strategy: + matrix: + compiler: + - { cc: gcc-10, cxx: g++-10 } + - { cc: clang-10, cxx: clang++-10 } + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Prepare Environment + run: | + if [[ "${{matrix.compiler.cc}}" =~ "gcc" ]]; then + sudo apt-get install -y ${{matrix.compiler.cxx}} + else + sudo apt-get install -y ${{matrix.compiler.cxx}} llvm + fi + sudo apt-get install lcov + python -m pip install --upgrade pip + pip install conan + cmake -E make_directory ${{env.build-directory}} + cmake -E chdir ${{env.build-directory}} conan install .. + + - name: Configure + working-directory: ${{env.build-directory}} + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + cmake .. -DCMAKE_BUILD_TYPE=Debug -DBACKPORT_COMPILE_UNIT_TESTS=On -DCMAKE_CXX_FLAGS="--coverage" + cmake --build . + + - name: Build + working-directory: ${{env.build-directory}} + run: cmake --build . + + - name: Test + working-directory: ${{env.build-directory}} + run: ctest --output-on-failure + + - name: Process Coverage Data + working-directory: ${{env.build-directory}} + run: | + gcov $(find $(pwd) -name '*.o' -type f) + # Generate coverage information + lcov --capture --directory . --output-file coverage_unfiltered.info + # Strip symbols from 'test' directory + lcov --remove coverage_unfiltered.info -o coverage.info \ + "$(cd ..; pwd)/test/*" \ + "${HOME}/.conan/*" \ + "/usr/*" \ + + - name: Generate Coverage + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + path-to-lcov: ${{env.build-directory}}/coverage.info diff --git a/README.md b/README.md index bb48f00..218a7c7 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,14 @@ [![macOS Build Status](https://github.com/bitwizeshift/BackportCpp/workflows/macOS/badge.svg?branch=master)](https://github.com/bitwizeshift/BackportCpp/actions?query=workflow%3AmacOS) [![Windows Build Status](https://github.com/bitwizeshift/BackportCpp/workflows/Windows/badge.svg?branch=master)](https://github.com/bitwizeshift/BackportCpp/actions?query=workflow%3AWindows) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/64b1ffd7f95b488eb70a11ee21eb1792)](https://www.codacy.com/manual/bitwizeshift/BackportCpp?utm_source=github.com&utm_medium=referral&utm_content=bitwizeshift/BackportCpp&utm_campaign=Badge_Grade) +[![Coverage Status](https://coveralls.io/repos/github/bitwizeshift/BackportCpp/badge.svg?branch=master)](https://coveralls.io/github/bitwizeshift/BackportCpp?branch=master) [![Github Issues](https://img.shields.io/github/issues/bitwizeshift/BackportCpp.svg)](http://github.com/bitwizeshift/BackportCpp/issues)
[![Github Releases](https://img.shields.io/github/v/release/bitwizeshift/BackportCpp.svg?include_prereleases)](https://github.com/bitwizeshift/BackportCpp/releases) [![Bintray Releases](https://api.bintray.com/packages/bitwizeshift/public-conan/Backport%3Abackport/images/download.svg) ](https://bintray.com/bitwizeshift/public-conan/Backport%3Abackport/_latestVersion) +------------------------------ + **Backport** is an ongoing effort to bring modern C++ utilities to be compatible with C++11. diff --git a/include/bpstd/detail/config.hpp b/include/bpstd/detail/config.hpp index 0fdea82..8066b0f 100644 --- a/include/bpstd/detail/config.hpp +++ b/include/bpstd/detail/config.hpp @@ -73,9 +73,9 @@ // When using 'clang-cl', don't forceinline -- since it results in code generation // failures in 'variant' #if defined(__clang__) && defined(_MSC_VER) -# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"), no_instrument_function)) +# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"))) #elif defined(__clang__) || defined(__GNUC__) -# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline, no_instrument_function)) +# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline)) #elif defined(_MSC_VER) # define BPSTD_INLINE_VISIBILITY __forceinline #else @@ -86,7 +86,7 @@ # define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE \ __pragma(warning(push)) \ __pragma(warning(disable:4714)) \ - __pragma(warning(disable:4100)) + __pragma(warning(disable:4100)) #else # define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE #endif