Merge pull request #10 from johannes-graeter/f-add-optional-error-sup… #124
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: | |
pull_request: | |
release: | |
types: [published] | |
push: | |
tags: | |
- v** | |
branches: | |
- main | |
- develop | |
env: | |
CLANG_TIDY_VERSION: "17" | |
VERBOSE: 1 | |
ASAN_OPTIONS: "alloc_dealloc_mismatch=0" | |
permissions: | |
contents: write | |
jobs: | |
Test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
# Recommendations: | |
# * support at least 2 operating systems | |
# * support at least 2 compilers | |
# * make sure all supported configurations for your project are built | |
# | |
# Disable/enable builds in this list to meet the above recommendations | |
# and your own projects needs | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- ubuntu-20.04 | |
# - macos-10.15 | |
# - windows-2019 | |
compiler: | |
- llvm-17 | |
- gcc-13 | |
generator: | |
- "Ninja Multi-Config" | |
build_type: | |
- Release | |
- Debug | |
packaging_maintainer_mode: | |
- ON | |
- OFF | |
build_shared: | |
- OFF | |
exclude: | |
# mingw is determined by this author to be too buggy to support | |
- os: windows-2019 | |
compiler: gcc-13 | |
include: | |
# Add appropriate variables for gcov version required. This will intentionally break | |
# if you try to use a compiler that does not have gcov set | |
- compiler: gcc-13 | |
gcov_executable: gcov-13 | |
enable_ipo: On | |
- compiler: llvm-17 | |
enable_ipo: Off | |
gcov_executable: "llvm-cov gcov" | |
# - os: macos-10.15 | |
# enable_ipo: Off | |
# Set up preferred package generators, for given build configurations | |
- build_type: Release | |
packaging_maintainer_mode: OFF | |
package_generator: DEB | |
# # This exists solely to make sure a non-multiconfig build works | |
# - os: ubuntu-22.04 | |
# compiler: llvm-17 | |
# generator: "Unix Makefiles" | |
# build_type: Debug | |
# gcov_executable: gcov | |
# packaging_maintainer_mode: On | |
# enable_ipo: Off | |
# - os: ubuntu-22.04 | |
# compiler: gcc-13 | |
# generator: "Unix Makefiles" | |
# build_type: Debug | |
# gcov_executable: gcov | |
# packaging_maintainer_mode: On | |
# enable_ipo: Off | |
# # Windows msvc builds | |
# - os: windows-2022 | |
# compiler: msvc | |
# generator: "Visual Studio 17 2022" | |
# build_type: Debug | |
# packaging_maintainer_mode: On | |
# enable_ipo: On | |
# - os: windows-2022 | |
# compiler: msvc | |
# generator: "Visual Studio 17 2022" | |
# build_type: Release | |
# packaging_maintainer_mode: On | |
# enable_ipo: On | |
# - os: windows-2022 | |
# compiler: msvc | |
# generator: "Visual Studio 17 2022" | |
# build_type: Debug | |
# packaging_maintainer_mode: Off | |
# - os: windows-2022 | |
# compiler: msvc | |
# generator: "Visual Studio 17 2022" | |
# build_type: Release | |
# packaging_maintainer_mode: Off | |
# package_generator: ZIP | |
# - os: windows-2022 | |
# compiler: msvc | |
# generator: "Visual Studio 17 2022" | |
# build_type: Release | |
# packaging_maintainer_mode: On | |
# enable_ipo: On | |
# build_shared: On | |
steps: | |
- name: Check for llvm version mismatches | |
if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }} | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen') | |
- uses: actions/checkout@v3 | |
- name: Setup Cache | |
uses: ./.github/actions/setup_cache | |
with: | |
compiler: ${{ matrix.compiler }} | |
build_type: ${{ matrix.build_type }} | |
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }} | |
generator: ${{ matrix.generator }} | |
- name: Project Name | |
uses: cardinalby/export-env-action@v2 | |
with: | |
envFile: '.github/constants.env' | |
- name: Setup Cpp | |
uses: aminya/setup-cpp@v1 | |
with: | |
compiler: ${{ matrix.compiler }} | |
vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
cmake: true | |
ninja: true | |
vcpkg: false | |
ccache: true | |
clangtidy: ${{ env.CLANG_TIDY_VERSION }} | |
cppcheck: false | |
gcovr: true | |
opencppcoverage: true | |
- name: Install libc++ | |
run: | | |
sudo apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ | |
sudo apt-get install -y \ | |
gnupg \ | |
clang-${{ env.CLANG_TIDY_VERSION}} llvm-${{ env.CLANG_TIDY_VERSION}}-dev \ | |
lldb-${{ env.CLANG_TIDY_VERSION}} lld-${{ env.CLANG_TIDY_VERSION}} clangd-${{ env.CLANG_TIDY_VERSION}} \ | |
libclang-${{ env.CLANG_TIDY_VERSION}}-dev clang-tidy-${{ env.CLANG_TIDY_VERSION}} clang-format-${{ env.CLANG_TIDY_VERSION}} \ | |
libc++-${{ env.CLANG_TIDY_VERSION}}-dev libc++abi-${{ env.CLANG_TIDY_VERSION}}-dev | |
sudo apt-get clean | |
- name: Install gcc | |
run: | | |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && \ | |
sudo apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ | |
sudo apt-get install -y --no-install-recommends \ | |
gcc-13 g++-13 gdb libstdc++-13-dev | |
- name: Install cmake | |
run: | | |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null && \ | |
sudo apt-add-repository -y "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" && \ | |
sudo apt-get update -qq && export DEBIAN_FRONTEND=noninteractive && \ | |
sudo apt-get install -y --no-install-recommends cmake cmake-curses-gui | |
- name: Configure CMake | |
run: | | |
cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }} | |
- name: Build | |
# Execute the build. You can specify a specific target with "--target <NAME>" | |
run: | | |
cmake --build ./build --config ${{matrix.build_type}} | |
- name: Unix - Test and coverage | |
if: runner.os != 'Windows' | |
working-directory: ./build | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: | | |
ctest -C ${{matrix.build_type}} --output-on-failure | |
gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}' | |
- name: Windows - Test and coverage | |
if: runner.os == 'Windows' | |
working-directory: ./build | |
run: | | |
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}} | |
- name: CPack | |
if: matrix.package_generator != '' | |
working-directory: ./build | |
run: | | |
cpack -C ${{matrix.build_type}} -G ${{matrix.package_generator}} | |
- name: Publish Tagged Release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.package_generator != '' }} | |
with: | |
files: | | |
build/*-*${{ matrix.build_type }}*-*.* | |
- name: Publish to codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
flags: ${{ runner.os }} | |
name: ${{ runner.os }}-coverage | |
files: ./build/coverage.xml |