Add tests for parsing .pro drug files #100
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 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 ===" | |
# Install Qt6 and required dependencies | |
brew install qt@6 double-conversion libb2 md4c dbus | |
# Link Qt6 (since it's keg-only and not linked by default) | |
brew link qt@6 --force --overwrite | |
brew link double-conversion --force | |
brew link libb2 --force | |
brew link md4c --force | |
brew link dbus --force | |
# Get Homebrew prefix and paths | |
HOMEBREW_PREFIX=$(brew --prefix) | |
QT6_PATH=$(brew --prefix qt@6) | |
LIBB2_PATH=$(brew --prefix libb2) | |
MD4C_PATH=$(brew --prefix md4c) | |
DBUS_PATH=$(brew --prefix dbus) | |
echo "Homebrew prefix: $HOMEBREW_PREFIX" | |
echo "Qt6 installed at: $QT6_PATH" | |
echo "libb2 installed at: $LIBB2_PATH" | |
echo "md4c installed at: $MD4C_PATH" | |
echo "dbus installed at: $DBUS_PATH" | |
# Set up library paths for Qt tools to find libb2, md4c, and dbus | |
export DYLD_LIBRARY_PATH="$LIBB2_PATH/lib:$MD4C_PATH/lib:$DBUS_PATH/lib:$HOMEBREW_PREFIX/lib:$DYLD_LIBRARY_PATH" | |
export LD_LIBRARY_PATH="$LIBB2_PATH/lib:$MD4C_PATH/lib:$DBUS_PATH/lib:$HOMEBREW_PREFIX/lib:$LD_LIBRARY_PATH" | |
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
# Export CMake path hints | |
export CMAKE_PREFIX_PATH="$QT6_PATH/lib/cmake:$CMAKE_PREFIX_PATH" | |
export Qt6_DIR="$QT6_PATH/lib/cmake/Qt6" | |
echo "CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" >> $GITHUB_ENV | |
echo "Qt6_DIR=$Qt6_DIR" >> $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 | |
# Verify libb2 is available | |
echo "Checking for libb2 library..." | |
# Look for libb2 libraries (versioned or unversioned) | |
LIBB2_FOUND=false | |
for lib in "$LIBB2_PATH/lib/libb2.dylib" "$LIBB2_PATH/lib/libb2.1.dylib" "$LIBB2_PATH/lib/libb2.*.dylib"; do | |
if [[ -f "$lib" ]]; then | |
echo "✅ libb2 library found: $lib" | |
LIBB2_FOUND=true | |
break | |
fi | |
done | |
if [[ "$LIBB2_FOUND" == "false" ]]; then | |
echo "❌ libb2 library not found in expected locations" | |
echo "Contents of $LIBB2_PATH/lib/:" | |
ls -la "$LIBB2_PATH/lib/" | grep -i libb2 || echo "No libb2 files found" | |
echo "Searching for libb2 libraries system-wide..." | |
find "$HOMEBREW_PREFIX" -name "*libb2*" 2>/dev/null || echo "No libb2 libraries found" | |
exit 1 | |
fi | |
# Verify md4c is available | |
echo "Checking for md4c library..." | |
# Look for md4c libraries (versioned or unversioned) | |
MD4C_FOUND=false | |
for lib in "$MD4C_PATH/lib/libmd4c.dylib" "$MD4C_PATH/lib/libmd4c.0.dylib" "$MD4C_PATH/lib/libmd4c.*.dylib"; do | |
if [[ -f "$lib" ]]; then | |
echo "✅ md4c library found: $lib" | |
MD4C_FOUND=true | |
break | |
fi | |
done | |
if [[ "$MD4C_FOUND" == "false" ]]; then | |
echo "❌ md4c library not found in expected locations" | |
echo "Contents of $MD4C_PATH/lib/:" | |
ls -la "$MD4C_PATH/lib/" | grep -i md4c || echo "No md4c files found" | |
echo "Searching for md4c libraries system-wide..." | |
find "$HOMEBREW_PREFIX" -name "*md4c*" 2>/dev/null || echo "No md4c libraries found" | |
exit 1 | |
fi | |
# Test that Qt tools can find libb2 and md4c with the exported paths | |
echo "Testing Qt uic tool with library paths..." | |
echo "Current DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH" | |
if DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH" "$QT6_PATH/share/qt/libexec/uic" -h > /dev/null 2>&1; then | |
echo "✅ Qt uic tool can load with all required libraries" | |
else | |
echo "❌ Qt uic tool failed to load" | |
echo "Trying to diagnose..." | |
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH" otool -L "$QT6_PATH/share/qt/libexec/uic" | grep -i -E "(libb2|md4c)" || true | |
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 paths for CMake test discovery on Linux/macOS | |
# On macOS, use the environment variables set by the Qt setup step | |
if [[ "${{ runner.os }}" == "macOS" ]]; then | |
echo "Using DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH" | |
echo "Using LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
else | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
fi | |
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 paths for Linux/macOS | |
if [[ "${{ runner.os }}" == "macOS" ]]; then | |
echo "Using DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH" | |
echo "Using LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
else | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
fi | |
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 paths for Linux and macOS | |
if [[ "${{ runner.os }}" == "macOS" ]]; then | |
echo "Using DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH" | |
echo "Using LD_LIBRARY_PATH: $LD_LIBRARY_PATH" | |
else | |
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH | |
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH | |
fi | |
# 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: gecko-${{ matrix.os }}-${{ matrix.build_type }} | |
path: | | |
${{ env.BUILD_DIR }}/src/gecko* | |
${{ 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 | |