SDL: ci: test with (old) Intel compiler + (new) oneAPI compiler (b5828)

From b58285b7ed92cf36d528bca2ed057a0bca28de27 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 23 Mar 2023 05:26:56 +0100
Subject: [PATCH] ci: test with (old) Intel compiler + (new) oneAPI compiler

---
 .github/workflows/main.yml | 51 ++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index e7b737c5bc86..ab737184ac92 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -15,17 +15,22 @@ jobs:
       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: 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 }
+        - { 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
@@ -61,6 +66,19 @@ jobs:
         brew install \
           ninja \
           pkg-config
+
+    - name: Setup Intel oneAPI
+      if: matrix.platform.intel
+      run: |
+        # Setup oneAPI repo
+        wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
+        sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
+        sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
+        sudo apt-get update -y
+
+        # Install oneAPI
+        sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
+
     - uses: actions/checkout@v3
     - name: Check that versioning is consistent
       # We only need to run this once: arbitrarily use the Linux/CMake build
@@ -69,6 +87,7 @@ jobs:
     - name: Configure (CMake)
       if: "! matrix.platform.autotools"
       run: |
+        ${{ matrix.platform.source_cmd }}
         cmake -S . -B build -G Ninja \
         -DSDL_TESTS=ON \
         -DSDL_WERROR=ON \
@@ -80,11 +99,13 @@ jobs:
     - 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: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         export SDL_TESTS_QUICK=1
         ctest -VV --test-dir build/
         if test "${{ runner.os }}" = "Linux"; then
@@ -102,6 +123,7 @@ jobs:
       if: matrix.platform.autotools
       run: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         rm -fr build-autotools
         mkdir build-autotools
         ./autogen.sh
@@ -133,6 +155,7 @@ jobs:
       if: matrix.platform.autotools
       run: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         parallel="$(getconf _NPROCESSORS_ONLN)"
         make -j"${parallel}" -C build-autotools V=1
         if test "${{ runner.os }}" != "macOS" ; then
@@ -142,6 +165,7 @@ jobs:
       if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
       run: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         curdir="$(pwd)"
         parallel="$(getconf _NPROCESSORS_ONLN)"
         export SDL_TESTS_QUICK=1
@@ -154,6 +178,7 @@ jobs:
       if: matrix.platform.autotools
       run: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         curdir="$(pwd)"
         parallel="$(getconf _NPROCESSORS_ONLN)"
         make -j"${parallel}" -C build-autotools install V=1
@@ -164,16 +189,19 @@ jobs:
         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)
@@ -192,6 +220,7 @@ jobs:
       if: "runner.os == 'Linux' && matrix.platform.autotools"
       run: |
         set -eu
+        ${{ matrix.platform.source_cmd }}
         parallel="$(getconf _NPROCESSORS_ONLN)"
         sudo make -j"${parallel}" -C build-autotools install
         sudo make -j"${parallel}" -C build-autotools/test install