Skip to content

Commit dd56a1a

Browse files
committed
feat: add comprehensive C++ tests workflow
- Add GitHub Actions workflow for running C++ tests using xmake - Support multiple platforms (Linux, Windows, macOS) - Test with multiple compilers (GCC, Clang, MSVC) - Include caching for build dependencies
1 parent cadac4c commit dd56a1a

File tree

1 file changed

+282
-0
lines changed

1 file changed

+282
-0
lines changed

.github/workflows/tests.yml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'include/**'
8+
- 'test/**'
9+
- 'examples/**'
10+
- 'xmake.lua'
11+
- '.github/workflows/tests.yml'
12+
pull_request:
13+
branches: [ main ]
14+
paths:
15+
- 'include/**'
16+
- 'test/**'
17+
- 'examples/**'
18+
- 'xmake.lua'
19+
- '.github/workflows/tests.yml'
20+
21+
jobs:
22+
test-linux:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
matrix:
26+
compiler: [gcc, clang]
27+
include:
28+
- compiler: gcc
29+
cc: gcc-11
30+
cxx: g++-11
31+
- compiler: clang
32+
cc: clang-13
33+
cxx: clang++-13
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Install system dependencies
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y build-essential cmake
43+
sudo apt-get install -y gcc-11 g++-11 clang-13 clang++-13
44+
sudo apt-get install -y libeigen3-dev
45+
46+
- name: Install xmake
47+
run: |
48+
curl -fsSL https://xmake.io/shget.text | bash
49+
echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
51+
- name: Configure xmake
52+
run: |
53+
xmake config --toolchain=${{ matrix.compiler }} --cc=${{ matrix.cc }} --cxx=${{ matrix.cxx }}
54+
55+
- name: Build tests
56+
run: |
57+
xmake build -g tests
58+
xmake build -g integration_tests
59+
60+
- name: Run unit tests
61+
run: |
62+
xmake run test_state_concept
63+
xmake run test_rk4_integrator
64+
xmake run test_advanced_integrators
65+
xmake run test_dop853
66+
67+
- name: Run integration tests
68+
run: |
69+
xmake run test_sde_solvers
70+
xmake run test_sde_integration
71+
xmake run test_modernized_interface
72+
xmake run test_standard_parallelism
73+
74+
- name: Run comprehensive test suite
75+
run: |
76+
xmake test-all --verbose
77+
78+
test-windows:
79+
runs-on: windows-latest
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Setup MSVC
86+
uses: ilammy/msvc-dev-cmd@v1
87+
88+
- name: Install xmake
89+
run: |
90+
Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content
91+
92+
- name: Configure xmake
93+
run: |
94+
xmake config --toolchain=msvc --arch=x64
95+
96+
- name: Build tests
97+
run: |
98+
xmake build -g tests
99+
xmake build -g integration_tests
100+
101+
- name: Run unit tests
102+
run: |
103+
xmake run test_state_concept
104+
xmake run test_rk4_integrator
105+
xmake run test_advanced_integrators
106+
xmake run test_dop853
107+
108+
- name: Run integration tests
109+
run: |
110+
xmake run test_sde_solvers
111+
xmake run test_sde_integration
112+
xmake run test_modernized_interface
113+
xmake run test_standard_parallelism
114+
115+
- name: Run comprehensive test suite
116+
run: |
117+
xmake test-all --verbose
118+
119+
test-macos:
120+
runs-on: macos-latest
121+
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
126+
- name: Install system dependencies
127+
run: |
128+
brew install eigen
129+
130+
- name: Install xmake
131+
run: |
132+
curl -fsSL https://xmake.io/shget.text | bash
133+
echo "$HOME/.local/bin" >> $GITHUB_PATH
134+
135+
- name: Configure xmake
136+
run: |
137+
xmake config --toolchain=clang
138+
139+
- name: Build tests
140+
run: |
141+
xmake build -g tests
142+
xmake build -g integration_tests
143+
144+
- name: Run unit tests
145+
run: |
146+
xmake run test_state_concept
147+
xmake run test_rk4_integrator
148+
xmake run test_advanced_integrators
149+
xmake run test_dop853
150+
151+
- name: Run integration tests
152+
run: |
153+
xmake run test_sde_solvers
154+
xmake run test_sde_integration
155+
xmake run test_modernized_interface
156+
xmake run test_standard_parallelism
157+
158+
- name: Run comprehensive test suite
159+
run: |
160+
xmake test-all --verbose
161+
162+
test-examples:
163+
runs-on: ubuntu-latest
164+
165+
steps:
166+
- name: Checkout code
167+
uses: actions/checkout@v4
168+
169+
- name: Install system dependencies
170+
run: |
171+
sudo apt-get update
172+
sudo apt-get install -y build-essential cmake
173+
sudo apt-get install -y gcc-11 g++-11
174+
sudo apt-get install -y libeigen3-dev
175+
176+
- name: Install xmake
177+
run: |
178+
curl -fsSL https://xmake.io/shget.text | bash
179+
echo "$HOME/.local/bin" >> $GITHUB_PATH
180+
181+
- name: Configure xmake
182+
run: |
183+
xmake config --toolchain=gcc --cc=gcc-11 --cxx=g++-11
184+
185+
- name: Build examples
186+
run: |
187+
xmake build -g examples
188+
189+
- name: Run examples
190+
run: |
191+
xmake run basic_ode_example
192+
xmake run lorenz_system_example
193+
xmake run parallel_integration_example
194+
xmake run sde_example
195+
xmake run state_concept_example
196+
xmake run signal_aware_example
197+
xmake run async_integration_example
198+
xmake run modernized_interface_example
199+
xmake run standard_parallelism_example
200+
201+
performance-test:
202+
runs-on: ubuntu-latest
203+
204+
steps:
205+
- name: Checkout code
206+
uses: actions/checkout@v4
207+
208+
- name: Install system dependencies
209+
run: |
210+
sudo apt-get update
211+
sudo apt-get install -y build-essential cmake
212+
sudo apt-get install -y gcc-11 g++-11
213+
sudo apt-get install -y libeigen3-dev
214+
215+
- name: Install xmake
216+
run: |
217+
curl -fsSL https://xmake.io/shget.text | bash
218+
echo "$HOME/.local/bin" >> $GITHUB_PATH
219+
220+
- name: Configure xmake for performance
221+
run: |
222+
xmake config --toolchain=gcc --cc=gcc-11 --cxx=g++-11 --mode=release
223+
224+
- name: Build performance tests
225+
run: |
226+
xmake build -g performance_tests
227+
228+
- name: Run performance benchmarks
229+
run: |
230+
xmake run performance_benchmark
231+
232+
- name: Upload performance results
233+
uses: actions/upload-artifact@v4
234+
with:
235+
name: performance-results
236+
path: performance_results.txt
237+
retention-days: 30
238+
239+
test-coverage:
240+
runs-on: ubuntu-latest
241+
242+
steps:
243+
- name: Checkout code
244+
uses: actions/checkout@v4
245+
246+
- name: Install system dependencies
247+
run: |
248+
sudo apt-get update
249+
sudo apt-get install -y build-essential cmake
250+
sudo apt-get install -y gcc-11 g++-11
251+
sudo apt-get install -y libeigen3-dev
252+
sudo apt-get install -y lcov
253+
254+
- name: Install xmake
255+
run: |
256+
curl -fsSL https://xmake.io/shget.text | bash
257+
echo "$HOME/.local/bin" >> $GITHUB_PATH
258+
259+
- name: Configure xmake with coverage
260+
run: |
261+
xmake config --toolchain=gcc --cc=gcc-11 --cxx=g++-11 --mode=debug
262+
xmake config --enable_coverage=true
263+
264+
- name: Build and run tests with coverage
265+
run: |
266+
xmake build -g tests
267+
xmake build -g integration_tests
268+
xmake test-all --coverage
269+
270+
- name: Generate coverage report
271+
run: |
272+
lcov --capture --directory . --output-file coverage.info
273+
lcov --remove coverage.info '/usr/*' --output-file coverage.info
274+
lcov --remove coverage.info '*/test/*' --output-file coverage.info
275+
lcov --list coverage.info
276+
277+
- name: Upload coverage reports
278+
uses: actions/upload-artifact@v4
279+
with:
280+
name: coverage-report
281+
path: coverage.info
282+
retention-days: 30

0 commit comments

Comments
 (0)