Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/actions/cmake-build-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: 'CMake Build Test'
description: ''
inputs:
cpp_version:
required: true
toolchain_file:
required: true
cmake_extra_args:
description: 'extra cmake arguments'
Default: ''
disable_test:
Default: false
runs:
using: 'composite'
steps:
- name: Setup Macos
if: startsWith(matrix.platform.os, 'macos')
shell: bash
run: sudo chmod -R 777 /opt/
- name: Print installed software
shell: bash
run: |
echo "Build system:"
cmake --version
ninja --version
- name: Configure CMake
shell: bash
run: |
cmake \
-B build \
-S . \
-DCMAKE_CXX_STANDARD=${{ inputs.cpp_version }} \
-DCMAKE_TOOLCHAIN_FILE="${{ inputs.toolchain_file }}" \
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="./cmake/use-fetch-content.cmake" \
${{ matrix.cmake_args.args }}
env:
CMAKE_GENERATOR: "Ninja Multi-Config"
- name: Build Release
shell: bash
run: |
cmake --build build --config Release --parallel --verbose
cmake --build build --config Release --target all_verify_interface_header_sets
cmake --install build --config Release --prefix /opt/beman.package
ls -R /opt/beman.package
- name: Test Release
if: ${{ !inputs.disable_test }}
shell: bash
run: ctest --test-dir build --build-config Release
- name: Build Debug
shell: bash
run: |
cmake --build build --config Debug --parallel --verbose
cmake --build build --config Debug --target all_verify_interface_header_sets
cmake --install build --config Debug --prefix /opt/beman.package
ls -R /opt/beman.package
- name: Test Debug
if: ${{ !inputs.disable_test }}
shell: bash
run: ctest --test-dir build --build-config Debug
246 changes: 246 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: Continuous Integration Tests

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '30 15 * * *'

jobs:
preset-test:
strategy:
fail-fast: false
matrix:
presets:
- preset: "gcc-debug"
platform: "ubuntu-latest"
- preset: "gcc-release"
platform: "ubuntu-latest"
- preset: "llvm-debug"
platform: "ubuntu-latest"
- preset: "llvm-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.presets.preset }}

gtest-test:
strategy:
fail-fast: false
matrix:
platform:
- description: "Ubuntu GNU"
os: ubuntu-latest
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"
- description: "Macos Appleclang"
os: macos-latest
toolchain: "cmake/appleclang-toolchain.cmake"
cpp_version: [20, 23, 26]
cmake_args:
- description: "Default"
- description: "TSan"
args: "-DBEMAN_BUILDSYS_SANITIZER=TSan"
- description: "MaxSan"
args: "-DBEMAN_BUILDSYS_SANITIZER=MaxSan"
include:
- platform:
description: "Ubuntu GCC"
os: ubuntu-latest
toolchain: "cmake/gnu-toolchain.cmake"
cpp_version: 20
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: 20
cmake_args:
description: "Dynamic"
args: "-DBUILD_SHARED_LIBS=on"
exclude:
# MSVC does not support thread sanitizer
- platform:
description: "Windows MSVC"
cmake_args:
description: "TSan"

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: Build and Test
uses: ./.github/actions/cmake-build-test
with:
cpp_version: ${{ matrix.cpp_version }}
toolchain_file: ${{ matrix.platform.toolchain }}
cmake_extra_args: ${{ matrix.cmake_args.args }}

configuration-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
args:
- name: "Disable build testing"
arg: "-DBEMAN_EXECUTION_BUILD_TESTS=OFF"
- name: "Disable example building"
arg: "-DBEMAN_EXECUTION_BUILD_EXAMPLES=OFF"
- name: "Disable config-file package creation"
arg: "-DBEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE=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: Build and Test
uses: ./.github/actions/cmake-build-test
with:
cpp_version: 20
toolchain_file: "cmake/gnu-toolchain.cmake"
cmake_extra_args: ${{ matrix.args.arg }}
disable_test: true

compiler-test:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
compilers:
- class: GNU
version: 14
toolchain: "cmake/gnu-toolchain.cmake"
- class: GNU
version: 13
toolchain: "cmake/gnu-toolchain.cmake"
- class: GNU
version: 12
toolchain: "cmake/gnu-toolchain.cmake"
- class: LLVM
version: 20
toolchain: "cmake/llvm-toolchain.cmake"
- class: LLVM
version: 19
toolchain: "cmake/llvm-toolchain.cmake"
- class: LLVM
version: 18
toolchain: "cmake/llvm-toolchain.cmake"
- class: LLVM
version: 17
toolchain: "cmake/llvm-toolchain.cmake"
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: |
sudo add-apt-repository universe
sudo apt-get update

if [ "${{ matrix.compilers.class }}" = "GNU" ]; then
CC=gcc-${{ matrix.compilers.version }}
CXX=g++-${{ matrix.compilers.version }}

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: Build and Test
uses: ./.github/actions/cmake-build-test
with:
cpp_version: 20
toolchain_file: ${{ matrix.compilers.toolchain }}

create-issue-when-fault:
runs-on: ubuntu-latest
needs: [preset-test, gtest-test, configuration-test, compiler-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 }}
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ option(
${PROJECT_IS_TOP_LEVEL}
)

set(TARGET_NAME execution)
set(TARGET_NAMESPACE beman)
set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME})
set(TARGET_LIBRARY ${PROJECT_NAME})
set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME})
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)

add_subdirectory(src/beman/execution)

if(BEMAN_EXECUTION_BUILD_TESTS)
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ SYSTEM = $(shell uname -s)
BUILD = $(BUILDROOT)/$(SYSTEM)/$(SANITIZER)
EXAMPLE = beman.execution.examples.stop_token
CMAKE_CXX_COMPILER=$(COMPILER)
INSTALL_PREFIX = /opt/local

ifeq ($(SANITIZER),release)
CXX_FLAGS = -O3 -Wpedantic -Wall -Wextra -Wno-shadow -Werror
Expand Down Expand Up @@ -81,16 +82,14 @@ doc:
build:
CC=$(CXX) cmake --fresh -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \
-D CMAKE_SKIP_INSTALL_RULES=1 \
-D CMAKE_CXX_COMPILER=$(CXX) # XXX -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
cmake --build $(BUILD)

# NOTE: without install! CK
test: build
ctest --test-dir $(BUILD) --rerun-failed --output-on-failure
ctest --test-dir $(BUILD) --output-on-failure

install: test
cmake --install $(BUILD) --prefix /opt/local
cmake --install $(BUILD) --prefix $(INSTALL_PREFIX)

release:
cmake --workflow --preset $@ --fresh
Expand Down
39 changes: 39 additions & 0 deletions cmake/appleclang-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# This toolchain file is not meant to be used directly,
# but to be invoked by CMake preset and GitHub CI.
#
# This toolchain file configures for apple clang family of compiler.
# Note this is different from LLVM toolchain.
#
# BEMAN_BUILDSYS_SANITIZER:
# This optional CMake parameter is not meant for public use and is subject to
# change.
# Possible values:
# - MaxSan: configures clang and clang++ to use all available non-conflicting
# sanitizers. Note that apple clang does not support leak sanitizer.
# - TSan: configures clang and clang++ to enable the use of thread sanitizer.

include_guard(GLOBAL)

set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)

if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan")
set(SANITIZER_FLAGS
"-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined"
)
elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan")
set(SANITIZER_FLAGS "-fsanitize=thread")
endif()

set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}")

set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}")

set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}")

set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")
Loading
Loading