Skip to content

Commit bd17f0f

Browse files
committed
brought more files in line with exemplar
1 parent 1884811 commit bd17f0f

File tree

13 files changed

+526
-96
lines changed

13 files changed

+526
-96
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
name: 'CMake Build Test'
4+
description: ''
5+
inputs:
6+
cpp_version:
7+
required: true
8+
toolchain_file:
9+
required: true
10+
cmake_extra_args:
11+
description: 'extra cmake arguments'
12+
Default: ''
13+
disable_test:
14+
Default: false
15+
runs:
16+
using: 'composite'
17+
steps:
18+
- name: Setup Macos
19+
if: startsWith(matrix.platform.os, 'macos')
20+
shell: bash
21+
run: sudo chmod -R 777 /opt/
22+
- name: Print installed software
23+
shell: bash
24+
run: |
25+
echo "Build system:"
26+
cmake --version
27+
ninja --version
28+
- name: Configure CMake
29+
shell: bash
30+
run: |
31+
cmake \
32+
-B build \
33+
-S . \
34+
-DCMAKE_CXX_STANDARD=${{ inputs.cpp_version }} \
35+
-DCMAKE_TOOLCHAIN_FILE="${{ inputs.toolchain_file }}" \
36+
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES="./cmake/use-fetch-content.cmake" \
37+
${{ matrix.cmake_args.args }}
38+
env:
39+
CMAKE_GENERATOR: "Ninja Multi-Config"
40+
- name: Build Release
41+
shell: bash
42+
run: |
43+
cmake --build build --config Release --parallel --verbose
44+
cmake --build build --config Release --target all_verify_interface_header_sets
45+
cmake --install build --config Release --prefix /opt/beman.package
46+
ls -R /opt/beman.package
47+
- name: Test Release
48+
if: ${{ !inputs.disable_test }}
49+
shell: bash
50+
run: ctest --test-dir build --build-config Release
51+
- name: Build Debug
52+
shell: bash
53+
run: |
54+
cmake --build build --config Debug --parallel --verbose
55+
cmake --build build --config Debug --target all_verify_interface_header_sets
56+
cmake --install build --config Debug --prefix /opt/beman.package
57+
ls -R /opt/beman.package
58+
- name: Test Debug
59+
if: ${{ !inputs.disable_test }}
60+
shell: bash
61+
run: ctest --test-dir build --build-config Debug

