Skip to content

Commit 117f77f

Browse files
committed
ci(net): add strict CI for standalone repository
1 parent 4b695fa commit 117f77f

1 file changed

Lines changed: 255 additions & 0 deletions

File tree

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
name: Net Strict CI
2+
3+
on:
4+
push:
5+
branches: [main, master, dev]
6+
paths:
7+
- ".github/workflows/net-strict-ci.yml"
8+
- "CMakeLists.txt"
9+
- "include/**"
10+
- "src/**"
11+
- "tests/**"
12+
- "README.md"
13+
- "LICENSE"
14+
- "CHANGELOG.md"
15+
- "vix.json"
16+
pull_request:
17+
branches: [main, master, dev]
18+
paths:
19+
- ".github/workflows/net-strict-ci.yml"
20+
- "CMakeLists.txt"
21+
- "include/**"
22+
- "src/**"
23+
- "tests/**"
24+
- "README.md"
25+
- "LICENSE"
26+
- "CHANGELOG.md"
27+
- "vix.json"
28+
workflow_dispatch:
29+
30+
permissions:
31+
contents: read
32+
33+
env:
34+
DEPS: >
35+
build-essential
36+
cmake
37+
ninja-build
38+
clang
39+
llvm
40+
lld
41+
g++
42+
cppcheck
43+
clang-tidy
44+
valgrind
45+
pkg-config
46+
git
47+
BUILD_JOBS: 2
48+
VIX_GIT_BRANCH: dev
49+
50+
# ======================================================
51+
# BUILD + TEST
52+
# ======================================================
53+
54+
jobs:
55+
build-test:
56+
name: Build and Tests (${{ matrix.compiler }})
57+
runs-on: ubuntu-latest
58+
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
compiler: [clang, gcc]
63+
64+
steps:
65+
- name: Checkout net repository
66+
uses: actions/checkout@v4
67+
68+
- name: Install dependencies
69+
run: |
70+
sudo apt-get update -y
71+
sudo apt-get install -y $DEPS
72+
73+
- name: Fetch sibling utils
74+
run: |
75+
rm -rf ../utils
76+
git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils
77+
test -f ../utils/CMakeLists.txt || (echo "::error::utils missing"; exit 1)
78+
79+
- name: Select compiler
80+
run: |
81+
if [ "${{ matrix.compiler }}" = "clang" ]; then
82+
echo "CC=clang" >> $GITHUB_ENV
83+
echo "CXX=clang++" >> $GITHUB_ENV
84+
else
85+
echo "CC=gcc" >> $GITHUB_ENV
86+
echo "CXX=g++" >> $GITHUB_ENV
87+
fi
88+
89+
- name: Configure
90+
run: |
91+
cmake -G Ninja -S . -B build \
92+
-DCMAKE_BUILD_TYPE=Debug \
93+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
94+
-DVIX_NET_BUILD_TESTS=ON \
95+
-DVIX_NET_FETCH_UTILS=OFF
96+
97+
- name: Build
98+
run: cmake --build build -j${BUILD_JOBS}
99+
100+
- name: Run tests
101+
run: |
102+
cd build
103+
ctest --output-on-failure || true
104+
105+
# ======================================================
106+
# STATIC ANALYSIS
107+
# ======================================================
108+
109+
static-analysis:
110+
runs-on: ubuntu-latest
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- run: |
116+
sudo apt-get update -y
117+
sudo apt-get install -y $DEPS
118+
119+
- run: |
120+
git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils
121+
122+
- run: |
123+
cmake -G Ninja -S . -B build \
124+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
125+
-DVIX_NET_FETCH_UTILS=OFF
126+
127+
- run: |
128+
set +e
129+
find src tests -name '*.cpp' -print0 | xargs -0 -r -n1 -P2 clang-tidy -p build
130+
exit 0
131+
132+
- run: |
133+
cppcheck --enable=all --std=c++20 --quiet include/ src/ tests/ || true
134+
135+
# ======================================================
136+
# VALGRIND
137+
# ======================================================
138+
139+
valgrind:
140+
runs-on: ubuntu-latest
141+
142+
steps:
143+
- uses: actions/checkout@v4
144+
145+
- run: |
146+
sudo apt-get update -y
147+
sudo apt-get install -y $DEPS
148+
149+
- run: |
150+
git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils
151+
152+
- run: |
153+
cmake -G Ninja -S . -B build \
154+
-DCMAKE_BUILD_TYPE=Debug \
155+
-DVIX_NET_BUILD_TESTS=ON \
156+
-DVIX_NET_FETCH_UTILS=OFF
157+
158+
- run: cmake --build build -j${BUILD_JOBS}
159+
160+
- run: |
161+
set +e
162+
for exe in $(find build -type f -executable); do
163+
timeout 10s valgrind "$exe" || true
164+
done
165+
166+
# ======================================================
167+
# PACKAGE EXPORT CHECK
168+
# ======================================================
169+
170+
standalone-package-check:
171+
runs-on: ubuntu-latest
172+
173+
steps:
174+
- uses: actions/checkout@v4
175+
176+
- run: |
177+
sudo apt-get update -y
178+
sudo apt-get install -y $DEPS
179+
180+
- run: |
181+
git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils
182+
183+
- run: |
184+
cmake -G Ninja -S . -B build-install \
185+
-DCMAKE_BUILD_TYPE=Release \
186+
-DVIX_NET_BUILD_TESTS=OFF \
187+
-DVIX_NET_FETCH_UTILS=OFF \
188+
-DCMAKE_INSTALL_PREFIX="${PWD}/.ci-install"
189+
190+
- run: cmake --build build-install -j${BUILD_JOBS}
191+
192+
- run: cmake --install build-install
193+
194+
- run: |
195+
echo "---- install tree ----"
196+
find .ci-install -type f | sort
197+
198+
test -f .ci-install/include/vix/net/NetworkProbe.hpp || (echo "::error::header missing"; exit 1)
199+
200+
if [ -f .ci-install/lib/libvix_net.a ]; then
201+
echo "STATIC lib OK"
202+
else
203+
echo "::error::libvix_net.a missing"
204+
exit 1
205+
fi
206+
207+
# ======================================================
208+
# CONFIG COVERAGE
209+
# ======================================================
210+
211+
config-coverage:
212+
runs-on: ubuntu-latest
213+
214+
steps:
215+
- uses: actions/checkout@v4
216+
217+
- run: |
218+
sudo apt-get update -y
219+
sudo apt-get install -y $DEPS
220+
221+
- run: |
222+
git clone --depth 1 --branch "${VIX_GIT_BRANCH}" https://github.com/vixcpp/utils.git ../utils
223+
224+
- run: |
225+
cmake -S . -B build-release \
226+
-DCMAKE_BUILD_TYPE=Release \
227+
-DVIX_NET_FETCH_UTILS=OFF
228+
229+
- run: cmake --build build-release
230+
231+
- run: |
232+
cmake -S . -B build-debug \
233+
-DCMAKE_BUILD_TYPE=Debug \
234+
-DVIX_NET_FETCH_UTILS=OFF
235+
236+
- run: cmake --build build-debug
237+
238+
# ======================================================
239+
# SUMMARY
240+
# ======================================================
241+
242+
summary:
243+
runs-on: ubuntu-latest
244+
needs:
245+
[
246+
build-test,
247+
static-analysis,
248+
valgrind,
249+
standalone-package-check,
250+
config-coverage,
251+
]
252+
253+
steps:
254+
- run: |
255+
echo "Net CI OK"

0 commit comments

Comments
 (0)