Skip to content

Commit

Permalink
Add code-coverage GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhashiniNaik committed Nov 18, 2024
1 parent ee26225 commit cd34715
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
run: |
cmake -B cmake-build-unit-tests -S executables/unitTest -DBUILD_UNIT_TESTS=ON
cmake --build cmake-build-unit-tests -j4
ctest --test-dir cmake-build-unit-tests -j4
ctest --test-dir cmake-build-unit-tests -j4
28 changes: 15 additions & 13 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Code Coverage Report

on: [push, pull_request]
on: [workflow_call,push, pull_request]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -14,23 +14,23 @@ jobs:

steps:
- uses: actions/checkout@v4
# - name: Update package list
# run: sudo apt update

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.22.x'

- name: Test
# Execute tests defined by the CMake configuration.
run: |
cmake -B cmake-build-unit-tests -S executables/unitTest -DBUILD_UNIT_TESTS=ON
cmake -B cmake-build-unit-tests -S executables/unitTest -DBUILD_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build cmake-build-unit-tests -j4
ctest --test-dir cmake-build-unit-tests -j4
#Code coverage
- name: Install lcov
run: sudo apt install lcov

# no-external command excludes the system libraries in the root directory
- name: Capture code coverage
run: |
echo "Capturing code coverage..."
Expand All @@ -53,13 +53,15 @@ jobs:
echo "Generating HTML coverage report..."
genhtml cmake-build-unit-tests/coverage.info \
--output-directory cmake-build-unit-tests/coverage

- name: Zip the coverage report
run: |
mv cmake-build-unit-tests/coverage code_coverage
zip -r code_coverage.zip code_coverage
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
- name: Upload code coverage artifact
uses: actions/upload-artifact@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: cmake-build-unit-tests/coverage
destination_dir: code-coverage
force_orphan: false


name: code_coverage
path: code_coverage.zip
17 changes: 16 additions & 1 deletion .github/workflows/doc-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jobs:
build-sphinx-docs:
uses: ./.github/workflows/sphinx-doc-build.yml

build-code-coverage:
uses: ./.github/workflows/code-coverage.yml

publish-docs:
runs-on: ubuntu-latest
needs: build-sphinx-docs
needs: [build-sphinx-docs, build-code-coverage]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -31,6 +34,18 @@ jobs:
unzip sphinx_docs.zip
rm sphinx_docs.zip
- name: Download Code coverage report
uses: actions/download-artifact@v4
with:
name: code_coverage
path: ./doc/github_pages

- name: Unzip Code coverage report
working-directory: ./doc/github_pages
run: |
unzip code_coverage.zip
rm code_coverage.zip
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ allowing developers to get up and running quickly.
The [documentation](https://eclipse-openbsw.github.io/openbsw)
describes Eclipse OpenBSW in detail and provides simple setup guides to build and use it.

## Code coverage

Code coverage report [here](https://esrlabs.github.io/openbsw/coverage/index.html)

## Contributing

It is expected that this respository will be used as a starting point for many custom developments.
Expand Down
2 changes: 1 addition & 1 deletion doc/github_pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2><a href="sphinx_docs/doc/index.html">Welcome to Eclipse OpenBSW</a></h2>
<h3><a href="doxygenOut/html/index.html">Doxygen-generated API docs</a></h3>
<h3>Coverage reports</h3>
<ul>
<li><a href="code_coverage_url">Code coverage report</a></li>
<li><a href="code-coverage/index.html">Code coverage report</a></li>
<li><a href="api_doc_coverage_url">API doc coverage report</a></li>
</ul>
</body>
Expand Down

0 comments on commit cd34715

Please sign in to comment.