.github/workflows/ci_tests.yml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
name: Continuous Integration Tests
4+
5+
on:
6+
push:
7+
pull_request:
8+
workflow_dispatch:
9+
schedule:
10+
- cron: '30 15 * * *'
11+
12+
jobs:
13+
preset-test:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
presets:
18+
- preset: "gcc-debug"
19+
platform: "ubuntu-latest"
20+
- preset: "gcc-release"
21+
platform: "ubuntu-latest"
22+
- preset: "llvm-debug"
23+
platform: "ubuntu-latest"
24+
- preset: "llvm-release"
25+
platform: "ubuntu-latest"
26+
- preset: "appleclang-debug"
27+
platform: "macos-latest"
28+
- preset: "appleclang-release"
29+
platform: "macos-latest"
30+
- preset: "msvc-debug"
31+
platform: "windows-latest"
32+
- preset: "msvc-release"
33+
platform: "windows-latest"
34+
name: "Preset: ${{ matrix.presets.preset }} on ${{ matrix.presets.platform }}"
35+
runs-on: ${{ matrix.presets.platform }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Setup build environment
39+
uses: lukka/get-cmake@latest
40+
with:
41+
cmakeVersion: "~3.25.0"
42+
ninjaVersion: "^1.11.1"
43+
- name: Setup MSVC
44+
if: startsWith(matrix.presets.platform, 'windows')
45+
uses: TheMrMilchmann/setup-msvc-dev@v3
46+
with:
47+
arch: x64
48+
- name: Run preset
49+
run: cmake --workflow --preset ${{ matrix.presets.preset }}
50+
51+
gtest-test:
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
platform:
56+
- description: "Ubuntu GNU"
57+
os: ubuntu-latest
58+
toolchain: "cmake/gnu-toolchain.cmake"
59+
- description: "Ubuntu LLVM"
60+
os: ubuntu-latest
61+
toolchain: "cmake/llvm-toolchain.cmake"
62+
- description: "Windows MSVC"
63+
os: windows-latest
64+
toolchain: "cmake/msvc-toolchain.cmake"
65+
- description: "Macos Appleclang"
66+
os: macos-latest
67+
toolchain: "cmake/appleclang-toolchain.cmake"
68+
cpp_version: [20, 23, 26]
69+
cmake_args:
70+
- description: "Default"
71+
- description: "TSan"
72+
args: "-DBEMAN_BUILDSYS_SANITIZER=TSan"
73+
- description: "MaxSan"
74+
args: "-DBEMAN_BUILDSYS_SANITIZER=MaxSan"
75+
include:
76+
- platform:
77+
description: "Ubuntu GCC"
78+
os: ubuntu-latest
79+
toolchain: "cmake/gnu-toolchain.cmake"
80+
cpp_version: 20
81+
cmake_args:
82+
description: "Werror"
83+
args: "-DCMAKE_CXX_FLAGS='-Werror=all -Werror=extra'"
84+
- platform:
85+
description: "Ubuntu GCC"
86+
os: ubuntu-latest
87+
toolchain: "cmake/gnu-toolchain.cmake"
88+
cpp_version: 20
89+
cmake_args:
90+
description: "Dynamic"
91+
args: "-DBUILD_SHARED_LIBS=on"
92+
exclude:
93+
# MSVC does not support thread sanitizer
94+
- platform:
95+
description: "Windows MSVC"
96+
cmake_args:
97+
description: "TSan"
98+
99+
name: "Unit:
100+
${{ matrix.platform.description }}
101+
${{ matrix.cpp_version }}
102+
${{ matrix.cmake_args.description }}"
103+
runs-on: ${{ matrix.platform.os }}
104+
steps:
105+
- uses: actions/checkout@v4
106+
- name: Install Ninja
107+
uses: lukka/get-cmake@latest
108+
with:
109+
cmakeVersion: "~3.25.0"
110+
ninjaVersion: "^1.11.1"
111+
- name: Setup MSVC
112+
if: startsWith(matrix.platform.os, 'windows')
113+
uses: TheMrMilchmann/setup-msvc-dev@v3
114+
with:
115+
arch: x64
116+
- name: Build and Test
117+
uses: ./.github/actions/cmake-build-test
118+
with:
119+
cpp_version: ${{ matrix.cpp_version }}
120+
toolchain_file: ${{ matrix.platform.toolchain }}
121+
cmake_extra_args: ${{ matrix.cmake_args.args }}
122+
123+
configuration-test:
124+
runs-on: ubuntu-latest
125+
strategy:
126+
fail-fast: false
127+
matrix:
128+
args:
129+
- name: "Disable build testing"
130+
arg: "-DBEMAN_EXECUTION_BUILD_TESTS=OFF"
131+
- name: "Disable example building"
132+
arg: "-DBEMAN_EXECUTION_BUILD_EXAMPLES=OFF"
133+
- name: "Disable config-file package creation"
134+
arg: "-DBEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE=OFF"
135+
name: "CMake: ${{ matrix.args.name }}"
136+
steps:
137+
- uses: actions/checkout@v4
138+
- name: Setup build environment
139+
uses: lukka/get-cmake@latest
140+
with:
141+
cmakeVersion: "~3.25.0"
142+
ninjaVersion: "^1.11.1"
143+
- name: Build and Test
144+
uses: ./.github/actions/cmake-build-test
145+
with:
146+
cpp_version: 20
147+
toolchain_file: "cmake/gnu-toolchain.cmake"
148+
cmake_extra_args: ${{ matrix.args.arg }}
149+
disable_test: true
150+
151+
compiler-test:
152+
runs-on: ubuntu-24.04
153+
strategy:
154+
fail-fast: false
155+
matrix:
156+
compilers:
157+
- class: GNU
158+
version: 14
159+
toolchain: "cmake/gnu-toolchain.cmake"
160+
- class: GNU
161+
version: 13
162+
toolchain: "cmake/gnu-toolchain.cmake"
163+
- class: GNU
164+
version: 12
165+
toolchain: "cmake/gnu-toolchain.cmake"
166+
- class: LLVM
167+
version: 20
168+
toolchain: "cmake/llvm-toolchain.cmake"
169+
- class: LLVM
170+
version: 19
171+
toolchain: "cmake/llvm-toolchain.cmake"
172+
- class: LLVM
173+
version: 18
174+
toolchain: "cmake/llvm-toolchain.cmake"
175+
- class: LLVM
176+
version: 17
177+
toolchain: "cmake/llvm-toolchain.cmake"
178+
name: "Compiler: ${{ matrix.compilers.class }} ${{ matrix.compilers.version }}"
179+
steps:
180+
- uses: actions/checkout@v4
181+
- name: Setup build environment
182+
uses: lukka/get-cmake@latest
183+
with:
184+
cmakeVersion: "~3.25.0"
185+
ninjaVersion: "^1.11.1"
186+
- name: Install Compiler
187+
id: install-compiler
188+
run: |
189+
sudo add-apt-repository universe
190+
sudo apt-get update
191+
192+
if [ "${{ matrix.compilers.class }}" = "GNU" ]; then
193+
CC=gcc-${{ matrix.compilers.version }}
194+
CXX=g++-${{ matrix.compilers.version }}
195+
196+
sudo apt-get install -y $CC
197+
sudo apt-get install -y $CXX
198+
199+
$CC --version
200+
$CXX --version
201+
else
202+
wget https://apt.llvm.org/llvm.sh
203+
chmod +x llvm.sh
204+
sudo bash llvm.sh ${{ matrix.compilers.version }}
205+
206+
CC=clang-${{ matrix.compilers.version }}
207+
CXX=clang++-${{ matrix.compilers.version }}
208+
209+
$CC --version
210+
$CXX --version
211+
fi
212+
213+
echo "CC=$CC" >> "$GITHUB_OUTPUT"
214+
echo "CXX=$CXX" >> "$GITHUB_OUTPUT"
215+
- name: Build and Test
216+
uses: ./.github/actions/cmake-build-test
217+
with:
218+
cpp_version: 20
219+
toolchain_file: ${{ matrix.compilers.toolchain }}
220+
221+
create-issue-when-fault:
222+
runs-on: ubuntu-latest
223+
needs: [preset-test, gtest-test, configuration-test, compiler-test]
224+
if: failure() && github.event_name == 'schedule'
225+
steps:
226+
# See https://github.com/cli/cli/issues/5075
227+
- uses: actions/checkout@v4
228+
- name: Create issue
229+
run: |
230+
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')
231+
232+
body="**Build-and-Test Failure Report**
233+
- **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z')
234+
- **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
235+
- **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
236+
237+
The scheduled build-and-test triggered by cron has failed.
238+
Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error."
239+
240+
if [[ $issue_num -eq -1 ]]; then
241+
gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body"
242+
else
243+
gh issue comment --repo ${{ github.repository }} $issue_num --body "$body"
244+
fi
245+
env:
246+
GH_TOKEN: ${{ github.token }}

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ option(
2828
${PROJECT_IS_TOP_LEVEL}
2929
)
3030

31-
set(TARGET_NAME execution)
32-
set(TARGET_NAMESPACE beman)
33-
set(TARGET_PREFIX ${TARGET_NAMESPACE}.${TARGET_NAME})
34-
set(TARGET_LIBRARY ${PROJECT_NAME})
35-
set(TARGET_ALIAS ${TARGET_NAMESPACE}::${TARGET_NAME})
36-
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
37-
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)
38-
3931
add_subdirectory(src/beman/execution)
4032

