SDL: Fixup 'ci: merge all workflows'

From 9eebee9ff039c503fec8c6c61292a0b78388aa19 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 23 Nov 2024 22:40:00 +0100
Subject: [PATCH] Fixup 'ci: merge all workflows'

---
 .github/workflows/build.yml |  48 ++++++++
 .github/workflows/main.yml  | 240 ------------------------------------
 2 files changed, 48 insertions(+), 240 deletions(-)
 create mode 100644 .github/workflows/build.yml
 delete mode 100644 .github/workflows/main.yml

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
new file mode 100644
index 0000000000000..09652e024817c
--- /dev/null
+++ b/.github/workflows/build.yml
@@ -0,0 +1,48 @@
+name: 'Build (All)'
+
+on: [push, pull_request]
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
+  cancel-in-progress: true
+
+jobs:
+  controller:
+    name: 'Create test plan'
+    runs-on: 'ubuntu-latest'
+    outputs:
+      platforms-level1: ${{ steps.plan.outputs.platforms-level1 }}
+      platforms-others: ${{ steps.plan.outputs.platforms-others }}
+    steps:
+      - uses: actions/setup-python@main
+        with:
+          python-version: 3.x
+      - uses: actions/checkout@main
+        with:
+          sparse-checkout: '.github/workflows/create-test-plan.py'
+      - name: 'Create plan'
+        id: plan
+        run: |
+          # Adding [sdl-ci-filter GLOB] to the commit message will limit the jobs
+          # e.g. [sdl-ci-filter msvc-*]
+          EOF=$(openssl rand -hex 32)
+          cat >/tmp/commit_message.txt <<$EOF
+          ${{ github.event.head_commit.message }}
+          $EOF
+
+          python .github/workflows/create-test-plan.py \
+            --github-variable-prefix platforms \
+            --github-ci \
+            --verbose \
+            ${{ (github.repository_owner != 'libsdl-org' && '--no-artifact') || '' }} \
+            --commit-message-file /tmp/commit_message.txt
+  level1:
+    needs: [controller]
+    uses: './.github/workflows/generic.yml'
+    with:
+      platforms: ${{ needs.controller.outputs.platforms-level1 }}
+  level2:
+    needs: [controller, level1]
+    uses: './.github/workflows/generic.yml'
+    with:
+      platforms: ${{ needs.controller.outputs.platforms-others }}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 18de2184c4751..0000000000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,240 +0,0 @@
-name: Build
-
-on: [push, pull_request]
-
-jobs:
-  Build:
-    name: ${{ matrix.platform.name }}
-    runs-on: ${{ matrix.platform.os }}
-
-    defaults:
-      run:
-        shell: ${{ matrix.platform.shell }}
-
-    strategy:
-      fail-fast: false
-      matrix:
-        platform:
-        - { name: Windows (mingw32),              os: windows-latest, shell: 'msys2 {0}', msystem: mingw32, msys-env: mingw-w64-i686 }
-        - { name: Windows (mingw64),              os: windows-latest, shell: 'msys2 {0}', msystem: mingw64, msys-env: mingw-w64-x86_64 }
-        - { name: Windows (clang32),              os: windows-latest, shell: 'msys2 {0}', msystem: clang32, msys-env: mingw-w64-clang-i686 }
-        - { name: Windows (clang64),              os: windows-latest, shell: 'msys2 {0}', msystem: clang64, msys-env: mingw-w64-clang-x86_64 }
-        - { name: Windows (ucrt64),               os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64,  msys-env: mingw-w64-ucrt-x86_64 }
-        - { name: Ubuntu 20.04 (CMake),           os: ubuntu-20.04,   shell: sh }
-        - { name: Ubuntu 20.04 (autotools),       os: ubuntu-20.04,   shell: sh,    autotools: true }
-        - { name: Intel oneAPI (Ubuntu 20.04),    os: ubuntu-20.04,   shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
-            source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
-        - { name: Intel Compiler (Ubuntu 20.04),  os: ubuntu-20.04,   shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
-             source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
-
-        - { name: Ubuntu 22.04 (CMake),           os: ubuntu-22.04,   shell: sh }
-        - { name: Ubuntu 22.04 (autotools),       os: ubuntu-22.04,   shell: sh,    autotools: true }
-        - { name: MacOS (CMake),                  os: macos-latest,   shell: sh,    cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
-        - { name: MacOS (autotools),              os: macos-latest,   shell: sh,    autotools: true }
-
-    steps:
-    - name: Set up MSYS2
-      if: matrix.platform.shell == 'msys2 {0}'
-      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 }}-ninja
-          ${{ matrix.platform.msys-env }}-pkg-config
-
-    - name: Setup Linux dependencies
-      if: runner.os == 'Linux'
-      run: |
-        sudo apt-get update
-        sudo apt-get install build-essential git make autoconf automake libtool \
-            pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
-            libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
-            libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
-            libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
-            libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
-
-    - name: Setup extra Ubuntu 22.04 dependencies
-      if: matrix.platform.os == 'ubuntu-22.04'
-      run: |
-        sudo apt-get install libpipewire-0.3-dev libdecor-0-dev
-
-    - name: Setup Macos dependencies
-      if: runner.os == 'macOS'
-      run: |
-        brew install \
-          autoconf \
-          ninja
-
-    - name: Setup Intel oneAPI
-      if: matrix.platform.intel
-      run: |
-        # Download the key to system keyring
-        wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
-          | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
-
-        # Add signed entry to apt sources and configure the APT client to use Intel repository:
-        echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
-
-        # Update package list
-        sudo apt-get update -y
-
-        # Install oneAPI
-        sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
-
-    - uses: actions/checkout@v4
-    - name: Check that versioning is consistent
-      # We only need to run this once: arbitrarily use the Linux/CMake build
-      if: "runner.os == 'Linux' && ! matrix.platform.autotools"
-      run: ./build-scripts/test-versioning.sh
-    - name: Configure (CMake)
-      if: "! matrix.platform.autotools"
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        cmake -S . -B build -G Ninja \
-        -DSDL_TESTS=ON \
-        -DSDL_WERROR=ON \
-        -DSDL_INSTALL_TESTS=ON \
-        -DSDL_VENDOR_INFO="Github Workflow" \
-        -DCMAKE_INSTALL_PREFIX=cmake_prefix \
-        -DCMAKE_BUILD_TYPE=Release \
-        ${{ matrix.platform.cmake }}
-    - name: Build (CMake)
-      if: "! matrix.platform.autotools"
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        cmake --build build/ --config Release --verbose --parallel
-    - name: Run build-time tests (CMake)
-      if: "! matrix.platform.autotools"
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        export SDL_TESTS_QUICK=1
-        ctest -VV --test-dir build/ -j2
-        if test "${{ runner.os }}" = "Linux"; then
-          # This should show us the SDL_REVISION
-          strings build/libSDL2-2.0.so.0 | grep SDL-
-        fi
-    - name: Install (CMake)
-      if: "! matrix.platform.autotools"
-      run: |
-        set -eu
-        cmake --install build/ --config Release
-        echo "SDL2_DIR=$(pwd)/cmake_prefix" >> $GITHUB_ENV
-        ( cd cmake_prefix; find ) | LC_ALL=C sort -u
-    - name: Configure (Autotools)
-      if: matrix.platform.autotools
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        rm -fr build-autotools
-        mkdir build-autotools
-        ./autogen.sh
-        (
-          cd build-autotools
-          ${{ github.workspace }}/configure \
-            --enable-vendor-info="Github Workflow" \
-            --enable-werror \
-            --prefix=${{ github.workspace }}/autotools_prefix \
-        )
-        if test "${{ runner.os }}" != "macOS" ; then
-          curdir="$(pwd)"
-          multiarch="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
-          (
-            mkdir -p build-autotools/test
-            cd build-autotools/test
-            ${{ github.workspace }}/test/configure \
-              --enable-werror \
-              --x-includes=/usr/include \
-              --x-libraries="/usr/lib/${multiarch}" \
-              --prefix=${{ github.workspace }}/autotools_prefix \
-              SDL_CFLAGS="-I${curdir}/include" \
-              SDL_LIBS="-L${curdir}/build-autotools/build/.libs -lSDL2" \
-              ac_cv_lib_SDL2_ttf_TTF_Init=no \
-              ${NULL+}
-          )
-        fi
-    - name: Build (Autotools)
-      if: matrix.platform.autotools
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools V=1
-        if test "${{ runner.os }}" != "macOS" ; then
-          make -j"${parallel}" -C build-autotools/test V=1
-        fi
-    - name: Run build-time tests (Autotools)
-      if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        curdir="$(pwd)"
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        export SDL_TESTS_QUICK=1
-        make -j"${parallel}" -C build-autotools/test check LD_LIBRARY_PATH="${curdir}/build-autotools/build/.libs"
-        if test "${{ runner.os }}" = "Linux"; then
-          # This should show us the SDL_REVISION
-          strings "${curdir}/build-autotools/build/.libs/libSDL2-2.0.so.0" | grep SDL-
-        fi
-    - name: Install (Autotools)
-      if: matrix.platform.autotools
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        curdir="$(pwd)"
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools install V=1
-        if test "${{ runner.os }}" != "macOS" ; then
-          make -j"${parallel}" -C build-autotools/test install V=1
-        fi
-        ( cd autotools_prefix; find . ) | LC_ALL=C sort -u
-        echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
-    - name: Verify CMake configuration files
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        cmake -S cmake/test -B cmake_config_build -G Ninja \
-          -DCMAKE_BUILD_TYPE=Release \
-          -DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
-        cmake --build cmake_config_build --verbose
-    - name: Verify sdl2-config
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        export PATH=${{ env.SDL2_DIR }}/bin:$PATH
-        cmake/test/test_sdlconfig.sh
-    - name: Verify sdl2.pc
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
-        cmake/test/test_pkgconfig.sh
-    - name: Distcheck (Autotools)
-      if: matrix.platform.autotools
-      run: |
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        make -j"${parallel}" -C build-autotools dist V=1
-        # Similar to Automake `make distcheck`: check that the tarball
-        # release is sufficient to do a new build
-        mkdir distcheck
-        tar -C distcheck -zxf build-autotools/SDL2-*.tar.gz
-        ( cd distcheck/SDL2-* && ./configure )
-        make -j"${parallel}" -C distcheck/SDL2-*
-    - name: Run installed-tests (Autotools)
-      if: "runner.os == 'Linux' && matrix.platform.autotools"
-      run: |
-        ${{ matrix.platform.source_cmd }}
-        set -eu
-        parallel="$(getconf _NPROCESSORS_ONLN)"
-        sudo make -j"${parallel}" -C build-autotools install
-        sudo make -j"${parallel}" -C build-autotools/test install
-        export SDL_TESTS_QUICK=1
-        # We need to set LD_LIBRARY_PATH because it isn't in the default
-        # linker search path. We don't need to set XDG_DATA_DIRS for
-        # ginsttest-runner, because /usr/local/share *is* in the default
-        # search path for that.
-        env --chdir=/ \
-            LD_LIBRARY_PATH=/usr/local/lib \
-            SDL_AUDIODRIVER=dummy \
-            SDL_VIDEODRIVER=dummy \
-            ginsttest-runner --tap SDL2