Update Github Actions #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push or pull request events but only for the main branch | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| cross-platform-build: | |
| name: Build (${{ matrix.os }}, ${{ matrix.build-type }}) | |
| strategy: | |
| matrix: | |
| # Order: Most important platforms first (Ubuntu for CI, then Windows/macOS) | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| # Order: Release first (production), then debug (development), then debug+symbols | |
| build-type: [release, debug] | |
| fail-fast: false # Don't cancel other jobs if one fails, to get full test coverage | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up build environment | |
| run: | | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| choco install mingw -y | |
| elif [ "$RUNNER_OS" == "Linux" ]; then | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential --no-install-recommends | |
| sudo apt-get install pkg-config libglfw3-dev libgl1-mesa-dev xorg-dev -y | |
| elif [ "$RUNNER_OS" == "macOS" ]; then | |
| brew update | |
| fi | |
| shell: bash | |
| - name: Cache build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| examples/task-manager/build/ | |
| examples/donut-basic/build/ | |
| key: ${{ runner.os }}-build-${{ matrix.build-type }}-${{ hashFiles('examples/task-manager/makefile', 'examples/task-manager/**/*.cpp', 'examples/donut-basic/makefile', 'examples/donut-basic/**/*.cpp') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ matrix.build-type }}- | |
| - name: Build task-manager example (${{ matrix.build-type }}) | |
| run: | | |
| cd examples/task-manager | |
| if [ "$RUNNER_OS" = "macOS" ]; then | |
| make BUILD_TYPE=${{ matrix.build-type }} CXX=clang++ clean all -j$(nproc 2>/dev/null || echo 4) | |
| else | |
| make BUILD_TYPE=${{ matrix.build-type }} clean all -j$(nproc 2>/dev/null || echo 4) | |
| fi | |
| shell: bash | |
| - name: Build donut-basic example (${{ matrix.build-type }}) | |
| run: | | |
| cd examples/donut-basic | |
| if [ "$RUNNER_OS" = "macOS" ]; then | |
| make BUILD_TYPE=${{ matrix.build-type }} CXX=clang++ clean all -j$(nproc 2>/dev/null || echo 4) | |
| else | |
| make BUILD_TYPE=${{ matrix.build-type }} clean all -j$(nproc 2>/dev/null || echo 4) | |
| fi | |
| shell: bash | |
| - name: Generate assembly and disassembly | |
| run: | | |
| cd examples/task-manager | |
| if [ "$RUNNER_OS" = "macOS" ]; then | |
| make CXX=clang++ asm disassemble || true | |
| else | |
| make asm disassemble || true | |
| fi | |
| shell: bash | |
| - name: Build task-manager with static analysis | |
| if: matrix.build-type == 'debug' && runner.os == 'Linux' | |
| run: | | |
| cd examples/task-manager | |
| if [ "$RUNNER_OS" = "macOS" ]; then | |
| make clean CXX=clang++ analyze | |
| else | |
| make clean analyze | |
| fi | |
| shell: bash | |
| - name: Check compilation | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cd examples/task-manager | |
| make BUILD_TYPE=debug WARN_LEVEL=normal clean all 2>&1 | tee build.log | |
| # Count actual compilation errors (not warnings) | |
| ERROR_COUNT=$(grep -c "error:" build.log || true) | |
| if [ "$ERROR_COUNT" -gt 0 ]; then | |
| echo "❌ Compilation errors found:" | |
| grep "error:" build.log | |
| exit 1 | |
| else | |
| echo "✅ Build successful (warnings are allowed in CI)" | |
| fi | |
| shell: bash | |
| integration-tests: | |
| name: Integration Tests | |
| needs: cross-platform-build # Ensure this runs after the build job | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest] # Run tests on Ubuntu for CI, can add Windows/macOS later | |
| fail-fast: false # Don't cancel other jobs if one fails, to get full test coverage | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up build environment | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential --no-install-recommends | |
| - name: Build task-manager example | |
| run: | | |
| cd examples/task-manager | |
| make BUILD_TYPE=release clean all asm disassemble -j$(nproc) | |
| - name: Build donut-basic example | |
| run: | | |
| cd examples/donut-basic | |
| make BUILD_TYPE=release clean all -j$(nproc) | |
| - name: Verify executables | |
| run: | | |
| [ -f "examples/task-manager/build/app/tm" ] || { echo "task-manager executable not found!"; exit 1; } | |
| echo "✓ task-manager executable built successfully" | |
| [ -f "examples/donut-basic/build/app/donut" ] || { echo "donut-basic executable not found!"; exit 1; } | |
| echo "✓ donut-basic executable built successfully" |