Skip to content

Commit

Permalink
Merge branch 'main' into parallel-build
Browse files Browse the repository at this point in the history
  • Loading branch information
wusatosi authored Jan 16, 2025
2 parents b0f025f + e6e880b commit a76cc6d
Show file tree
Hide file tree
Showing 7 changed files with 417 additions and 58 deletions.
161 changes: 110 additions & 51 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,82 @@ on:

jobs:
preset-test:
runs-on: ubuntu-latest
strategy:
matrix:
preset: ["gcc-debug", "gcc-release"]
name: "Preset: ${{ matrix.preset }}"
presets:
- preset: "gcc-debug"
platform: "ubuntu-latest"
- preset: "gcc-release"
platform: "ubuntu-latest"
- preset: "appleclang-debug"
platform: "macos-latest"
- preset: "appleclang-release"
platform: "macos-latest"
- preset: "msvc-debug"
platform: "windows-latest"
- preset: "msvc-release"
platform: "windows-latest"
name: "Preset: ${{ matrix.presets.preset }} on ${{ matrix.presets.platform }}"
runs-on: ${{ matrix.presets.platform }}
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Setup MSVC
if: startsWith(matrix.presets.platform, 'windows')
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64
- name: Run preset
run: cmake --workflow --preset ${{ matrix.preset }}
run: cmake --workflow --preset ${{ matrix.presets.preset }}

gtest-test:
strategy:
fail-fast: false
matrix:
platform:
- description: "Ubuntu GCC"
cpp: g++
c: gcc
- description: "Ubuntu GNU"
os: ubuntu-latest
- description: "Ubuntu Clang"
cpp: clang++
c: clang
toolchain: "cmake/gnu-toolchain.cmake"
- description: "Ubuntu LLVM"
os: ubuntu-latest
toolchain: "cmake/llvm-toolchain.cmake"
- description: "Windows MSVC"
os: windows-latest
toolchain: "cmake/msvc-toolchain.cmake"
cpp_version: [17, 20, 23, 26]
cmake_args:
- description: "Default"
args: ""
- description: "TSan"
args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread"
- description: "ASan"
args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'"
args: "-DBEMAN_BUILDSYS_SANITIZER=TSan"
- description: "MaxSan"
args: "-DBEMAN_BUILDSYS_SANITIZER=MaxSan"
include:
- platform:
description: "Ubuntu GCC"
cpp: g++
c: 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"
cpp: g++
c: gcc
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 17
cmake_args:
description: "Dynamic"
args: "-DBUILD_SHARED_LIBS=on"
exclude:
# MSVC does not support thread sanitizer
- 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'"

description: "TSan"

name: "Unit: ${{ matrix.platform.description }} ${{ matrix.cpp_version }} ${{ matrix.cmake_args.description }}"
runs-on: ${{ matrix.platform.os }}
Expand All @@ -106,26 +106,13 @@ jobs:
- name: Print installed softwares
shell: bash
run: |
echo "Compiler:"
# cl does not have a --version option
if [ "${{ matrix.platform.cpp }}" != "cl" ]; then
${{ matrix.platform.cpp }} --version
${{ matrix.platform.c }} --version
else
${{ matrix.platform.cpp }}
${{ matrix.platform.c }}
fi
echo "Build system:"
cmake --version
ninja --version
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} ${{ matrix.cmake_args.args }}
cmake -B build -S . -DCMAKE_CXX_STANDARD=${{ matrix.cpp_version }} -DCMAKE_TOOLCHAIN_FILE="${{ matrix.platform.toolchain }}" ${{ matrix.cmake_args.args }}
env:
CC: ${{ matrix.platform.c }}
CXX: ${{ matrix.platform.cpp }}
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Release
run: |
Expand Down Expand Up @@ -187,9 +174,81 @@ jobs:
cmake --install build --config Debug --prefix /opt/beman.exemplar
ls -R /opt/beman.exemplar
compiler-test:
runs-on: ubuntu-24.04
strategy:
matrix:
compilers:
- class: GNU
version: 14
- class: GNU
version: 13
- class: GNU
version: 12
- class: LLVM
version: 20
- class: LLVM
version: 19
- class: LLVM
version: 18
- class: LLVM
version: 17
name: "Compiler: ${{ matrix.compilers.class }} ${{ matrix.compilers.version }}"
steps:
- uses: actions/checkout@v4
- name: Setup build environment
uses: lukka/get-cmake@latest
with:
cmakeVersion: "~3.25.0"
ninjaVersion: "^1.11.1"
- name: Install Compiler
id: install-compiler
run: |
if [ "${{ matrix.compilers.class }}" = "GNU" ]; then
CC=gcc-${{ matrix.compilers.version }}
CXX=g++-${{ matrix.compilers.version }}
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y $CC
sudo apt-get install -y $CXX
$CC --version
$CXX --version
else
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo bash llvm.sh ${{ matrix.compilers.version }}
CC=clang-${{ matrix.compilers.version }}
CXX=clang++-${{ matrix.compilers.version }}
$CC --version
$CXX --version
fi
echo "CC=$CC" >> "$GITHUB_OUTPUT"
echo "CXX=$CXX" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: |
cmake -B build -S . -DCMAKE_CXX_STANDARD=20
env:
CC: ${{ steps.install-compiler.outputs.CC }}
CXX: ${{ steps.install-compiler.outputs.CXX }}
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Debug
run: |
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
find /opt/beman.exemplar -type f
- name: Test Debug
run: ctest --test-dir build --build-config Debug


create-issue-when-fault:
runs-on: ubuntu-latest
needs: [preset-test, gtest-test, configuration-test]
needs: [preset-test, gtest-test, configuration-test, compiler-test]
if: failure() && github.event_name == 'schedule'
steps:
# See https://github.com/cli/cli/issues/5075
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ project(
LANGUAGES CXX
)

enable_testing()

# [CMAKE.SKIP_TESTS]
option(
BEMAN_EXEMPLAR_BUILD_TESTS
Expand All @@ -27,8 +29,6 @@ include(FetchContent)
include(GNUInstallDirs)

if(BEMAN_EXEMPLAR_BUILD_TESTS)
enable_testing()

# Fetch GoogleTest
FetchContent_Declare(
googletest
Expand Down
Loading

0 comments on commit a76cc6d

Please sign in to comment.