| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- # CI workflow for building and testing across multiple platforms
- name: CI
- on:
- push:
- branches: [ "master" ]
- paths:
- - 'src/**'
- - 'include/**'
- - 'scripts/**'
- - 'shaders/**'
- - 'CMakeLists.txt'
- - '**/CMakeLists.txt'
- - '.github/workflows/**'
- pull_request:
- branches: [ "master" ]
- paths:
- - 'src/**'
- - 'include/**'
- - 'scripts/**'
- - 'shaders/**'
- - 'CMakeLists.txt'
- - '**/CMakeLists.txt'
- - '.github/workflows/**'
- workflow_dispatch: # Manual trigger from GitHub UI
- jobs:
- build:
- runs-on: ${{ matrix.os }}
- strategy:
- fail-fast: false
- # Build matrix: Windows (MSVC + MinGW), Linux (GCC + Clang)
- matrix:
- os: [ubuntu-latest, windows-latest]
- build_type: [Release]
- c_compiler: [gcc, clang, cl]
- include:
- - os: windows-latest
- c_compiler: cl
- cpp_compiler: cl
- - os: windows-latest
- c_compiler: gcc
- cpp_compiler: g++
- - os: ubuntu-latest
- c_compiler: gcc
- cpp_compiler: g++
- - os: ubuntu-latest
- c_compiler: clang
- cpp_compiler: clang++
- exclude:
- - os: windows-latest
- c_compiler: clang
- - os: ubuntu-latest
- c_compiler: cl
- steps:
- - name: Checkout code with submodules
- uses: actions/checkout@v4
- with:
- submodules: 'recursive'
- - name: Setup MinGW-w64
- if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
- uses: msys2/setup-msys2@v2
- with:
- msystem: MINGW64
- update: true
- install: >-
- mingw-w64-x86_64-gcc
- mingw-w64-x86_64-cmake
- mingw-w64-x86_64-ninja
- mingw-w64-x86_64-python
- - name: Install dependencies for Ubuntu
- if: runner.os == 'Linux'
- run: |
- sudo apt update
- sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libwayland-bin libxkbcommon-dev
- # Cache CMake metadata to speed up builds
- - name: Cache dependencies
- uses: actions/cache@v4
- with:
- path: |
- ${{ github.workspace }}/build/CMakeFiles
- key: ${{ runner.os }}-${{ matrix.c_compiler }}-deps-${{ hashFiles('**/CMakeLists.txt') }}
- restore-keys: |
- ${{ runner.os }}-${{ matrix.c_compiler }}-deps-
- - name: Set reusable strings
- id: strings
- shell: bash
- run: |
- echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- - name: Configure CMake (MinGW)
- if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
- shell: msys2 {0}
- run: |
- cmake -B build \
- -G "Ninja" \
- -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \
- -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
- -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
- -DR3D_RAYLIB_VENDORED=ON \
- -DR3D_ASSIMP_VENDORED=ON \
- -DR3D_BUILD_EXAMPLES=ON \
- -DR3D_BUILD_DOCS=OFF \
- -S .
- - name: Configure CMake (Non-MinGW)
- if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
- run: >
- cmake -B ${{ steps.strings.outputs.build-output-dir }}
- -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
- -DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
- -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- -DR3D_RAYLIB_VENDORED=ON
- -DR3D_ASSIMP_VENDORED=ON
- -DR3D_BUILD_EXAMPLES=ON
- -DR3D_BUILD_DOCS=OFF
- -S ${{ github.workspace }}
- - name: Build (MinGW)
- if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
- shell: msys2 {0}
- run: cmake --build build --config ${{ matrix.build_type }} --parallel
- - name: Build (Non-MinGW)
- if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
- run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel
- - name: Test (MinGW)
- if: runner.os == 'Windows' && matrix.c_compiler == 'gcc'
- shell: msys2 {0}
- working-directory: build
- run: ctest --build-config ${{ matrix.build_type }}
- - name: Test (Non-MinGW)
- if: runner.os != 'Windows' || matrix.c_compiler != 'gcc'
- working-directory: ${{ steps.strings.outputs.build-output-dir }}
- run: ctest --build-config ${{ matrix.build_type }}
- - name: Upload build artifacts
- uses: actions/upload-artifact@v4
- with:
- name: r3d-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.c_compiler }}
- path: |
- ${{ steps.strings.outputs.build-output-dir }}/**/*.dll
- ${{ steps.strings.outputs.build-output-dir }}/**/*.so
- ${{ steps.strings.outputs.build-output-dir }}/**/*.a
- ${{ steps.strings.outputs.build-output-dir }}/**/*.lib
- ${{ steps.strings.outputs.build-output-dir }}/**/*.dylib
- retention-days: 14
|