Skip to content

use switches

use switches #3097

Workflow file for this run

name: Build
on:
push:
workflow_dispatch:
jobs:
# =========================================================
# Build Job
# =========================================================
build:
name: CMake - ${{ matrix.platform[0] }} - ${{ matrix.platform[2] }} - ${{ matrix.platform[3] }}
runs-on: ${{ matrix.platform[1] }}
strategy:
matrix:
platform:
- [windows, windows-latest, msvc, Debug, msvc, AMD64]
- [windows, windows-latest, msvc, Release, msvc, AMD64]
- [windows, windows-latest, gnu, Debug, gnu, AMD64]
- [windows, windows-latest, gnu, Release, gnu, AMD64]
- [windows, windows-latest, clang-cl, Debug, clang, AMD64]
- [windows, windows-latest, clang-cl, Release, clang, AMD64]
- [linux, ubuntu-latest, gnu, Debug, gnu, x86_64]
- [linux, ubuntu-latest, gnu, Release, gnu, x86_64]
- [linux, ubuntu-latest, clang, Debug, clang, x86_64]
- [linux, ubuntu-latest, clang, Release, clang, x86_64]
env:
OPERATING_SYSTEM: ${{ matrix.platform[0] }}
DISTRIBUTION: ${{ matrix.platform[1] }}
COMPILER: ${{ matrix.platform[2] }}
BUILD_TYPE: ${{ matrix.platform[3] }}
COMPILER_ID: ${{ matrix.platform[4] }}
ARCH: ${{ matrix.platform[5]}}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Clang
if: env.COMPILER == 'clang'
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- name: Install CMake
uses: lukka/get-cmake@latest
- name: Configure
shell: bash
run: |
if [ "${{ env.COMPILER }}" == "msvc" ]; then
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G "Visual Studio 17 2022" -DWARNINGS_AS_ERRORS=ON
elif [ "${{ env.COMPILER }}" == "clang-cl" ]; then
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G "Visual Studio 17 2022" -T ClangCL #TODO: -DWARNINGS_AS_ERRORS=ON
elif [ "${{ env.COMPILER }}" == "clang" ]; then
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DCMAKE_CXX_COMPILER=clang++ -DWARNINGS_AS_ERRORS=ON
elif [ "${{ env.COMPILER }}" == "gnu" ]; then
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DCMAKE_CXX_COMPILER=g++ -DWARNINGS_AS_ERRORS=ON
fi
- name: Build
run: cmake --build out/build --parallel --config ${{ env.BUILD_TYPE }}
- name: Inspect build outputs
if: env.OPERATING_SYSTEM == 'linux'
run: |
ls -lh out/build/bin/*
(cd out/build/bin/* && for f in *; do echo $f; objdump -p $f | grep -P 'RUNPATH|RPATH' || true; done)
- name: Unit Tests
run: ctest --test-dir out/build --build-config ${{ env.BUILD_TYPE }} --output-on-failure
- name: Regression Tests
shell: bash
run: |
echo "Starting regression tests for $OPERATING_SYSTEM $BUILD_TYPE"
bash regression/run_tests.sh ./out/build/bin/$OPERATING_SYSTEM-$ARCH-$COMPILER_ID-$BUILD_TYPE/converter_components
echo "Regression tests for $OPERATING_SYSTEM $BUILD_TYPE done!"
- name: Upload Build Artifacts
uses: actions/[email protected]
with:
name: ${{ env.OPERATING_SYSTEM }}-${{ env.ARCH }}-${{ env.COMPILER }}-${{ env.BUILD_TYPE }}-bin
path: out/build/bin/
- name: Upload Regression Artifacts on Failure
if: failure()
uses: actions/[email protected]
with:
name: ${{ env.OPERATING_SYSTEM }}-${{ env.ARCH }}-${{ env.COMPILER }}-${{ env.BUILD_TYPE }}-regression
path: regression/
# =========================================================
# Clang Format Job
# =========================================================
clang-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check code formatting
run: find include src examples \( -name '*.cpp' -o -name '*.hpp' \) -exec clang-format -Werror --style=file -n {} + || (echo "Clang-format failed! See the README if you don't know how to fix this." && exit 1)
# =========================================================
# Editor Config Job
# =========================================================
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install editorconfig-checker
uses: editorconfig-checker/action-editorconfig-checker@main
- name: Check CMakeLists.txt formatting
run: find . \( -name 'CMakeLists.txt' \) -exec editorconfig-checker {} \+ || { echo "EditorConfig check failed! See the README if you don't know how to fix this."; exit 1; }
- name: Check C++ formatting
run: find include src examples \( -name '*.cpp' -o -name '*.hpp' \) -exec editorconfig-checker {} \+ || { echo "EditorConfig check failed! See the README if you don't know how to fix this."; exit 1; }
# =========================================================
# Clang Tidy Job
# =========================================================
clang-tidy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "17.0"
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- name: Install CMake
uses: lukka/get-cmake@latest
- name: Static code analysis
run: |
cmake -S . -B out/build -DCMAKE_CXX_CLANG_TIDY=clang-tidy -DCMAKE_BUILD_TYPE=Debug -G Ninja -DCMAKE_CC=clang -DCMAKE_CXX=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_TARGET=x86_64-pc-linux-gnu -DCMAKE_C_COMPILER_TARGET=x86_64-pc-linux-gnu -DWARNINGS_AS_ERRORS=ON
cmake --build out/build --parallel --config Debug
# =========================================================
# Code Coverage Job
# =========================================================
code-coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
- name: Install CMake
uses: lukka/get-cmake@latest
- name: Install GNU Coverage
run: |
sudo apt-get update
sudo apt-get install -y gcovr
- name: Configure
run: cmake -S . -B out/build -DCMAKE_BUILD_TYPE=Debug -G Ninja -DCOVERAGE=ON -DWARNINGS_AS_ERRORS=ON
- name: Build
run: cmake --build out/build --parallel --config debug
- name: Run Tests
run: cd out/build && ctest && cd ..
- name: Generate HTML code coverage reports
run: |
mkdir out/build/code-coverage
gcovr -r ./src/ ./out/build/ --exclude='.*/test/.*' --exclude='.*/version.h' --html --html-details -o ./out/build/code-coverage/index.html
- name: Coverage visualization in pipeline summary
run: gcovr -r ./src/ ./out/build/ --exclude='.*/test/.*' --exclude='.*/version.h' --exclude-unreachable-branches --print-summary -o ./out/build/coverage.xml
- name: Upload Artifacts
uses: actions/[email protected]
with:
name: code-coverage
path: |
out/build/code-coverage
out/build/coverage.xml
# =========================================================
# Documentation Job
# =========================================================
documentation:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y doxygen=1.9.1-2ubuntu2
pip3 install 'exhale==0.3.7'
pip3 install 'sphinx==7.3.7'
pip3 install 'sphinx_rtd_theme==2.0.0'
pip3 install 'json2html==1.3.0'
- name: Generate documentation for EDIE
run: |
sphinx-build docs docs/build
python3 scripts/database_to_html.py database/messages_public.json
- name: Archive documentation artifacts
uses: actions/[email protected]
with:
name: documentation
path: |
docs/build
database/messages_public.html