|
| 1 | +name: Build and test |
| 2 | + |
| 3 | +on: [workflow_call, workflow_dispatch] |
| 4 | + |
| 5 | +concurrency: |
| 6 | + group: ${{ github.workflow }}-build-${{ github.ref }} |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +env: |
| 10 | + DISPLAY: ":99" # Display number to use for the X server |
| 11 | + GALLIUM_DRIVER: llvmpipe # Use Mesa 3D software OpenGL renderer |
| 12 | + ANDROID_NDK_VERSION: "26.1.10909125" # Android NDK version to use |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }} |
| 21 | + runs-on: ${{ matrix.platform.os }} |
| 22 | + |
| 23 | + env: |
| 24 | + CMAKE_CXX_COMPILER_LAUNCHER: ccache # Use ccache to cache C++ compiler output |
| 25 | + |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + matrix: |
| 29 | + platform: |
| 30 | + - { name: Windows VS2022 x86, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -GNinja } |
| 31 | + - { name: Windows VS2022 x64, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -GNinja } |
| 32 | + - { name: Windows VS2022 arm64, os: windows-2025, flags: -DSFML_USE_MESA3D=OFF -GNinja -DSFML_BUILD_TEST_SUITE=OFF } |
| 33 | + - { name: Windows VS2022 ClangCL MSBuild, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -T ClangCL } # ninja doesn't support specifying the toolset, so use the ClangCL toolset to test building with MSBuild as well |
| 34 | + - { name: Windows VS2022 OpenGL ES, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -DSFML_OPENGL_ES=ON -GNinja } |
| 35 | + - { name: Windows VS2022 Unity, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -DCMAKE_UNITY_BUILD=ON -GNinja } |
| 36 | + - { name: Windows LLVM/Clang, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja } |
| 37 | + - { name: Windows MinGW, os: windows-2025, flags: -DSFML_USE_MESA3D=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -GNinja } |
| 38 | + - { name: Linux GCC, os: ubuntu-24.04, flags: -GNinja } |
| 39 | + - { name: Linux Clang, os: ubuntu-24.04, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -GNinja , gcovr_options: '--gcov-executable="llvm-cov-$CLANG_VERSION gcov"' } |
| 40 | + - { name: Linux GCC DRM, os: ubuntu-24.04, flags: -DSFML_USE_DRM=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja } |
| 41 | + - { name: Linux GCC OpenGL ES, os: ubuntu-24.04, flags: -DSFML_OPENGL_ES=ON -DSFML_RUN_DISPLAY_TESTS=OFF -GNinja } |
| 42 | + - { name: macOS x64, os: macos-15, flags: -GNinja -DCMAKE_OSX_ARCHITECTURES=x86_64 } |
| 43 | + - { name: macOS x64 Xcode, os: macos-15, flags: -GXcode -DCMAKE_OSX_ARCHITECTURES=x86_64 } |
| 44 | + - { name: macOS arm64, os: macos-15, flags: -GNinja -DSFML_RUN_AUDIO_DEVICE_TESTS=OFF } |
| 45 | + - { name: iOS Xcode, os: macos-15, flags: -DCMAKE_SYSTEM_NAME=iOS -GXcode -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO } |
| 46 | + config: |
| 47 | + - { name: Shared, flags: -DBUILD_SHARED_LIBS=ON } |
| 48 | + - { name: Static, flags: -DBUILD_SHARED_LIBS=OFF } |
| 49 | + type: |
| 50 | + - { name: Release } |
| 51 | + - { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_ENABLE_COVERAGE=ON -DSFML_FATAL_OPENGL_ERRORS=ON } |
| 52 | + |
| 53 | + include: |
| 54 | + - platform: { name: Windows VS2022 x64, os: windows-2025 } |
| 55 | + config: { name: Static with PCH (MSVC), flags: -DSFML_USE_MESA3D=ON -GNinja -DBUILD_SHARED_LIBS=OFF -DSFML_ENABLE_PCH=ON } |
| 56 | + - platform: { name: Linux GCC, os: ubuntu-24.04 } |
| 57 | + config: { name: Static with PCH (GCC), flags: -GNinja -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=OFF -DSFML_ENABLE_PCH=ON } |
| 58 | + - platform: { name: Linux Clang, os: ubuntu-24.04 } |
| 59 | + config: { name: Static with PCH (Clang), flags: -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_SHARED_LIBS=OFF -DSFML_ENABLE_PCH=ON } |
| 60 | + - platform: { name: Linux GCC, os: ubuntu-24.04 } |
| 61 | + config: { name: Bundled Deps Static, flags: -GNinja -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=OFF -DSFML_USE_SYSTEM_DEPS=OFF } |
| 62 | + - platform: { name: Linux GCC, os: ubuntu-24.04 } |
| 63 | + config: { name: Bundled Deps Shared, flags: -GNinja -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=ON -DSFML_USE_SYSTEM_DEPS=OFF } |
| 64 | + - platform: { name: Windows MinGW, os: windows-2025 } |
| 65 | + config: { name: Static Standard Libraries, flags: -GNinja -DSFML_USE_MESA3D=ON -DCMAKE_CXX_COMPILER=g++ -DSFML_USE_STATIC_STD_LIBS=ON } |
| 66 | + - platform: { name: Windows MinGW, os: windows-2025 } |
| 67 | + config: { name: Static with PCH (GCC), flags: -GNinja -DSFML_USE_MESA3D=ON -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=OFF -DSFML_ENABLE_PCH=ON -DSFML_ENABLE_STDLIB_ASSERTIONS=OFF } # disabling stdlib assertions due to false positive |
| 68 | + - platform: { name: macOS, os: macos-14 } |
| 69 | + config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=ON -DBUILD_SHARED_LIBS=ON } |
| 70 | + - platform: { name: macOS , os: macos-14 } |
| 71 | + config: { name: System Deps, flags: -GNinja -DBUILD_SHARED_LIBS=ON -DSFML_USE_SYSTEM_DEPS=ON } |
| 72 | + - platform: { name: Android, os: ubuntu-24.04 } |
| 73 | + config: |
| 74 | + name: x86 (API 21) |
| 75 | + flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DBUILD_SHARED_LIBS=ON -DCMAKE_ANDROID_STL_TYPE=c++_shared -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_RUN_AUDIO_DEVICE_TESTS=OFF |
| 76 | + arch: x86 |
| 77 | + api: 21 |
| 78 | + type: { name: Release } |
| 79 | + - platform: { name: Android, os: ubuntu-24.04 } |
| 80 | + config: |
| 81 | + name: x86_64 (API 24) |
| 82 | + flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=24 -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DBUILD_SHARED_LIBS=ON -DCMAKE_ANDROID_STL_TYPE=c++_shared -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_RUN_AUDIO_DEVICE_TESTS=OFF |
| 83 | + arch: x86_64 |
| 84 | + api: 24 |
| 85 | + type: { name: Release } |
| 86 | + - platform: { name: Android, os: ubuntu-24.04 } |
| 87 | + config: |
| 88 | + name: armeabi-v7a (API 29) |
| 89 | + flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=29 -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DBUILD_SHARED_LIBS=ON -DCMAKE_ANDROID_STL_TYPE=c++_shared |
| 90 | + arch: armeabi-v7a |
| 91 | + api: 29 |
| 92 | + type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_FATAL_OPENGL_ERRORS=ON } |
| 93 | + - platform: { name: Android, os: ubuntu-24.04 } |
| 94 | + config: |
| 95 | + name: arm64-v8a (API 33) |
| 96 | + flags: -GNinja -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=33 -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT -DBUILD_SHARED_LIBS=ON -DCMAKE_ANDROID_STL_TYPE=c++_shared -DSFML_RUN_DISPLAY_TESTS=OFF -DSFML_RUN_AUDIO_DEVICE_TESTS=OFF |
| 97 | + arch: arm64-v8a |
| 98 | + api: 33 |
| 99 | + type: { name: Debug, flags: -DCMAKE_BUILD_TYPE=Debug -DSFML_FATAL_OPENGL_ERRORS=ON } |
| 100 | + exclude: # Shared libraries are not supported on iOS |
| 101 | + - platform: { name: iOS Xcode } |
| 102 | + config: { name: Shared } |
| 103 | + |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout Code |
| 107 | + uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - name: Set Visual Studio Architecture |
| 110 | + if: contains(matrix.platform.name, 'Windows VS') && !contains(matrix.platform.name, 'MSBuild') |
| 111 | + uses: ilammy/msvc-dev-cmd@v1 |
| 112 | + with: |
| 113 | + arch: ${{ contains(matrix.platform.name, 'arm64') && 'amd64_arm64' || contains(matrix.platform.name, 'x86') && 'x86' || 'x64' }} |
| 114 | + |
| 115 | + - name: Get CMake and Ninja |
| 116 | + uses: lukka/get-cmake@latest |
| 117 | + with: |
| 118 | + cmakeVersion: 3.28 |
| 119 | + ninjaVersion: latest |
| 120 | + |
| 121 | + - name: Install Linux Dependencies and Tools |
| 122 | + if: runner.os == 'Linux' |
| 123 | + run: | |
| 124 | + CLANG_VERSION=$(clang++ --version | sed -n 's/.*version \([0-9]\+\)\..*/\1/p') |
| 125 | + echo "CLANG_VERSION=$CLANG_VERSION" >> $GITHUB_ENV |
| 126 | + sudo apt-get update |
| 127 | + sudo apt-get install xorg-dev libharfbuzz-dev libxrandr-dev libxcursor-dev libxi-dev libudev-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libdrm-dev libgbm-dev libmbedtls-dev xvfb fluxbox ccache gcovr ${{ matrix.platform.name == 'Linux Clang' && 'llvm-$CLANG_VERSION' || '' }} |
| 128 | +
|
| 129 | + - name: Install Android Components |
| 130 | + if: matrix.platform.name == 'Android' |
| 131 | + run: | |
| 132 | + echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "build-tools;33.0.2" |
| 133 | + echo "y" | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager --install "ndk;26.1.10909125" |
| 134 | + ANDROID_NDK_ROOT=$(echo $ANDROID_SDK_ROOT/ndk/$ANDROID_NDK_VERSION) |
| 135 | + echo "ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT" >> $GITHUB_ENV |
| 136 | +
|
| 137 | + - name: Install macOS Tools |
| 138 | + if: runner.os == 'macOS' |
| 139 | + run: | |
| 140 | + brew update |
| 141 | + brew install gcovr ccache |
| 142 | +
|
| 143 | + - name: Install macOS System Deps |
| 144 | + if: contains(matrix.config.name, 'System Deps') |
| 145 | + run: brew install flac libvorbis mbedtls |
| 146 | + |
| 147 | + # In addition to installing a known working version of CCache, this action also takes care of saving and restoring the cache for us |
| 148 | + # Additionally it outputs information at the end of each job that helps us to verify if the cache is working properly |
| 149 | + - name: Setup CCache |
| 150 | + uses: hendrikmuhs/[email protected] |
| 151 | + with: |
| 152 | + verbose: 2 |
| 153 | + key: ${{ matrix.platform.name }}-${{ matrix.config.name }}-${{ matrix.type.name }} |
| 154 | + |
| 155 | + - name: Install Gcovr for MinGW |
| 156 | + if: matrix.type.name == 'Debug' && contains(matrix.platform.name, 'MinGW') |
| 157 | + |
| 158 | + with: |
| 159 | + packages: gcovr |
| 160 | + |
| 161 | + - name: Install OpenCppCoverage |
| 162 | + uses: nick-fields/retry@v3 |
| 163 | + if: matrix.type.name == 'Debug' && runner.os == 'Windows' |
| 164 | + with: |
| 165 | + max_attempts: 10 |
| 166 | + timeout_minutes: 3 |
| 167 | + command: choco install OpenCppCoverage -y |
| 168 | + |
| 169 | + - name: Cache MinGW |
| 170 | + if: matrix.platform.name == 'Windows MinGW' |
| 171 | + id: mingw-cache |
| 172 | + uses: actions/cache@v4 |
| 173 | + with: |
| 174 | + path: "C:\\Program Files\\mingw64" |
| 175 | + key: winlibs-x86_64-posix-seh-gcc-14.2.0-llvm-19.1.7-mingw-w64msvcrt-12.0.0-r3 |
| 176 | + |
| 177 | + - name: Install MinGW |
| 178 | + if: matrix.platform.name == 'Windows MinGW' && steps.mingw-cache.outputs.cache-hit != 'true' |
| 179 | + run: | |
| 180 | + curl -Lo mingw64.zip https://github.com/brechtsanders/winlibs_mingw/releases/download/14.2.0posix-19.1.7-12.0.0-msvcrt-r3/winlibs-x86_64-posix-seh-gcc-14.2.0-llvm-19.1.7-mingw-w64msvcrt-12.0.0-r3.zip |
| 181 | + unzip -qq -d "C:\Program Files" mingw64.zip |
| 182 | +
|
| 183 | + - name: Add OpenCppCoverage and MinGW to PATH and remove MinGW-supplied CCache & CMake |
| 184 | + if: runner.os == 'Windows' |
| 185 | + run: | |
| 186 | + echo "C:\Program Files\OpenCppCoverage" >> $GITHUB_PATH |
| 187 | + echo "C:\Program Files\mingw64\bin" >> $GITHUB_PATH |
| 188 | + rm -f "C:\Program Files\mingw64\bin\ccache.exe" |
| 189 | + echo "Using $(which ccache)" |
| 190 | + ccache --version |
| 191 | + rm -f "C:\Program Files\mingw64\bin\cmake.exe" |
| 192 | + echo "Using $(which cmake)" |
| 193 | + cmake --version |
| 194 | +
|
| 195 | + - name: Configure CMake |
| 196 | + run: cmake --preset dev -DCMAKE_VERBOSE_MAKEFILE=ON ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}} |
| 197 | + |
| 198 | + - name: Build |
| 199 | + run: cmake --build build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --target install |
| 200 | + |
| 201 | + - name: Build Android example |
| 202 | + if: matrix.platform.name == 'Android' |
| 203 | + run: examples/android/gradlew ${{ matrix.type.name == 'Debug' && 'assembleDebug' || 'assembleRelease' }} -p examples/android -P ARCH_ABI=${{matrix.config.arch}} -P MIN_SDK=${{matrix.config.api}} |
| 204 | + |
| 205 | + - name: Prepare Test |
| 206 | + run: | |
| 207 | + set -e |
| 208 | + # Start up Xvfb and fluxbox to host display tests |
| 209 | + if [ "${{ runner.os }}" == "Linux" ]; then |
| 210 | + Xvfb $DISPLAY -screen 0 1920x1080x24 & |
| 211 | + sleep 5 |
| 212 | + fluxbox > /dev/null 2>&1 & |
| 213 | + sleep 5 |
| 214 | + fi |
| 215 | + # Make sure the build/bin directory exists so that the find command does not fail if no executables are built |
| 216 | + mkdir -p build/bin |
| 217 | + # Make use of a test to print OpenGL vendor/renderer/version info to the console |
| 218 | + find build/bin -name test-sfml-window -or -name test-sfml-window.exe -exec sh -c "{} *sf::Context* --section=\"Version String\" --success | grep OpenGL" \; |
| 219 | +
|
| 220 | + - name: Test (Windows) |
| 221 | + if: runner.os == 'Windows' && !contains(matrix.platform.name, 'MinGW') && !contains(matrix.platform.name, 'arm64') |
| 222 | + run: | |
| 223 | + cmake --build build --target runtests --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} |
| 224 | +
|
| 225 | + - name: Test (Linux/macOS/MinGW) |
| 226 | + if: (runner.os != 'Windows' || contains(matrix.platform.name, 'MinGW')) && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android') |
| 227 | + run: | |
| 228 | + ctest --test-dir build --output-on-failure -C ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} --repeat until-pass:3 |
| 229 | + # Run gcovr to extract coverage information from the test run |
| 230 | + if [ "${{ matrix.type.name }}" == "Debug" ]; then |
| 231 | + gcovr -r $GITHUB_WORKSPACE -x build/coverage.out -s -f 'src/SFML/.*' -f 'include/SFML/.*' ${{ matrix.platform.gcovr_options }} $GITHUB_WORKSPACE |
| 232 | + fi |
| 233 | + ls build/ |
| 234 | +
|
| 235 | + - name: Upload Coverage Report to Coveralls |
| 236 | + if: matrix.type.name == 'Debug' && github.repository == 'SFML/SFML' && !contains(matrix.platform.name, 'iOS') && !contains(matrix.platform.name, 'Android') && !contains(matrix.platform.name, 'arm64') # Disable upload in forks |
| 237 | + uses: coverallsapp/github-action@v2 |
| 238 | + with: |
| 239 | + file: ./build/coverage.out |
| 240 | + flag-name: ${{ matrix.platform.name }} ${{ matrix.config.name }} ${{ matrix.type.name }} |
| 241 | + parallel: true |
| 242 | + allow-empty: true |
| 243 | + base-path: ${{ github.workspace }} |
| 244 | + |
| 245 | + - name: Test Install Interface |
| 246 | + if: matrix.platform.name != 'Android' |
| 247 | + run: | |
| 248 | + cmake -S test/install -B test/install/build -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/build/install -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} ${{matrix.platform.flags}} ${{matrix.config.flags}} ${{matrix.type.flags}} |
| 249 | + cmake --build test/install/build --config ${{ matrix.type.name == 'Debug' && 'Debug' || 'Release' }} |
| 250 | +
|
| 251 | + coverage: |
| 252 | + name: Finalize Coverage Upload |
| 253 | + needs: build |
| 254 | + runs-on: ubuntu-24.04 |
| 255 | + if: github.repository == 'SFML/SFML' # Disable upload in forks |
| 256 | + |
| 257 | + steps: |
| 258 | + - name: Coveralls Finished |
| 259 | + uses: coverallsapp/github-action@v2 |
| 260 | + with: |
| 261 | + parallel-finished: true |
0 commit comments