Build #480
This file contains 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: | |
pull_request: | |
push: | |
schedule: | |
- cron: '5 1 * * *' # Build every day at 1:05am | |
jobs: | |
Build: | |
name: '${{ matrix.platform.name }}' | |
runs-on: '${{ matrix.platform.os }}' | |
# The scheduled event should only run on libsdl-org/sdl2-compat | |
if: ${{ (github.event_name == 'schedule' && github.repository == 'libsdl-org/sdl2-compat') || (github.event_name != 'schedule') }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- { name: 'Linux', os: ubuntu-latest, artifact: 'SDL2_compat-ubuntu', shell: sh, static: true } | |
- { name: 'MacOS', os: macos-latest, artifact: 'SDL2_compat-macos', shell: sh } | |
- { name: 'Windows msys2 (mingw32)', os: windows-latest, artifact: 'SDL2_compat-mingw32', shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 } | |
- { name: 'Windows msys2 (mingw64)', os: windows-latest, artifact: 'SDL2_compat-mingw64', shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 } | |
- { name: 'Windows msys2 (clang32)', os: windows-latest, artifact: 'SDL2_compat-clang32', shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686 } | |
- { name: 'Windows msys2 (clang64)', os: windows-latest, artifact: 'SDL2_compat-clang64', shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64 } | |
- { name: 'Windows MSVC (x86)', os: windows-latest, artifact: 'SDL2_compat-VC-x86', shell: sh, msvc: true, msvc-arch: x86 } | |
- { name: 'Windows MSVC (x64)', os: windows-latest, artifact: 'SDL2_compat-VC-x64', shell: sh, msvc: true, msvc-arch: x64 } | |
- { name: 'Windows MSVC (arm32)', os: windows-latest, artifact: 'SDL2_compat-VC-arm32', shell: sh, msvc: true, msvc-arch: amd64_arm, cross: true } | |
- { name: 'Windows MSVC (arm64)', os: windows-latest, artifact: 'SDL2_compat-VC-arm64', shell: sh, msvc: true, msvc-arch: amd64_arm64, cross: true } | |
defaults: | |
run: | |
shell: ${{ matrix.platform.shell }} | |
steps: | |
- uses: ilammy/msvc-dev-cmd@v1 | |
if: ${{ matrix.platform.msvc }} | |
with: | |
arch: ${{ matrix.platform.msvc-arch }} | |
- name: Set up MSYS2 | |
if: ${{ contains(matrix.platform.shell, 'msys2') }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{ matrix.platform.msystem }} | |
install: >- | |
${{ matrix.platform.msys-env }}-cc | |
${{ matrix.platform.msys-env }}-cmake | |
${{ matrix.platform.msys-env }}-crt | |
${{ matrix.platform.msys-env }}-ninja | |
- name: Get sdl2-compat sources | |
uses: actions/checkout@v3 | |
- name: Install Ninja | |
if: ${{ !contains(matrix.platform.shell, 'msys2') }} | |
uses: turtlesec-no/get-ninja@main | |
- name: Set up SDL3 | |
uses: libsdl-org/setup-sdl@main | |
id: sdl | |
with: | |
cmake-generator: Ninja | |
version: 3-head | |
sdl-test: true | |
shell: ${{ matrix.platform.shell }} | |
add-to-environment: true | |
- name: Set up Linux dependencies | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev | |
- name: Configure (CMake) | |
run: | | |
cmake -S . -B build \ | |
-DSDL2COMPAT_STATIC=${{ matrix.platform.static }} \ | |
-DSDL2COMPAT_INSTALL=TRUE \ | |
-DCMAKE_INSTALL_LIBDIR=lib \ | |
-DSDL2COMPAT_INSTALL_CPACK=TRUE \ | |
-DCMAKE_INSTALL_PREFIX=prefix \ | |
-DSDL2COMPAT_WERROR=ON \ | |
-DCMAKE_POLICY_DEFAULT_CMP0141="NEW" \ | |
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT="ProgramDatabase" \ | |
-DCMAKE_EXE_LINKER_FLAGS="${{ matrix.platform.msvc && '-DEBUG' }}" \ | |
-DCMAKE_SHARED_LINKER_FLAGS="${{ matrix.platform.msvc && '-DEBUG' }}" \ | |
-GNinja | |
- name: Build (CMake) | |
id: build | |
run: | | |
cmake --build build/ --verbose | |
- name: Install (CMake) | |
run: | | |
cmake --install build/ | |
echo "SDL2_ROOT=$(pwd)/prefix" >>$GITHUB_ENV | |
- name: Package (CPack) | |
if: ${{ always() && steps.build.outcome == 'success' }} | |
run: | | |
cmake --build build/ --target package | |
- name: Run build-time tests (CMake) | |
if: ${{ false && !matrix.platform.cross }} # FIXME: enable build-time tests on CI | |
run: | | |
#FIXME: do this in libsdl-org/setup-sdl (by adding it to .bashrc)? Or move to separate ci step? | |
sdl_binpath="${{ steps.sdl.outputs.prefix }}/bin" | |
if [ "x${{ runner.os }}" = "xWindows" ]; then | |
sdl_binpath="$( cygpath -u "$sdl_binpath" )" | |
fi | |
echo "sdl_binpath=$sdl_binpath" | |
export PATH="$sdl_binpath:$PATH" | |
export LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" | |
set -eu | |
export SDL_TESTS_QUICK=1 | |
ctest -VV --test-dir build/ | |
- name: Run build tests (CMake) | |
run: | | |
cmake --build build/ --verbose --target sdl2compat-build-tests | |
- name: Check that versioning is consistent | |
# We only need to run this once: arbitrarily use the Linux build | |
if: ${{ runner.os == 'Linux' }} | |
run: | | |
./build-scripts/test-versioning.sh | |
- name: Verify CMake configuration files | |
run: | | |
cmake -S cmake/test -B cmake_config_build \ | |
-DTEST_SHARED=TRUE \ | |
-DTEST_STATIC=${{ matrix.platform.static || 'false' }} \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-GNinja | |
cmake --build cmake_config_build --verbose | |
- name: Verify sdl2-config | |
if: ${{ !matrix.platform.msvc }} | |
run: | | |
export PATH=${{ env.SDL2_ROOT }}/bin:$PATH | |
cmake/test/test_sdlconfig.sh ${{ !matrix.platform.static && '--no-static' }} | |
- name: Verify sdl2.pc | |
if: ${{ !matrix.platform.msvc }} | |
run: | | |
export PKG_CONFIG_PATH=${{ env.SDL2_ROOT }}/lib/pkgconfig | |
cmake/test/test_pkgconfig.sh ${{ !matrix.platform.static && '--no-static' }} | |
- uses: actions/upload-artifact@v3 | |
if: ${{ always() && steps.build.outcome == 'success' }} | |
with: | |
if-no-files-found: error | |
name: ${{ matrix.platform.artifact }} | |
path: build/dist/SDL2_compat* |