Skip to content

Commit

Permalink
Merge pull request #50 from injae/dev
Browse files Browse the repository at this point in the history
add code coverage
  • Loading branch information
injae authored Mar 2, 2022
2 parents a9b1da0 + a24b483 commit 73a93d4
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/code-cov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CodeCov

on: [pull_request]

jobs:
ubuntu-bionic-llvm-code-cov:
runs-on: ubuntu-18.04
env:
CMAKE_FLAGS: '-DSERDEPP_USE_NLOHMANN_JSON=ON -DSERDEPP_USE_TOML11=ON -DSERDEPP_USE_YAML-CPP=ON -DSERDEPP_USE_RAPIDJSON=ON -DSERDEPP_USE_FMT=ON -DSERDEPP_BUILD_TESTING=ON -DSERDEPP_USE_CATCH2=ON'
strategy:
matrix:
build-type: ['Debug']
clang-version: ['8']
steps:
- name: ccache
uses: hendrikmuhs/ccache-action@v1
- name: C++ Setting
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository -y "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-${{matrix.clang-version}} main"
sudo apt-get update
sudo apt-get install -yq clang-${{matrix.clang-version}} libc++-dev libc++abi-dev libstdc++-${{matrix.clang-version}}-dev build-essential cmake
sudo apt-get install -yq libllvm${{matrix.clang-version}} llvm-${{matrix.clang-version}} llvm-${{matrix.clang-version}}-dev llvm-${{matrix.clang-version}}-runtime
- name: Compiler Setting
run: |
echo "CC=clang-${{matrix.clang-version}}" >> $GITHUB_ENV
echo "CXX=clang++-${{matrix.clang-version}}" >> $GITHUB_ENV
- name: Clone Repository
uses: actions/checkout@master
with:
submodules: true
- name: CMake build
run: |
cmake -Bbuild -DCMAKE_BUILD_TYPE=${{matrix.build-type}} ${{env.CMAKE_FLAGS}} .
cd build
cmake --build . --config ${{matrix.build-type}}
- name: Generate Coverage Report
run: |
cd build/${{matrix.build-type}}
./unittest
llvm-profdata-${{matrix.clang-version}} merge -sparse default.profraw -o default.profdata
llvm-cov-${{matrix.clang-version}} export ./unittest --instr-profile default.profdata -format=lcov >> lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
directory: ./build/${{matrix.build-type}}
files: lcov.info
flags: unittest
fail_ci_if_error: true
verbose: true
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ cppm_project()
project(serdepp VERSION 0.1.4 LANGUAGES C CXX)
cppm_setting()
cppm_cxx_standard(17)
cppm_compiler_option(DEFAULT)
cppm_compiler_option(
DEBUG
CLANG "-fprofile-instr-generate -fcoverage-mapping"
)

find_cppkg(benchmark 1.5.2 MODULE benchmark::benchmark TYPE lib OPTIONAL OFF)
find_cppkg(RapidJSON 1.1.1 MODULE rapidjson TYPE lib OPTIONAL OFF)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Serdepp [![Linux](https://github.com/injae/serdepp/actions/workflows/linux.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/linux.yml) [![Windows](https://github.com/injae/serdepp/actions/workflows/window.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/window.yml) [![MacOS](https://github.com/injae/serdepp/actions/workflows/macos.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/macos.yml)
# Serdepp [![Linux](https://github.com/injae/serdepp/actions/workflows/linux.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/linux.yml) [![Windows](https://github.com/injae/serdepp/actions/workflows/window.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/window.yml) [![MacOS](https://github.com/injae/serdepp/actions/workflows/macos.yml/badge.svg)](https://github.com/injae/serdepp/actions/workflows/macos.yml)[![codecov](https://codecov.io/gh/injae/serdepp/branch/main/graph/badge.svg?token=2L217GF77B)](https://codecov.io/gh/injae/serdepp)
c++17 low cost serialize deserialize adaptor library like rust serde.rs
- [Features](#Features)
- [Get Started](#Get-Started)
Expand Down
3 changes: 3 additions & 0 deletions cppm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#[cmake]
# include=["cmake/Lua.cmake"]

[profile.dev.compiler]
clang = "-fprofile-instr-generate -fcoverage-mapping"

[lib]
name = "serdepp"
type = "static"
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/Catch2/2.9.1/Catch2.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ project(Catch2-2.9.1-install)

set(CPPM_VERSION ${CPPM_VERSION})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppm_loader.cmake)
download_package(Catch2 2.9.1 URL https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz TYPE lib CMAKE_ARGS ${CMAKE_ARGS} )
download_package(Catch2 2.9.1 URL https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz TYPE lib CMAKE_ARGS ${CMAKE_ARGS} -DCATCH_BUILD_TESTING=OFF)

3 changes: 2 additions & 1 deletion thirdparty/Catch2/2.9.1/cppkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
version = "2.9.1"
description = "modern, C++-native, header-only, test framework for unit-tests"
module = "Catch2::Catch2"
url="https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz"
url="https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz"
flags="-DCATCH_BUILD_TESTING=OFF"

0 comments on commit 73a93d4

Please sign in to comment.