Skip to content

Commit 6be9147

Browse files
feat: Add CMake workflow for building and testing with coverage and memory checks
1 parent 61e11ca commit 6be9147

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed

.github/workflows/cmake.yml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
name: CMake
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ubuntu-address-undefined-coverage:
7+
runs-on: ubuntu-latest
8+
9+
services:
10+
mongo:
11+
image: mongo
12+
ports:
13+
- 27017:27017
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y cmake lcov
24+
wget -O clips_core_source_642.zip https://sourceforge.net/projects/clipsrules/files/CLIPS/6.4.2/clips_core_source_642.zip/download
25+
unzip clips_core_source_642.zip
26+
curl -OL https://github.com/mongodb/mongo-cxx-driver/releases/download/r4.0.0/mongo-cxx-driver-r4.0.0.tar.gz
27+
tar -xzf mongo-cxx-driver-r4.0.0.tar.gz
28+
29+
- name: Compile CLIPS
30+
working-directory: clips_core_source_642/core
31+
run: |
32+
make release_cpp
33+
sudo mkdir /usr/local/include/clips
34+
sudo cp *.h /usr/local/include/clips/
35+
sudo cp libclips.a /usr/local/lib/
36+
37+
- name: Compile Mongo C++ driver
38+
working-directory: mongo-cxx-driver-r4.0.0/build
39+
run: |
40+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF
41+
cmake --build .
42+
sudo cmake --build . --target install
43+
44+
- name: Update library cache
45+
run: |
46+
sudo ldconfig
47+
48+
- name: Configure CMake
49+
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_UBSAN=ON -DENABLE_COV=ON
50+
51+
- name: Build
52+
run: cmake --build build --config Debug
53+
54+
- name: Test with address sanitizer, undefined behavior sanitizer and coverage
55+
working-directory: build
56+
run: ctest -C Debug --rerun-failed --output-on-failure -T Test -T Coverage
57+
58+
- name: Make coverage report
59+
run: |
60+
lcov --capture --directory build --output-file coverage.info
61+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
62+
lcov --list coverage.info
63+
64+
- name: Upload coverage reports to Codecov
65+
uses: codecov/[email protected]
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
69+
ubuntu-memcheck:
70+
runs-on: ubuntu-latest
71+
72+
services:
73+
mongo:
74+
image: mongo
75+
ports:
76+
- 27017:27017
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
with:
81+
submodules: recursive
82+
83+
- name: Install dependencies
84+
run: |
85+
sudo apt-get update
86+
sudo apt-get install -y cmake valgrind
87+
wget -O clips_core_source_642.zip https://sourceforge.net/projects/clipsrules/files/CLIPS/6.4.2/clips_core_source_642.zip/download
88+
unzip clips_core_source_642.zip
89+
90+
- name: Compile CLIPS
91+
working-directory: clips_core_source_642/core
92+
run: |
93+
make release_cpp
94+
sudo mkdir /usr/local/include/clips
95+
sudo cp *.h /usr/local/include/clips/
96+
sudo cp libclips.a /usr/local/lib/
97+
98+
- name: Update library cache
99+
run: |
100+
sudo ldconfig
101+
102+
- name: Configure CMake
103+
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug
104+
105+
- name: Build
106+
run: cmake --build build --config Debug
107+
108+
- name: Test with memory checker
109+
working-directory: build
110+
run: ctest -C Debug --rerun-failed --output-on-failure -T Test -T MemCheck
111+
112+
ubuntu-release:
113+
runs-on: ubuntu-latest
114+
115+
services:
116+
mongo:
117+
image: mongo
118+
ports:
119+
- 27017:27017
120+
121+
steps:
122+
- uses: actions/checkout@v4
123+
with:
124+
submodules: recursive
125+
126+
- name: Install dependencies
127+
run: |
128+
sudo apt-get update
129+
sudo apt-get install -y cmake
130+
wget -O clips_core_source_642.zip https://sourceforge.net/projects/clipsrules/files/CLIPS/6.4.2/clips_core_source_642.zip/download
131+
unzip clips_core_source_642.zip
132+
curl -OL https://github.com/mongodb/mongo-cxx-driver/releases/download/r4.0.0/mongo-cxx-driver-r4.0.0.tar.gz
133+
tar -xzf mongo-cxx-driver-r4.0.0.tar.gz
134+
135+
- name: Compile CLIPS
136+
working-directory: clips_core_source_642/core
137+
run: |
138+
make release_cpp
139+
sudo mkdir /usr/local/include/clips
140+
sudo cp *.h /usr/local/include/clips/
141+
sudo cp libclips.a /usr/local/lib/
142+
143+
- name: Compile Mongo C++ driver
144+
working-directory: mongo-cxx-driver-r4.0.0/build
145+
run: |
146+
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF
147+
cmake --build .
148+
sudo cmake --build . --target install
149+
150+
- name: Update library cache
151+
run: |
152+
sudo ldconfig
153+
154+
- name: Configure CMake
155+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
156+
157+
- name: Build
158+
run: cmake --build build --config Release
159+
160+
- name: Test
161+
working-directory: build
162+
run: ctest -C Release --rerun-failed --output-on-failure -T Test

0 commit comments

Comments
 (0)