Skip to content

Commit d7e19b5

Browse files
add CI
1 parent 2c182ab commit d7e19b5

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: MiniSolver CI Pipeline
2+
3+
# Trigger mechanism: When code is pushed to the main branch, or a Pull Request is submitted
4+
on:
5+
push:
6+
branches: [ "main", "master" ]
7+
pull_request:
8+
branches: [ "main", "master" ]
9+
# Allow manual trigger on GitHub Actions page
10+
workflow_dispatch:
11+
12+
jobs:
13+
build-and-test:
14+
name: ${{ matrix.os }} - ${{ matrix.backend }} - ${{ matrix.build_type }}
15+
runs-on: ${{ matrix.os }}
16+
17+
# Matrix strategy: Automatically combine different operating systems, backends, and build types for parallel testing
18+
strategy:
19+
fail-fast: false # If one task fails, do not immediately cancel other tasks
20+
matrix:
21+
os: [ubuntu-latest] # Can expand to windows-latest, macos-latest
22+
build_type: [Release, Debug]
23+
backend: [Eigen, CustomMatrix]
24+
include:
25+
# Set CMake parameters for different backends
26+
- backend: Eigen
27+
cmake_args: "-DUSE_EIGEN=ON"
28+
- backend: CustomMatrix
29+
cmake_args: "-DUSE_CUSTOM_MATRIX=ON"
30+
31+
steps:
32+
# 1. Pull code
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
36+
# 2. Prepare Python environment (for code generation)
37+
- name: Set up Python 3.x
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.10'
41+
cache: 'pip' # Cache pip dependencies to speed up build
42+
43+
# 3. Install dependencies (SymPy & System Tools)
44+
- name: Install Dependencies
45+
run: |
46+
# Update apt and install build tools
47+
sudo apt-get update
48+
sudo apt-get install -y cmake g++ make
49+
50+
# Install Python dependencies (SymPy)
51+
pip install sympy
52+
53+
# 4. Execute code generation (simulate build.sh logic)
54+
- name: Generate Model Code
55+
run: |
56+
echo ">> Generating C++ headers from Python models..."
57+
# Set PYTHONPATH to find minisolver module
58+
export PYTHONPATH=$PYTHONPATH:$(pwd)/python
59+
60+
# Run vehicle model generation script
61+
python3 examples/01_car_tutorial/generate_model.py
62+
63+
# Run advanced bicycle model generation script
64+
python3 examples/02_advanced_bicycle/generate_advanced_model.py
65+
66+
# 5. Configure CMake
67+
- name: Configure CMake
68+
run: |
69+
# Create build directory and configure
70+
# ${{ matrix.cmake_args }} will automatically switch backend definition based on current matrix task
71+
cmake -B build \
72+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
73+
${{ matrix.cmake_args }}
74+
75+
# 6. Compile project
76+
- name: Build Project
77+
run: |
78+
# Use multi-core compilation to speed up
79+
cmake --build build --config ${{ matrix.build_type }} -j$(nproc)
80+
81+
# 7. Run unit tests
82+
- name: Run Unit Tests
83+
working-directory: build
84+
run: |
85+
echo ">> Running GTest Suite..."
86+
# --output-on-failure: Output detailed logs when tests fail for debugging
87+
ctest --output-on-failure -C ${{ matrix.build_type }}
88+
89+
# 8. (Optional) Run Benchmark to ensure performance does not drop significantly
90+
# Only run in Release mode to avoid misleading performance data in Debug mode
91+
- name: Run Benchmark Check
92+
if: matrix.build_type == 'Release'
93+
working-directory: build
94+
run: |
95+
if [ -f "./tools/benchmark_suite/benchmark_suite" ]; then
96+
echo ">> Running Benchmark Suite..."
97+
./tools/benchmark_suite/benchmark_suite
98+
else
99+
echo "Benchmark executable not found, skipping."
100+
fi

0 commit comments

Comments
 (0)