CI #198
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
- '**.md' | |
- '**.yml' | |
pull_request: | |
branches: [ main ] | |
# Manual trigger | |
workflow_dispatch: | |
env: | |
BUILD_TYPE: Debug | |
jobs: | |
ci: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
compiler: ['g++', 'clang++'] | |
env: | |
WITH_GNU: ${{ matrix.compiler == 'g++' }} | |
WITH_CLANG: ${{ matrix.compiler == 'clang++' }} | |
BUILD_DIR: ${{ github.workspace }}/build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/install-ubuntu-packages | |
with: | |
with_ninja: true | |
with_clang: ${{ env.WITH_CLANG }} | |
with_llvm_linker: true | |
with_doxygen: ${{ env.WITH_GNU }} | |
with_lcov: ${{ env.WITH_GNU }} | |
# CodeQL needs to observe the build | |
- name: Initialize CodeQL | |
id: setup-codeql | |
if: env.WITH_GNU == 'true' | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: cpp, python | |
- name: Build | |
run: | | |
cmake -G Ninja -B ${{ env.BUILD_DIR }} -D CMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -D ENABLE_CODE_COVERAGE=ON -D USE_SANITISER=ON -D CMAKE_CXX_COMPILER=${{ matrix.compiler }} | |
cmake --build ${{ env.BUILD_DIR }} | |
- name: Perform CodeQL Analysis | |
if: steps.setup-codeql.outcome != 'skipped' | |
uses: github/codeql-action/analyze@v3 | |
- name: Run the unit tests | |
working-directory: ${{ env.BUILD_DIR }} | |
run: | | |
cmake ${{github.workspace}} -DUNIT_TEST_LEVEL=1_Continuous | |
ctest -VV | |
- name: Generate coverage report | |
id: generate-coverage-report | |
if: env.WITH_GNU == 'true' | |
# Coverage report | |
# gcov version must match that of g++ | |
working-directory: ${{ env.BUILD_DIR }} | |
run: | | |
lcov --directory . --capture --output-file coverage.lcov --gcov-tool gcov | |
lcov --remove coverage.lcov '/usr/*' "${HOME}"'/.cache/*' --output-file coverage.lcov | |
- name: Upload coverage report to Codecov | |
if: steps.generate-coverage-report.outcome != 'skipped' | |
# Sends the coverage report to Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: ${{ env.BUILD_DIR }}/coverage.lcov | |
flags: unittests | |
fail_ci_if_error: true | |
- name: Generate documentation | |
id: generate-documentation | |
if: env.WITH_GNU == 'true' | |
run: | | |
cmake --build ${{ env.BUILD_DIR }} --target docs | |
- name: Deploy documentation | |
if: steps.generate-documentation.outcome != 'skipped' | |
# Deploys the documentation to GitHub Pages | |
uses: peaceiris/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ${{ env.BUILD_DIR }}/html | |