# https://docs.github.com/en/actions name: build_test on: push: branches: [ main ] pull_request: branches: [ main ] workflow_dispatch: env: BUILD_TYPE: Debug jobs: test: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} timeout-minutes: ${{ matrix.timeout || 10 }} if: github.event_name != 'pull_request' || github.event.pull_request.draft == false strategy: fail-fast: false matrix: include: - name: ubuntu-gcc os: ubuntu-latest test: ./bin/test # Clang jobs pin the image because each Ubuntu image ships a different set of clang versions - name: ubuntu-clang os: ubuntu-26.04 args: '-DCMAKE_CXX_COMPILER=clang++-20 -DCMAKE_C_COMPILER=clang-20 -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread"' test: ./bin/test # Runner speed varies about 3x by region and MSan at -O0 can exceed the timeout on the slow ones. # -O1 is the level MSan recommends and Debug keeps asserts. Line buffering shows per test timing. - name: ubuntu-clang-msan os: ubuntu-26.04 timeout: 10 args: '-DCMAKE_CXX_COMPILER=clang++-20 -DCMAKE_C_COMPILER=clang-20 -DCMAKE_C_FLAGS="-O1 -fsanitize=memory -fsanitize-memory-track-origins=1 -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-O1 -fsanitize=memory -fsanitize-memory-track-origins=1 -fno-omit-frame-pointer" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=memory"' test: lscpu | grep 'Model name'; nproc; stdbuf -oL ./bin/test msan-options: abort_on_error=1:halt_on_error=1 - name: macos os: macos-latest args: -DBOX3D_SANITIZE=ON test: ./bin/test - name: windows os: windows-latest msvc: true args: -DBOX3D_SANITIZE=ON test: ./bin/Debug/test - name: windows-clang-cl os: windows-latest msvc: true args: -T ClangCL test: ./bin/Debug/test - name: windows-arm64 os: windows-11-arm msvc: true msvc-arch: arm64 args: -A arm64 -DBOX3D_DISABLE_SIMD=TRUE -DBOX3D_SANITIZE=ON test: ./bin/Debug/test # Optimized runs. The determinism golden hashes are otherwise only checked at -O0, # and -O2 is where a value changing float transform would first show up. - name: windows-relwithdebinfo os: windows-latest msvc: true config: RelWithDebInfo test: ./bin/RelWithDebInfo/test - name: macos-relwithdebinfo os: macos-latest config: RelWithDebInfo test: ./bin/test - name: ubuntu-gcc-double os: ubuntu-latest args: -DBOX3D_DOUBLE_PRECISION=ON test: ./bin/test - name: windows-double os: windows-latest msvc: true args: -DBOX3D_DOUBLE_PRECISION=ON -DBOX3D_SANITIZE=ON test: ./bin/Debug/test steps: - uses: actions/checkout@v6 - name: Setup MSVC dev command prompt if: ${{ matrix.msvc }} uses: TheMrMilchmann/setup-msvc-dev@v4 with: arch: ${{ matrix['msvc-arch'] || 'x64' }} - name: Configure CMake run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.config || env.BUILD_TYPE }} -DBOX3D_SAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DBOX3D_VALIDATE=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON ${{ matrix.args }} - name: Build run: cmake --build ${{github.workspace}}/build --config ${{ matrix.config || env.BUILD_TYPE }} --parallel - name: Test working-directory: ${{github.workspace}}/build env: MSAN_OPTIONS: ${{ matrix['msan-options'] || '' }} UBSAN_OPTIONS: print_stacktrace=1 run: ${{ matrix.test }} # mingw needs some extra setup so keeping it separate from the matrix. # Debug -O0 copies whole structs and hid the b3SurfaceMaterial padding dedup bug. # RelWithDebInfo tests -O2 codegen while B3_ENABLE_ASSERT keeps asserts alive, # heavy validation stays Debug only. build-windows-mingw: name: windows-mingw runs-on: windows-latest timeout-minutes: 10 if: github.event_name != 'pull_request' || github.event.pull_request.draft == false defaults: run: shell: msys2 {0} steps: - uses: actions/checkout@v6 - name: Setup MSYS2 UCRT64 uses: msys2/setup-msys2@v2 with: msystem: UCRT64 update: true install: >- mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja - name: Configure CMake run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBOX3D_SAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DBOX3D_VALIDATE=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON - name: Build run: cmake --build build --config RelWithDebInfo --parallel - name: Test working-directory: build run: ./bin/test # Build-only: running the wasm test needs a node + pthread/SharedArrayBuffer harness. # This still catches compile breaks in the box3d library and the test target. emscripten: name: emscripten runs-on: ubuntu-latest timeout-minutes: 10 if: github.event_name != 'pull_request' || github.event.pull_request.draft == false steps: - uses: actions/checkout@v6 - uses: mymindstorm/setup-emsdk@v14 - name: Configure CMake run: emcmake cmake -B build -DCMAKE_BUILD_TYPE=Debug -DBOX3D_SAMPLES=OFF -DBUILD_SHARED_LIBS=OFF -DBOX3D_VALIDATE=ON - name: Build run: cmake --build build --config Debug --parallel samples: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} timeout-minutes: 10 if: github.event_name != 'pull_request' || github.event.pull_request.draft == false strategy: fail-fast: false matrix: include: - name: samples-ubuntu-gcc-static os: ubuntu-latest linux-deps: true args: -DBUILD_SHARED_LIBS=OFF - name: samples-macos-static os: macos-latest args: -DBUILD_SHARED_LIBS=OFF - name: samples-macos-dynamic os: macos-latest args: -DBUILD_SHARED_LIBS=ON - name: samples-windows-static os: windows-latest msvc: true args: -DBUILD_SHARED_LIBS=OFF - name: samples-windows-double os: windows-latest msvc: true args: -DBOX3D_DOUBLE_PRECISION=ON -DBUILD_SHARED_LIBS=OFF - name: samples-windows-dynamic os: windows-latest msvc: true args: -DBUILD_SHARED_LIBS=ON steps: - uses: actions/checkout@v6 - name: Setup MSVC dev command prompt if: ${{ matrix.msvc }} uses: TheMrMilchmann/setup-msvc-dev@v4 with: arch: x64 # sokol_app needs X11/Xi/Xcursor + GL, the file dialog needs GTK3. - name: Install Linux sample dependencies if: ${{ matrix['linux-deps'] }} run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libxi-dev libxcursor-dev libgtk-3-dev - name: Configure CMake run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBOX3D_SAMPLES=ON -DBOX3D_UNIT_TESTS=OFF ${{ matrix.args }} - name: Build run: cmake --build ${{github.workspace}}/build --config Release --parallel