Trying to fix the test executable #47
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: CI | |
on: | |
push: | |
branches: [main, dev] | |
pull_request: | |
branches: [main, dev] | |
jobs: | |
build-and-test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-latest | |
compiler: gcc | |
cc: gcc | |
cxx: g++ | |
- os: ubuntu-latest | |
compiler: clang | |
cc: clang | |
cxx: clang++ | |
- os: windows-latest | |
compiler: msvc | |
cc: cl | |
cxx: cl | |
- os: windows-latest | |
compiler: mingw64 | |
cc: x86_64-w64-mingw32-gcc | |
cxx: x86_64-w64-mingw32-g++ | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# MSVC: copy glew.rc so CMake's add_library() finds it | |
- name: Prepare GLEW resource file for MSVC | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc' | |
shell: pwsh | |
run: | | |
New-Item -ItemType Directory -Force -Path import\glew-cmake\build | |
Copy-Item -Force import\glew-cmake\rc\glew.rc import\glew-cmake\build\glew.rc | |
- name: Install prerequisites (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
build-essential cmake ccache git \ | |
libgl1-mesa-dev libglu1-mesa-dev \ | |
libx11-dev libxrandr-dev libxi-dev libxinerama-dev libxcursor-dev libxss-dev libxxf86vm-dev \ | |
libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev \ | |
libglew-dev libfreetype6-dev | |
- name: Install MinGW (Windows, MinGW only) | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'mingw64' | |
shell: pwsh | |
run: | | |
choco install -y mingw | |
# Chocolatey unpacks MinGW-w64 under C:\ProgramData\mingw64\mingw64\bin | |
$bin = 'C:\ProgramData\mingw64\mingw64\bin' | |
Add-Content -Path $Env:GITHUB_PATH -Value $bin | |
- name: Setup MSVC (Windows, MSVC only) | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Configure with CMake | |
shell: bash | |
run: | | |
mkdir -p build | |
cd build | |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then | |
cmake \ | |
-DCMAKE_C_COMPILER=${{ matrix.cc }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_PREFIX_PATH="/usr/local" \ | |
.. | |
elif [ "${{ matrix.compiler }}" = "mingw64" ]; then | |
cmake \ | |
-G "MinGW Makefiles" \ | |
-DCMAKE_C_COMPILER=${{ matrix.cc }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
.. | |
else | |
cmake \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
.. | |
fi | |
- name: Cache ccache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.ccache | |
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-ccache-${{ matrix.compiler }}- | |
- name: Cache CMake build | |
uses: actions/cache@v3 | |
with: | |
path: build | |
key: ${{ runner.os }}-cmake-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-cmake-${{ matrix.compiler }}- | |
- name: Verify SDL2 installation (Linux only) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
echo "Includes:" | |
ls /usr/local/include/ | |
echo "sdl2-config:" | |
sdl2-config --version | |
- name: Copy MinGW-w64 runtime DLLs for tests | |
if: matrix.os == 'windows-latest' && matrix.compiler == 'mingw64' | |
shell: pwsh | |
run: | | |
$bin = 'C:\ProgramData\mingw64\mingw64\bin' | |
Copy-Item "$bin\libstdc++-6.dll" build | |
Copy-Item "$bin\libgcc_s_seh-1.dll" build | |
# Optional, if your build uses winpthread: | |
Copy-Item "$bin\libwinpthread-1.dll" build -ErrorAction SilentlyContinue | |
- name: Build tests only | |
shell: bash | |
run: | | |
cd build | |
if [ "${{ matrix.compiler }}" = "mingw64" ]; then | |
mingw32-make -j$(nproc || echo 2) t1 | |
else | |
cmake --build . --config Release --target t1 -- -j$(nproc || echo 2) | |
fi | |
- name: Run unit tests | |
shell: bash | |
run: | | |
cd build | |
ctest --output-on-failure --parallel $(nproc || echo 2) |