Skip to content

Specify sanitizer parameters in CMake #376

Specify sanitizer parameters in CMake

Specify sanitizer parameters in CMake #376

Workflow file for this run

# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Continuous Integration Tests
on:
push:
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
- cron: '30 15 * * *'
jobs:
preset-test:
runs-on: ubuntu-latest
strategy:
matrix:
preset: ["gcc-debug", "gcc-release"]
name: "Preset: ${{ matrix.preset }}"
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Run preset
run: cmake --workflow --preset ${{ matrix.preset }}
gtest-test:
strategy:
fail-fast: false
matrix:
platform:
- description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
- description: "Ubuntu Clang"
os: ubuntu-latest
toolchain: "cmake/llvm-toolchain.cmake"
cpp_version: [17, 20, 23, 26]
cmake_args:
- description: "Default"
args: ""
- description: "TSan"
args: "-DBEMAN_BUILDSYS_SANITIZER=TSan"
- description: "ASan"
args: "-DBEMAN_BUILDSYS_SANITIZER=ASan"
include:
- platform:
description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 17
cmake_args:
description: "Werror"
args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'"
- platform:
description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 17
cmake_args:
description: "Dynamic"
args: "-DBUILD_SHARED_LIBS=on"
# - platform:
# description: "Windows MSVC"
# cpp: cl
# c: cl
# os: windows-latest
# cpp_version: 17
# cmake_args:
# description: "Default"
# args: ""
# - platform:
# description: "Windows MSVC"
# cpp: cl
# c: cl
# os: windows-latest
# cpp_version: 17
# cmake_args:
# description: "ASan"
# # Debug infomation needed to avoid cl: C5072
# # https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072?view=msvc-170
# args: "-DCMAKE_CXX_FLAGS='/fsanitize=address /Zi'"
name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}"
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v4
- name: Install Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Setup MSVC
if: startsWith(matrix.platform.os, 'windows')
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Print installed softwares
shell: bash
run: |
echo "Build system:"
cmake --version
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} \
-DCMAKE_TOOLCHAIN_FILE=${{ matrix.platform.toolchain }} \
${{ matrix.cmake_args.args }}
env:
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Release
run: |
# Portable commands only
cmake --build build --config Release --verbose
cmake --build build --config Release --target all_verify_interface_header_sets
cmake --install build --config Release --prefix /opt/beman.exemplar
ls -R /opt/beman.exemplar
- name: Test Release
run: ctest --test-dir build --build-config Release
- name: Build Debug
run: |
# Portable commands only
cmake --build build --config Debug --verbose
cmake --build build --config Debug --target all_verify_interface_header_sets
cmake --install build --config Debug --prefix /opt/beman.exemplar
ls -R /opt/beman.exemplar
- name: Test Debug
run: ctest --test-dir build --build-config Debug
configuration-test:
runs-on: ubuntu-latest
strategy:
matrix:
args:
- name: "Disable build testing"
arg: "-DBEMAN_EXEMPLAR_BUILD_TESTS=OFF"
- name: "Disable example building"
arg: "-DBEMAN_EXEMPLAR_BUILD_EXAMPLES=OFF"
name: "CMake: ${{ matrix.args.name }}"
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Print installed softwares
run: |
cmake --version
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=17 ${{ matrix.args.arg }}
env:
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Release
run: |
# Portable commands only
cmake --build build --config Release --verbose
cmake --build build --config Release --target all_verify_interface_header_sets
cmake --install build --config Release --prefix /opt/beman.exemplar
ls -R /opt/beman.exemplar
- name: Build Debug
run: |
# Portable commands only
cmake --build build --config Debug --verbose
cmake --build build --config Debug --target all_verify_interface_header_sets
cmake --install build --config Debug --prefix /opt/beman.exemplar
ls -R /opt/beman.exemplar
create-issue-when-fault:
runs-on: ubuntu-latest
needs: [preset-test, gtest-test, configuration-test]
if: failure() && github.event_name == 'schedule'
steps:
# See https://github.com/cli/cli/issues/5075
- uses: actions/checkout@v4
- name: Create issue
run: |
issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end')
body="**Build-and-Test Failure Report**
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
The scheduled build-and-test triggered by cron has failed.
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
if [[ $issue_num -eq -1 ]]; then
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body"
else
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
fi
env:
GH_TOKEN: ${{ github.token }}