Skip to content

Commit 51c30e9

Browse files
Thoemi09Wentzell
authored andcommitted
[ghactions] Generate and deploy test coverage information
1 parent ad173dd commit 51c30e9

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

.github/workflows/build.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
include:
29-
- {os: ubuntu-22.04, cc: gcc-12, cxx: g++-12, doc: OFF}
30-
- {os: ubuntu-22.04, cc: clang-15, cxx: clang++-15, doc: ON}
31-
- {os: macos-12, cc: gcc-12, cxx: g++-12, doc: OFF}
32-
- {os: macos-12, cc: clang, cxx: clang++, doc: OFF}
29+
- {os: ubuntu-22.04, cc: gcc-12, cxx: g++-12, doc: OFF, cov: ON}
30+
- {os: ubuntu-22.04, cc: clang-15, cxx: clang++-15, doc: ON, cov: OFF}
31+
- {os: macos-12, cc: gcc-12, cxx: g++-12, doc: OFF, cov: OFF}
32+
- {os: macos-12, cc: clang, cxx: clang++, doc: OFF, cov: OFF}
3333

3434
runs-on: ${{ matrix.os }}
3535

@@ -79,6 +79,15 @@ jobs:
7979
python3-sphinx
8080
python3-nbsphinx
8181
82+
- name: Install gcovr for test coverage
83+
if: matrix.cov == 'ON'
84+
run: |
85+
python3 -m venv --system-site-packages $HOME/.venv/my_python
86+
source $HOME/.venv/my_python/bin/activate
87+
pip install gcovr
88+
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
89+
echo "PATH=$PATH" >> $GITHUB_ENV
90+
8291
- name: Install homebrew dependencies
8392
if: matrix.os == 'macos-12'
8493
run: |
@@ -123,7 +132,8 @@ jobs:
123132
mv tmp_basic_array.hpp basic_array.hpp
124133
mv tmp_basic_array_view.hpp basic_array_view.hpp
125134
126-
- name: Build nda
135+
- name: Build nda without test coverage
136+
if: matrix.cov == 'OFF'
127137
env:
128138
CC: ${{ matrix.cc }}
129139
CXX: ${{ matrix.cxx }}
@@ -132,6 +142,17 @@ jobs:
132142
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/install -DBuild_Documentation=${{ matrix.doc }} -DPythonSupport=ON
133143
make -j2 || make -j1 VERBOSE=1
134144
145+
- name: Build nda with test coverage
146+
if: matrix.cov == 'ON'
147+
env:
148+
CC: ${{ matrix.cc }}
149+
CXX: ${{ matrix.cxx }}
150+
LIBRARY_PATH: /usr/local/opt/llvm/lib
151+
CXXFLAGS: "${{ env.CXXFLAGS }} --coverage"
152+
run: |
153+
mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/install -DPythonSupport=OFF -DCMAKE_BUILD_TYPE=Debug
154+
make -j2 || make -j1 VERBOSE=1
155+
135156
- name: Test nda
136157
env:
137158
DYLD_FALLBACK_LIBRARY_PATH: /usr/local/opt/llvm/lib
@@ -140,6 +161,13 @@ jobs:
140161
cd build
141162
ctest -j2 --output-on-failure
142163
164+
- name: Generate test coverage HTML output
165+
if: matrix.cov == 'ON'
166+
run: |
167+
cd build
168+
mkdir coverage
169+
gcovr --gcov-executable "gcov-12" --root ../c++ --html-details -o coverage/coverage.html .
170+
143171
- name: ccache statistics
144172
if: always()
145173
run: ccache -sv
@@ -157,3 +185,11 @@ jobs:
157185
folder: build/doc/html
158186
branch: github.io
159187
target-folder: docs/unstable
188+
189+
- name: Deploy test coverage
190+
if: matrix.cov == 'ON' && github.ref == 'refs/heads/unstable'
191+
uses: JamesIves/github-pages-deploy-action@v4
192+
with:
193+
folder: build/coverage
194+
branch: github.io
195+
target-folder: docs/coverage

0 commit comments

Comments
 (0)