4133
if(BEMAN_EXECUTION_BUILD_TESTS)

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ SYSTEM = $(shell uname -s)
3838
BUILD = $(BUILDROOT)/$(SYSTEM)/$(SANITIZER)
3939
EXAMPLE = beman.execution.examples.stop_token
4040
CMAKE_CXX_COMPILER=$(COMPILER)
41+
INSTALL_PREFIX = /opt/local
4142

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

88-
# NOTE: without install! CK
8988
test: build
90-
ctest --test-dir $(BUILD) --rerun-failed --output-on-failure
89+
ctest --test-dir $(BUILD) --output-on-failure
9190

9291
install: test
93-
cmake --install $(BUILD) --prefix /opt/local
92+
cmake --install $(BUILD) --prefix $(INSTALL_PREFIX)
9493

9594
release:
9695
cmake --workflow --preset $@ --fresh

cmake/appleclang-toolchain.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
# This toolchain file is not meant to be used directly,
4+
# but to be invoked by CMake preset and GitHub CI.
5+
#
6+
# This toolchain file configures for apple clang family of compiler.
7+
# Note this is different from LLVM toolchain.
8+
#
9+
# BEMAN_BUILDSYS_SANITIZER:
10+
# This optional CMake parameter is not meant for public use and is subject to
11+
# change.
12+
# Possible values:
13+
# - MaxSan: configures clang and clang++ to use all available non-conflicting
14+
# sanitizers. Note that apple clang does not support leak sanitizer.
15+
# - TSan: configures clang and clang++ to enable the use of thread sanitizer.
16+
17+
include_guard(GLOBAL)
18+
19+
set(CMAKE_C_COMPILER clang)
20+
set(CMAKE_CXX_COMPILER clang++)
21+
22+
if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan")
23+
set(SANITIZER_FLAGS
24+
"-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined"
25+
)
26+
elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan")
27+
set(SANITIZER_FLAGS "-fsanitize=thread")
28+
endif()
29+
30+
set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}")
31+
set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}")
32+
33+
set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}")
34+
35+
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}")
36+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}")
37+
38+
set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")
39+
set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}")

0 commit comments

Comments
 (0)