Skip to content

Testing CI with SDL 2.0.20 #24

Testing CI with SDL 2.0.20

Testing CI with SDL 2.0.20 #24

Workflow file for this run

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
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install prerequisites and build SDL from source (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential clang cmake ccache git \
libgl1-mesa-dev libglu1-mesa-dev \
libx11-dev libxrandr-dev libxi-dev libxinerama-dev libxcursor-dev libxss-dev libxxf86vm-dev \
libglew-dev libfreetype6-dev libasound2-dev libpulse-dev libudev-dev libdbus-1-dev \
libmpg123-dev libvorbis-dev libflac-dev libxmp-dev \
libopusfile-dev libfluidsynth-dev libogg-dev fluidsynth libwavpack-dev
# Build SDL2
git clone --branch 2.0.20 https://github.com/libsdl-org/SDL.git SDL2
cd SDL2
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DSDL_INSTALL_INCLUDEDIR=include/SDL2
make -j$(nproc)
sudo make install
sudo ldconfig
cd ../..
# Build SDL_ttf
git clone -b SDL2 https://github.com/libsdl-org/SDL_ttf.git SDL_ttf
cd SDL_ttf
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
sudo ldconfig
cd ../..
# Build SDL_mixer
git clone -b SDL2 https://github.com/libsdl-org/SDL_mixer.git SDL_mixer
cd SDL_mixer
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
sudo ldconfig
cd ../..
- 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: Configure with CMake
run: |
mkdir -p build
cd build
export CMAKE_INCLUDE_PATH=/usr/local/include
export CMAKE_LIBRARY_PATH=/usr/local/lib
cmake \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_BUILD_TYPE=Release \
..
- name: Verify SDL installation
run: |
ls /usr/local/include/
ls /usr/local/include/SDL2
ls /usr/local/lib | grep SDL
sdl2-config --version
- name: Build
run: cmake --build build --config Release -- -j$(nproc || echo 2)
- name: Run unit tests
run: |
cd build
ctest --output-on-failure --parallel $(nproc || echo 2)