Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gcov to ci #165

Merged
merged 6 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions .gcov/make/make_gcov_01_generic.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,43 @@ gcov: $(PATH_BIN)/wide_decimal.exe
@$(PATH_BIN)/wide_decimal.exe
@$(GNUECHO)
@$(GNUECHO) +++ running gcov
@$(GCOV) $(GCOV_FLAGS) $(addsuffix .cpp,$(FILES_PRJ)) --object-directory obj
@$(GCOV) $(GCOV_FLAGS) $(addsuffix .cpp,$(FILES_PRJ))
@$(GNUECHO)
@$(GNUECHO) +++ running lcov
@$(LCOV) $(LCOV_BRANCH) -c --directory obj --output-file coverage_unfiltered.info
@$(LCOV) $(LCOV_BRANCH) --remove coverage_unfiltered.info $(LCOV_REMOVES) --output-file coverage.info
@$(GNUECHO)
@$(GNUECHO) +++ running genhtml
@$(GENHTML) coverage.info $(LCOV_BRANCH) --demangle-cpp --output-directory $(PATH_BIN)/report
@$(GNUECHO)
@$(LCOV) -c --directory obj --output-file coverage.info
@$(LCOV) --remove coverage.info '/usr/*' --output-file coverage.info
@$(LCOV) --remove coverage.info '*boost/*' --output-file coverage.info
@$(GENHTML) coverage.info --demangle-cpp --output-directory out

# ------------------------------------------------------------------------------
# Clean temporary files.
# ------------------------------------------------------------------------------

.PHONY: prepare
prepare:
.PHONY: clean
clean:
# creating output directories
@$(GNUECHO) +++ cleaning output directories
@-$(RM) -rf $(PATH_BIN)* || uname -r
@-$(RM) -rf $(PATH_ERR)* || uname -r
@-$(RM) -rf $(PATH_OBJ)* || uname -r
@-$(RM) -f *.gcov || uname -r
@-$(RM) -f coverage* || uname -r
@$(GNUECHO)


# ------------------------------------------------------------------------------
# Prepare the gcov build.
# ------------------------------------------------------------------------------

