sdl2-compat: ci: use libsdl-org/SDL to set up SDL3

From cb70ade5f36c1e5159b663cc5fe3f92da2c6fbf1 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 3 Jul 2023 16:59:16 +0200
Subject: [PATCH] ci: use libsdl-org/SDL to set up SDL3

---
 .github/workflows/main.yml | 55 ++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 17 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index b55dc58..42be474 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -7,31 +7,52 @@ jobs:
     name: ${{ matrix.platform.name }}
     runs-on: ${{ matrix.platform.os }}
     strategy:
+      fail-fast: false
       matrix:
         platform:
-        - { name: Windows, os: windows-latest }
-        - { name: Linux,   os: ubuntu-latest, flags: -GNinja }
+        - { name: Windows, os: windows-latest, msvc: true }
+        - { name: Linux,   os: ubuntu-latest }
         - { name: MacOS,   os: macos-latest }
     steps:
-    - name: Setup Linux dependencies
-      if: runner.os == 'Linux'
-      run: |
-        sudo apt-get update
-        sudo apt-get install cmake ninja-build libgl1-mesa-dev libglu1-mesa-dev
+    - uses: ilammy/msvc-dev-cmd@v1
+      if: ${{ matrix.platform.msvc }}
+      with:
+        arch: x64
     - name: Get sdl2-compat sources
       uses: actions/checkout@v3
-    - name: Get SDL3 headers
-      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
       with:
-        repository: libsdl-org/SDL
-        ref: main
-        path: SDL3
+        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)
+      shell: sh
+      run: |
+        cmake -B build -GNinja
+    - name: Build (CMake)
+      run: |
+        cmake --build build/
+    - name: Run build-time tests (CMake)
+      if: ${{ false }} # FIXME: enable build-time tests on CI
+      shell: sh
+      run: |
+        set -eu
+        export SDL_TESTS_QUICK=1
+        ctest -VV --test-dir build/
     - name: Check that versioning is consistent
       # We only need to run this once: arbitrarily use the Linux build
       if: ${{ runner.os == 'Linux' }}
       shell: bash
-      run: ./build-scripts/test-versioning.sh
-    - name: Configure CMake
-      run: cmake -DSDL3_INCLUDE_DIRS="${{ github.workspace }}/SDL3/include" -B build ${{ matrix.platform.flags }}
-    - name: Build
-      run: cmake --build build/
+      run: |
+        ./build-scripts/test-versioning.sh