Skip to content

build: update build files after refactoring #103

build: update build files after refactoring

build: update build files after refactoring #103

name: Build and Test ChainedDecos
on:
workflow_dispatch:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
CI: true
jobs:
build-and-test:
name: Build and Test (${{ matrix.os }}, ${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Ubuntu with GCC
- os: ubuntu-22.04
compiler: gcc
version: 11
build_type: Release
generator: "Unix Makefiles"
# Ubuntu with Clang
- os: ubuntu-22.04
compiler: clang
version: 14
build_type: Release
generator: "Unix Makefiles"
# Windows with MSVC
- os: windows-2022
compiler: msvc
version: 2022
build_type: Release
generator: "Ninja"
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup ccache
uses: actions/cache@v3
with:
path: |
~/.ccache
C:\ccache
key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ github.sha }}
restore-keys: |
ccache-${{ matrix.os }}-${{ matrix.compiler }}-
ccache-${{ matrix.os }}-
- name: Setup dependency cache
uses: actions/cache@v3
with:
path: |
.deps
~/.deps
key: deps-${{ matrix.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
deps-${{ matrix.os }}-${{ matrix.compiler }}-
deps-${{ matrix.os }}-
- name: Set up build environment
shell: bash
id: build-env
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
echo "install-prefix=${{ github.workspace }}/install" >> "$GITHUB_OUTPUT"
# ---------------- Linux (Ubuntu) setup ----------------
- name: Install dependencies (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build \
libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev \
libxcursor-dev libxi-dev libasound2-dev libglu1-mesa-dev \
libwayland-dev libxkbcommon-dev libegl1-mesa-dev \
pkg-config ccache
- name: Set up GCC (Ubuntu)
if: matrix.compiler == 'gcc' && startsWith(matrix.os, 'ubuntu')
run: |
echo "CC=gcc-${{ matrix.version }}" >> "$GITHUB_ENV"
echo "CXX=g++-${{ matrix.version }}" >> "$GITHUB_ENV"
- name: Set up Clang (Ubuntu)
if: matrix.compiler == 'clang' && startsWith(matrix.os, 'ubuntu')
run: |
echo "CC=clang-${{ matrix.version }}" >> "$GITHUB_ENV"
echo "CXX=clang++-${{ matrix.version }}" >> "$GITHUB_ENV"
# ---------------- Windows setup ----------------
- name: Install dependencies (Windows)
if: matrix.os == 'windows-2022'
run: |
choco install cmake ninja ccache --no-progress
# ---------------- Common build steps ----------------
- name: Clear CMake cache
shell: bash
run: |
rm -rf "${{ steps.build-env.outputs.build-output-dir }}"
rm -rf ".deps"
rm -f CMakeCache.txt cmake_install.cmake CMakeFiles/
- name: Create build directory
run: |
mkdir -p "${{ steps.build-env.outputs.build-output-dir }}"
mkdir -p "${{ steps.build-env.outputs.install-prefix }}"
- name: Configure CMake
shell: bash
run: |
cmake -B "${{ steps.build-env.outputs.build-output-dir }}" \
-G "${{ matrix.generator }}" \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_INSTALL_PREFIX="${{ steps.build-env.outputs.install-prefix }}" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DBUILD_TESTS=ON \
-DBUILD_BENCHMARKS=ON \
-DENABLE_WARNINGS=OFF \
-DENABLE_OPTIMIZATIONS=ON \
-DENABLE_UNITY_BUILD=OFF \
-DENABLE_DEV_TOOLS=OFF \
-DENABLE_DEBUG_INFO=ON \
-S "${{ github.workspace }}"
- name: Build project
shell: bash
run: |
cmake --build "${{ steps.build-env.outputs.build-output-dir }}" \
--config ${{ matrix.build_type }} \
--target ChainedDecos ChainedDecosMapEditor ChainedDecosTests \
--parallel $(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 8)
- name: Install project
shell: bash
run: |
cmake --install "${{ steps.build-env.outputs.build-output-dir }}" \
--config ${{ matrix.build_type }}
- name: Run tests
shell: bash
run: |
cd "${{ steps.build-env.outputs.build-output-dir }}"
# Run CTest if available
if command -v ctest &> /dev/null; then
echo "🧪 Running tests with CTest..."
ctest --output-on-failure --build-config ${{ matrix.build_type }} || echo "⚠️ Some tests failed"
else
echo "ℹ️ CTest not available, looking for test executables..."
# Look for test executables in build directory
if [ "${{ matrix.os }}" = "windows-2022" ]; then
find . -name "*test*.exe" -type f -executable | head -5 | while read -r test_exe; do
echo "🔍 Running test: $(basename "$test_exe")"
"$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")"
done
else
find . -name "*test*" -type f -executable | head -5 | while read -r test_exe; do
echo "🔍 Running test: $(basename "$test_exe")"
"$test_exe" || echo "⚠️ Test failed: $(basename "$test_exe")"
done
fi
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: build-artifacts-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}
path: |
${{ steps.build-env.outputs.install-prefix }}/bin/
${{ steps.build-env.outputs.build-output-dir }}/compile_commands.json
retention-days: 7