.PHONY: prepare
prepare: clean
@$(GNUECHO) +++ creating output directories
@-$(MKDIR) -p $(PATH_BIN)
@-$(MKDIR) -p $(PATH_ERR)
@-$(MKDIR) -p $(PATH_OBJ)
@$(GNUECHO)
@$(GNUECHO) +++ cleaning output directories
@-$(RM) -rf $(PATH_BIN)/*.*
@-$(RM) -rf $(PATH_ERR)/*.*
@-$(RM) -rf $(PATH_OBJ)/*.*
@$(GNUECHO)
@$(GNUECHO) +++ print gcov version
@$(GCOV) --version
@$(GNUECHO)
Expand Down
30 changes: 28 additions & 2 deletions .gcov/make/make_gcov_03_flags.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
# ------------------------------------------------------------------------------

BOOST_ROOT_FOR_GCOV = /mnt/c/boost/boost_1_78_0
CC = g++-10
CC = g++
STD = c++11
ALL_COV = 0

ifneq ($(MY_BOOST_ROOT),)
BOOST_ROOT_FOR_GCOV := $(MY_BOOST_ROOT)
Expand All @@ -21,6 +22,14 @@ ifneq ($(MY_STD),)
STD := $(MY_STD)
endif

ifneq ($(MY_STD),)
STD := $(MY_STD)
endif

ifneq ($(MY_ALL_COV),)
ALL_COV := $(MY_ALL_COV)
endif

CXXFLAGS = -march=native \
-mtune=native \
-O2 \
Expand All @@ -43,5 +52,22 @@ C_INCLUDES = $(PATH_SRC) \
C_DEFINES :=$(addprefix -D,$(C_DEFINES))
C_INCLUDES :=$(addprefix -I,$(C_INCLUDES))

GCOV_FLAGS = --object-directory obj \
--all-blocks \
--function-summaries \
--demangled-names

ifneq ($(ALL_COV),0)
GCOV_FLAGS := $(GCOV_FLAGS) \
--branch-counts \
--branch-probabilities
endif

LCOV_BRANCH =

ifneq ($(ALL_COV),0)
LCOV_BRANCH := --rc lcov_branch_coverage=1
endif

GCOV_FLAGS = -b -c -m
LCOV_REMOVES = '/usr/*' \
'*boost/*'
40 changes: 0 additions & 40 deletions .github/workflows/wide_decimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,6 @@ jobs:
echo
echo "verify empty word count of ./tmp/all.tidy_txt"
wc ./tmp/all.tidy_txt | grep '0 0 0'
gnumake-gcc-gcov-native:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
standard: [ c++11 ]
compiler: [ g++ ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: update-tools
run: sudo apt install lcov
- name: clone-submods-bootstrap-headers-boost-develop
run: |
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
cd ../boost-root
git submodule update --init tools
git submodule update --init libs/config
git submodule update --init libs/math
cd libs/math
git checkout no_exceptions_or_rtti_error_handling
cd ../..
git submodule update --init libs/multiprecision
./bootstrap.sh
./b2 headers
- name: gnumake-gcc-gcov-native
run: |
grep BOOST_VERSION ../boost-root/boost/version.hpp
cd .gcov/make
echo "running gcov"
echo "make prepare -f make_gcov_01_generic.gmk MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
echo
make prepare -f make_gcov_01_generic.gmk MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
echo "make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
echo
gcc-clang-native:
runs-on: ubuntu-20.04
defaults:
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/wide_decimal_codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# ------------------------------------------------------------------------------
# Copyright Christopher Kormanyos 2022.
# Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
# ------------------------------------------------------------------------------

name: wide_decimal_codecov
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
gnumake-gcc-gcov-native:
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
standard: [ c++11 ]
compiler: [ g++ ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: update-tools
run: sudo apt install lcov
- name: clone-submods-bootstrap-headers-boost-develop
run: |
git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
cd ../boost-root
git submodule update --init tools
git submodule update --init libs/config
git submodule update --init libs/math
cd libs/math
git checkout no_exceptions_or_rtti_error_handling
cd ../..
git submodule update --init libs/multiprecision
./bootstrap.sh
./b2 headers
- name: gnumake-gcc-gcov-native
run: |
grep BOOST_VERSION ../boost-root/boost/version.hpp
cd .gcov/make
echo "build and run gcov/lcov/genhtml"
echo "make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
echo
make prepare -f make_gcov_01_generic.gmk MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
echo
echo "make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}"
echo
make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_ALL_COV=0 MY_BOOST_ROOT=../../../boost-root MY_CC=${{ matrix.compiler }} MY_STD=${{ matrix.standard }}
echo
echo "return to wide-decimal root directory"
cd ../..
- name: upload-codecov
uses: codecov/codecov-action@v2
with:
files: .gcov/make/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
functionalities: fix
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Total alerts](https://img.shields.io/lgtm/alerts/g/ckormanyos/wide-decimal.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ckormanyos/wide-decimal/alerts/)
[![Coverity Scan](https://scan.coverity.com/projects/24792/badge.svg)](https://scan.coverity.com/projects/ckormanyos-wide-decimal)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ckormanyos_wide-decimal&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ckormanyos_wide-decimal)
[![codecov](https://codecov.io/gh/ckormanyos/wide-decimal/branch/main/graph/badge.svg?token=9SEP7RLNSO)](https://codecov.io/gh/ckormanyos/wide-decimal)
[![Boost Software License 1.0](https://img.shields.io/badge/license-BSL%201.0-blue.svg)](https://github.com/ckormanyos/wide-decimal/blob/master/LICENSE_1_0.txt)
[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/ckormanyos/wide-decimal)](https://github.com/ckormanyos/wide-decimal)

Expand Down
5 changes: 3 additions & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
// make tidy -f make_tidy_01_generic.gmk --jobs=8 MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0

// cd .gcov/make
// make prepare -f make_gcov_01_generic.gmk MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0
// make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0
// make clean -f make_gcov_01_generic.gmk MY_CC=g++ MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0
// make prepare -f make_gcov_01_generic.gmk MY_CC=g++ MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0
// make gcov -f make_gcov_01_generic.gmk --jobs=8 MY_CC=g++ MY_ALL_COV=0 MY_BOOST_ROOT=/mnt/c/boost/boost_1_79_0

// cd /mnt/c/Users/User/Documents/Ks/PC_Software/NumericalPrograms/ExtendedNumberTypes/wide_decimal
// PATH=/home/chris/local/coverity/cov-analysis-linux64-2021.12.1/bin:$PATH
Expand Down
1 change: 1 addition & 0 deletions wide_decimal.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
<None Include=".gcov\make\make_gcov_02_files.gmk" />
<None Include=".gcov\make\make_gcov_03_flags.gmk" />
<None Include=".github\toolchains\gcc.cmake" />
<None Include=".github\workflows\wide_decimal_codecov.yml" />
<None Include=".github\workflows\wide_decimal.yml" />
<None Include=".github\workflows\wide_decimal_sonar.yml" />
<None Include=".props\Directory.Build.props" />
Expand Down
3 changes: 3 additions & 0 deletions wide_decimal.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@
<None Include=".props\Directory.Build.props">
<Filter>.props</Filter>
</None>
<None Include=".github\workflows\wide_decimal_codecov.yml">
<Filter>.github\workflows</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="examples\CMakeLists.txt">
Expand Down