Handle missing assets gracefully in tests and update Qt6 setup in Git… #82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [ master, main, develop, "feature/*" ] | |
pull_request: | |
branches: [ master, main, develop ] | |
env: | |
CMAKE_VERSION: 3.31.4 | |
BUILD_TYPE: Release | |
BUILD_DIR: ${{ github.workspace }}/build | |
jobs: | |
build: | |
name: ${{ matrix.os }} - ${{ matrix.build_type }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
build_type: [Debug, Release] | |
include: | |
- os: ubuntu-latest | |
install_deps: | | |
sudo apt-get update | |
# Install Qt6 packages (correct names for Ubuntu) | |
sudo apt-get install -y \ | |
qt6-base-dev qt6-base-dev-tools \ | |
libgl1-mesa-dev \ | |
libxrandr-dev \ | |
libxcursor-dev \ | |
libxi-dev \ | |
libxinerama-dev \ | |
libx11-dev \ | |
libxext-dev \ | |
libudev-dev \ | |
libopenal-dev \ | |
libflac-dev \ | |
libvorbis-dev \ | |
libegl1-mesa-dev \ | |
libdrm-dev \ | |
libgbm-dev \ | |
libfreetype6-dev \ | |
zlib1g-dev | |
# Build SFML 3 from source as it's not in Ubuntu repos yet | |
git clone --depth 1 --branch 3.0.0 https://github.com/SFML/SFML.git | |
cd SFML | |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON | |
cmake --build build --config Release | |
sudo cmake --install build | |
cd .. | |
# Update library cache for SFML | |
sudo ldconfig | |
# Install spdlog (compatible version) | |
git clone --depth 1 --branch v1.12.0 https://github.com/gabime/spdlog.git | |
cd spdlog | |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_SHARED=ON | |
cmake --build build --config Release | |
sudo cmake --install build | |
cd .. | |
# Update library cache for spdlog | |
sudo ldconfig | |
- os: windows-latest | |
install_deps: | | |
# Use vcpkg for dependencies | |
vcpkg install qtbase:x64-windows qttools:x64-windows sfml:x64-windows spdlog:x64-windows zlib:x64-windows | |
cmake_extra_args: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake | |
- os: macos-latest | |
install_deps: | | |
brew install qt@6 zlib | |
# Build SFML 3 from source | |
git clone --depth 1 --branch 3.0.0 https://github.com/SFML/SFML.git | |
cd SFML | |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON | |
cmake --build build --config Release | |
sudo cmake --install build | |
cd .. | |
# Install spdlog (compatible version, same as Ubuntu) | |
git clone --depth 1 --branch v1.12.0 https://github.com/gabime/spdlog.git | |
cd spdlog | |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_SHARED=ON | |
cmake --build build --config Release | |
sudo cmake --install build | |
cd .. | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Fix vfspp CMake version requirement | |
shell: bash | |
run: | | |
# Patch vfspp CMakeLists.txt to use compatible CMake version | |
if [ "${{ matrix.os }}" == "macos-latest" ]; then | |
sed -i '.bak' 's/cmake_minimum_required(VERSION 3.50)/cmake_minimum_required(VERSION 3.20)/' vendor/vfspp/CMakeLists.txt | |
else | |
sed -i 's/cmake_minimum_required(VERSION 3.50)/cmake_minimum_required(VERSION 3.20)/' vendor/vfspp/CMakeLists.txt | |
fi | |
- name: Set up CMake | |
uses: lukka/get-cmake@latest | |
with: | |
cmakeVersion: ${{ env.CMAKE_VERSION }} | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/vcpkg | |
~/.cache/vcpkg | |
~/Library/Caches/Homebrew | |
/usr/local/Cellar | |
/opt/homebrew/Cellar | |
key: ${{ runner.os }}-deps-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-deps- | |
- name: Install dependencies | |
shell: bash | |
run: ${{ matrix.install_deps }} | |
- name: Setup Qt6 on macOS | |
if: runner.os == 'macOS' | |
shell: bash | |
run: | | |
echo "=== Setting up Qt6 on macOS ===" | |
brew install qt@6 | |
# Link Qt6 (since it's keg-only and not linked by default) | |
brew link qt@6 --force --overwrite | |
# Get Homebrew prefix | |
QT6_PATH=$(brew --prefix qt@6) | |
echo "Qt6 installed at: $QT6_PATH" | |
# Export CMake path hints | |
echo "CMAKE_PREFIX_PATH=$QT6_PATH/lib/cmake" >> $GITHUB_ENV | |
echo "Qt6_DIR=$QT6_PATH/lib/cmake/Qt6" >> $GITHUB_ENV | |
# Confirm existence | |
echo "Looking for Qt6Config.cmake in $QT6_PATH/lib/cmake/Qt6" | |
if [[ -f "$QT6_PATH/lib/cmake/Qt6/Qt6Config.cmake" ]]; then | |
echo "✅ Qt6Config.cmake found" | |
else | |
echo "❌ Qt6Config.cmake not found" | |
find "$QT6_PATH" -name Qt6Config.cmake | |
exit 1 | |
fi | |
- name: Configure CMake | |
shell: bash | |
run: | | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
# Use Windows paths with proper escaping | |
cmake -B "${{ env.BUILD_DIR }}" \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DGECK_BUILD_TESTS=ON \ | |
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \ | |
-DGECK_AUTO_TEST=OFF \ | |
${{ matrix.cmake_extra_args }} \ | |
-S "${{ github.workspace }}" | |
else | |
# Set library path for CMake test discovery on Linux/macOS | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
cmake -B "${{ env.BUILD_DIR }}" \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DGECK_BUILD_TESTS=ON \ | |
-DGECK_AUTO_TEST=OFF \ | |
-DSPDLOG_FMT_EXTERNAL=OFF \ | |
-DCMAKE_CXX_FLAGS="-Wno-error" \ | |
${{ matrix.cmake_extra_args }} \ | |
-S "${{ github.workspace }}" | |
fi | |
- name: Build | |
shell: bash | |
run: | | |
if [[ "${{ runner.os }}" != "Windows" ]]; then | |
# Set library path for Linux/macOS | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
fi | |
cmake --build "${{ env.BUILD_DIR }}" --config ${{ matrix.build_type }} --parallel | |
- name: Run Unit Tests | |
shell: bash | |
working-directory: ${{ env.BUILD_DIR }} | |
run: | | |
if [[ "${{ runner.os }}" == "Windows" ]]; then | |
# Run tests with proper configuration | |
ctest -C ${{ matrix.build_type }} --output-on-failure --verbose | |
else | |
# Set library path for Linux and macOS | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
# Set Qt platform to offscreen for headless testing on Linux | |
if [[ "${{ runner.os }}" == "Linux" ]]; then | |
export QT_QPA_PLATFORM=offscreen | |
fi | |
ctest --output-on-failure --verbose | |
fi | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: geck-mapper-${{ matrix.os }}-${{ matrix.build_type }} | |
path: | | |
${{ env.BUILD_DIR }}/src/geck-mapper* | |
${{ env.BUILD_DIR }}/tests/*_tests* | |
retention-days: 7 | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.os }}-${{ matrix.build_type }} | |
path: | | |
test-results/ | |
${{ env.BUILD_DIR }}/Testing/ | |
retention-days: 7 | |