Skip to content

Commit

Permalink
ci: fix code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed May 7, 2024
1 parent 8fa9d69 commit 4ae4100
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
43 changes: 10 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ jobs:
sudo apt-get install -y \
build-essential \
cmake \
lcov \
ninja-build
- name: Setup Dependencies macOS
if: runner.os == 'macOS'
run: |
brew install \
cmake \
lcov \
ninja
- name: Setup Dependencies Windows
Expand All @@ -61,6 +63,7 @@ jobs:
make
mingw-w64-x86_64-binutils
mingw-w64-x86_64-cmake
mingw-w64-x86_64-lcov
mingw-w64-x86_64-ninja
mingw-w64-x86_64-toolchain
Expand Down Expand Up @@ -118,26 +121,6 @@ jobs:
./deviceinstaller64 enableidd 1
}
- name: Setup python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Python Path
id: python-path
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
# replace backslashes with double backslashes
python_path=$(echo "${{ steps.setup-python.outputs.python-path }}" | sed 's/\\/\\\\/g')
else
python_path="${{ steps.setup-python.outputs.python-path }}"
fi
# step output
echo "python-path=${python_path}"
echo "python-path=${python_path}" >> $GITHUB_OUTPUT
- name: Build
run: |
mkdir -p build
Expand All @@ -151,27 +134,21 @@ jobs:
run: |
./tests/test_libdisplaydevice --gtest_color=yes
- name: Generate gcov report
# any except canceled or skipped
if: always() && (steps.test.outcome == 'success' || steps.test.outcome == 'failure')
id: test_report
working-directory: build
- name: Generate coverage
id: coverage
if: steps.test.outcome == 'success' || steps.test.outcome == 'failure'
run: |
${{ steps.python-path.outputs.python-path }} -m pip install gcovr
${{ steps.python-path.outputs.python-path }} -m gcovr -r .. \
--exclude '.*tests/.*' \
--exclude '.*tests/.*' \
--xml-pretty \
-o coverage.xml
lcov --directory . --capture --output-file coverage.info
- name: Upload coverage
# any except canceled or skipped
if: >-
always() && (steps.test_report.outcome == 'success') &&
always() &&
(steps.coverage.outcome == 'success') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: ./build/coverage.xml
files: ./coverage.info
flags: ${{ runner.os }}
token: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
codecov:
branch: master
notify:
after_n_builds: 3

coverage:
status:
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ gtest_discover_tests(${TEST_BINARY})
# Additional setup for coverage
# https://gcovr.com/en/stable/guide/compiling.html#compiler-options
#
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O1")
set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O1")
set(CMAKE_CXX_FLAGS "-fprofile-arcs -ftest-coverage -O0")
set(CMAKE_C_FLAGS "-fprofile-arcs -ftest-coverage -O0")

0 comments on commit 4ae4100

Please sign in to comment.