diff --git a/.ci/docker/rockylinux.Dockerfile b/.ci/docker/rockylinux.Dockerfile deleted file mode 100644 index 9821de2..0000000 --- a/.ci/docker/rockylinux.Dockerfile +++ /dev/null @@ -1,29 +0,0 @@ -FROM rockylinux:9 - -# Enable EPEL -RUN dnf update -y -RUN dnf install -y 'dnf-command(config-manager)' -RUN dnf config-manager --set-enabled crb -y -RUN dnf install epel-release -y - -# Install dependencies -RUN dnf install -y \ - clang \ - g++ \ - ninja-build \ - cmake -RUN dnf clean all - -# Copy code -WORKDIR /workarea -COPY ./ ./ - -ARG cc=gcc -ARG cxx=g++ -ARG cmake_args= - -ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on -RUN cmake -B build -S . "$cmake_args" && \ - cmake --build build --verbose && \ - DESTDIR=build/staging cmake --install build --prefix /opt/example --component libexample-dev && \ - find build/staging -type f diff --git a/.ci/docker/ubuntu.Dockerfile b/.ci/docker/ubuntu.Dockerfile deleted file mode 100644 index fbfe4ed..0000000 --- a/.ci/docker/ubuntu.Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# Using a non-LTS Ubuntu, just until CMake 3.23 is available on Ubuntu 24.04 -FROM ubuntu:23.10 - -# Install dependencies -RUN apt-get update -RUN apt-get install -y \ - clang \ - clang-tidy \ - g++ \ - ninja-build \ - cmake -RUN apt-get clean - -WORKDIR /workarea -COPY ./ ./ - -ARG cc=gcc -ARG cxx=g++ -ARG cmake_args= - -# Workaround Ubuntu broken ASan -RUN sysctl vm.mmap_rnd_bits=28 - -ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on -RUN cmake -B build -S . "$cmake_args" && \ - cmake --build build --verbose && \ - DESTDIR=build/staging cmake --install build --prefix /opt/example --component libexample-dev && \ - find build/staging -type f diff --git a/.github/workflows/cxx.yml b/.github/workflows/cxx.yml index 2ac2e49..d5218dd 100644 --- a/.github/workflows/cxx.yml +++ b/.github/workflows/cxx.yml @@ -1,83 +1,97 @@ -# Copyright © 2024 Bret Brown -# SPDX-License-Identifier: MIT - -name: Test +name: Test Multi-Platform on: push: branches: [ main ] - paths: - - "src/**" - - "test/**" - - "CMakeLists.txt" pull_request: branches: [ main ] - paths: - - "src/**" - - "test/**" - - "CMakeLists.txt" - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: jobs: - test: - runs-on: ubuntu-latest + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: - cfg: - - { id: ubuntu-gcc-werror, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'"} - - { id: ubuntu-gcc-aubsan, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS=-fsanitize=address -fsanitize=undefined"} - - { id: ubuntu-gcc-tsan, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_FLAGS=-fsanitize=thread"} - - { id: ubuntu-gcc-static, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: ""} - - { id: ubuntu-gcc-static-cxx98, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=on"} - - { id: ubuntu-gcc-static-cxx11, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=on"} - - { id: ubuntu-gcc-static-cxx14, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=on"} - - { id: ubuntu-gcc-static-cxx17, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=on"} - - { id: ubuntu-gcc-static-cxx20, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=on"} - - { id: ubuntu-gcc-dynamic, platform: ubuntu, cc: gcc, cpp: g++, cmake_args: "-DBUILD_SHARED_LIBS=on"} - - { id: ubuntu-clang-static, platform: ubuntu, cc: clang, cpp: clang++, cmake_args: ""} - - { id: ubuntu-clang-dynamic, platform: ubuntu, cc: clang, cpp: clang++, cmake_args: "-DBUILD_SHARED_LIBS=on"} - # Disabling Rocky until it catches up on CMake versions or a way to sideload newer version of CMake - # is identified. - # - { id: rockylinux-gcc-static, platform: rockylinux, cc: gcc, cpp: g++, cmake_args: ""} - # - { id: rockylinux-clang-static, platform: rockylinux, cc: clang, cpp: clang++, cmake_args: ""} + include: + - os: windows-latest + build_type: Release + cmake_args: "" + preset: msvc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-fsanitize=thread'" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DBUILD_SHARED_LIBS=on" + preset: gcc-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-fsanitize=address -fsanitize=undefined'" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_FLAGS='-fsanitize=thread'" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=on" + preset: clang-debug + - os: ubuntu-latest + cmake_args: "-DBUILD_SHARED_LIBS=on" + preset: clang-debug + - os: macos-latest + cmake_args: "" + preset: clang-debug steps: - - uses: actions/checkout@v2 - # GitHub runners have updated the Ubuntu Linux Kernel to use strong ASLR, - # but LLVM is not configured for this change, and thus the address - # sanitizer breaks. - # - # The next image is supposed to fix this, so if the Ubuntu image has been - # updated, this work around is no longer required. - - name: get runner image version - id: runner-image-version - run: | - echo "image-version=$(echo $ImageVersion)" >> "$GITHUB_OUTPUT" - working-directory: . - - name: modify number of bits to use for ASLR entropy - if: ${{ steps.runner-image-version.outputs.ImageVersion }} == '20240310.1.0' - run: | - sudo sysctl -a | grep vm.mmap.rnd - sudo sysctl -w vm.mmap_rnd_bits=28 - working-directory: . - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: false - load: true - tags: ${{ matrix.cfg.id }} - file: .ci/docker/${{ matrix.cfg.platform }}.Dockerfile - build-args: | - cc=${{ matrix.cfg.cc }} - cxx=${{ matrix.cfg.cpp }} - cmake_args=${{ matrix.cfg.cmake_args }} - cache-from: type=gha - cache-to: type=gha,mode=max - - name: Run tests - run: | - docker run ${{ matrix.cfg.id }} ctest --test-dir build + - uses: actions/checkout@v3 + - uses: seanmiddleditch/gha-setup-ninja@master + + - name: Setup MSVC + if: startsWith(matrix.os, 'windows') + uses: TheMrMilchmann/setup-msvc-dev@v3 + with: + arch: x64 + + - name: Configure CMake + run: cmake --preset ${{ matrix.preset }} -DBUILD_TESTING=on ${{ matrix.cmake_args }} + + - name: Build + run: cmake --build --preset ${{ matrix.preset }} + + - name: Test + run: ctest --preset ${{ matrix.preset }} diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..b76e86a --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,105 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "gcc-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "clang-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "msvc-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "gcc-debug", + "displayName": "gcc-debug", + "inherits": "gcc-base" + }, + { + "name": "clang-debug", + "displayName": "clang-debug", + "inherits": "clang-base" + }, + { + "name": "msvc-debug", + "displayName": "msvc-debug", + "inherits": "msvc-base" + } + ], + "buildPresets": [ + { + "name": "gcc-debug", + "configurePreset": "gcc-debug" + }, + { + "name": "clang-debug", + "configurePreset": "clang-debug" + }, + { + "name": "msvc-debug", + "configurePreset": "msvc-debug" + } + ], + "testPresets": [ + { + "name": "gcc-debug", + "configurePreset": "gcc-debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "clang-debug", + "configurePreset": "clang-debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "msvc-debug", + "configurePreset": "msvc-debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + } + ] +} \ No newline at end of file