Skip to content

Commit 112bcb2

Browse files
committed
Add CI
1 parent 30a2304 commit 112bcb2

1 file changed

Lines changed: 210 additions & 0 deletions

File tree

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
name: Threadpool Strict CI
2+
3+
on:
4+
push:
5+
branches: [main, master, dev]
6+
paths:
7+
- ".github/workflows/threadpool-strict-ci.yml"
8+
- "CMakeLists.txt"
9+
- "CMakePresets.json"
10+
- "cmake/**"
11+
- "include/**"
12+
- "src/**"
13+
- "tests/**"
14+
- "examples/**"
15+
- "benchmarks/**"
16+
- "docs/**"
17+
- "README.md"
18+
- "CHANGELOG.md"
19+
- "LICENSE"
20+
- "vix.json"
21+
pull_request:
22+
branches: [main, master, dev]
23+
paths:
24+
- ".github/workflows/threadpool-strict-ci.yml"
25+
- "CMakeLists.txt"
26+
- "CMakePresets.json"
27+
- "cmake/**"
28+
- "include/**"
29+
- "src/**"
30+
- "tests/**"
31+
- "examples/**"
32+
- "benchmarks/**"
33+
- "docs/**"
34+
- "README.md"
35+
- "CHANGELOG.md"
36+
- "LICENSE"
37+
- "vix.json"
38+
workflow_dispatch:
39+
40+
permissions:
41+
contents: read
42+
43+
env:
44+
DEPS: >
45+
build-essential
46+
cmake
47+
ninja-build
48+
clang
49+
llvm
50+
lld
51+
g++
52+
cppcheck
53+
clang-tidy
54+
valgrind
55+
pkg-config
56+
git
57+
libgtest-dev
58+
BUILD_JOBS: 2
59+
60+
jobs:
61+
build-test:
62+
name: Build and Test (${{ matrix.compiler }}, examples=${{ matrix.examples }}, benchmarks=${{ matrix.benchmarks }})
63+
runs-on: ubuntu-latest
64+
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
compiler: [clang, gcc]
69+
examples: [ON, OFF]
70+
benchmarks: [OFF]
71+
include:
72+
- compiler: clang
73+
examples: ON
74+
benchmarks: ON
75+
76+
steps:
77+
- name: Checkout threadpool repository
78+
uses: actions/checkout@v4
79+
with:
80+
fetch-depth: 0
81+
82+
- name: Install dependencies
83+
run: |
84+
sudo apt-get update -y
85+
sudo apt-get install -y $DEPS
86+
87+
- name: Select compiler
88+
run: |
89+
if [ "${{ matrix.compiler }}" = "clang" ]; then
90+
echo "CC=clang" >> "$GITHUB_ENV"
91+
echo "CXX=clang++" >> "$GITHUB_ENV"
92+
else
93+
echo "CC=gcc" >> "$GITHUB_ENV"
94+
echo "CXX=g++" >> "$GITHUB_ENV"
95+
fi
96+
97+
- name: Configure
98+
run: |
99+
cmake -G Ninja -S . -B build \
100+
-DCMAKE_BUILD_TYPE=Debug \
101+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
102+
-DVIX_ENABLE_SANITIZERS=OFF \
103+
-DVIX_THREADPOOL_BUILD_TESTS=ON \
104+
-DVIX_THREADPOOL_BUILD_EXAMPLES=${{ matrix.examples }} \
105+
-DVIX_THREADPOOL_BUILD_BENCHMARKS=${{ matrix.benchmarks }}
106+
107+
- name: Build
108+
run: |
109+
cmake --build build -j"${BUILD_JOBS}"
110+
111+
- name: Run tests
112+
run: |
113+
ctest --test-dir build --output-on-failure --timeout 120
114+
115+
- name: Print artifacts
116+
run: |
117+
find build -maxdepth 5 -type f | sort
118+
119+
sanitized:
120+
name: Sanitized Tests
121+
runs-on: ubuntu-latest
122+
123+
steps:
124+
- name: Checkout threadpool repository
125+
uses: actions/checkout@v4
126+
with:
127+
fetch-depth: 0
128+
129+
- name: Install dependencies
130+
run: |
131+
sudo apt-get update -y
132+
sudo apt-get install -y $DEPS
133+
134+
- name: Select compiler
135+
run: |
136+
echo "CC=clang" >> "$GITHUB_ENV"
137+
echo "CXX=clang++" >> "$GITHUB_ENV"
138+
139+
- name: Configure sanitized build
140+
run: |
141+
cmake -G Ninja -S . -B build-sanitize \
142+
-DCMAKE_BUILD_TYPE=Debug \
143+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
144+
-DVIX_ENABLE_SANITIZERS=ON \
145+
-DVIX_THREADPOOL_BUILD_TESTS=ON \
146+
-DVIX_THREADPOOL_BUILD_EXAMPLES=OFF \
147+
-DVIX_THREADPOOL_BUILD_BENCHMARKS=OFF
148+
149+
- name: Build sanitized artifacts
150+
run: |
151+
cmake --build build-sanitize -j"${BUILD_JOBS}"
152+
153+
- name: Run sanitized tests
154+
run: |
155+
ctest --test-dir build-sanitize --output-on-failure --timeout 120
156+
157+
static-analysis:
158+
name: Static Analysis
159+
runs-on: ubuntu-latest
160+
161+
steps:
162+
- name: Checkout threadpool repository
163+
uses: actions/checkout@v4
164+
with:
165+
fetch-depth: 0
166+
167+
- name: Install dependencies
168+
run: |
169+
sudo apt-get update -y
170+
sudo apt-get install -y $DEPS
171+
172+
- name: Configure for analysis
173+
run: |
174+
cmake -G Ninja -S . -B build-analyze \
175+
-DCMAKE_BUILD_TYPE=Debug \
176+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
177+
-DVIX_ENABLE_SANITIZERS=OFF \
178+
-DVIX_THREADPOOL_BUILD_TESTS=ON \
179+
-DVIX_THREADPOOL_BUILD_EXAMPLES=ON \
180+
-DVIX_THREADPOOL_BUILD_BENCHMARKS=ON
181+
182+
- name: Run clang-tidy
183+
run: |
184+
set +e
185+
find src examples benchmarks tests -name '*.cpp' -print0 | xargs -0 -n1 -P2 clang-tidy -p build-analyze
186+
STATUS=$?
187+
if [ $STATUS -ne 0 ]; then
188+
echo "::warning::clang-tidy reported issues."
189+
else
190+
echo "clang-tidy completed successfully."
191+
fi
192+
exit 0
193+
194+
- name: Run cppcheck
195+
run: |
196+
set +e
197+
cppcheck \
198+
--enable=all \
199+
--std=c++20 \
200+
--inconclusive \
201+
--quiet \
202+
--suppress=missingIncludeSystem \
203+
include/ src/ examples/ benchmarks/ tests/
204+
STATUS=$?
205+
if [ $STATUS -ne 0 ]; then
206+
echo "::warning::cppcheck reported issues."
207+
else
208+
echo "cppcheck completed successfully."
209+
fi
210+
exit 0

0 commit comments

Comments
 (0)