diff --git a/.github/scripts/build-matrix.ps1 b/.github/scripts/build-matrix.ps1 new file mode 100644 index 0000000..3ef1b3f --- /dev/null +++ b/.github/scripts/build-matrix.ps1 @@ -0,0 +1,88 @@ +#!/usr/bin/env pwsh +$ErrorActionPreference = "Stop" + +# Fail early if required environment variables are missing +if (-not $env:COMPILERS) { Write-Host "โŒ COMPILERS is required"; exit 1 } +if (-not $env:STANDARDS) { Write-Host "โŒ STANDARDS is required"; exit 1 } +if (-not $env:MODES) { Write-Host "โŒ MODES is required"; exit 1 } + +$Compilers = $env:COMPILERS.Split(" ") +$Standards = $env:STANDARDS.Split(" ") +$Modes = $env:MODES.Split(" ") + +Write-Host "๐Ÿ—๏ธ Running build matrix" +Write-Host "Compilers: $($Compilers -join ', ')" +Write-Host "Standards: $($Standards -join ', ')" +Write-Host "Modes: $($Modes -join ', ')" +Write-Host "" + +# Array to track failures +$Failures = @() + +foreach ($Compiler in $Compilers) { + foreach ($Standard in $Standards) { + foreach ($Mode in $Modes) { + Write-Host "::group::$Compiler ($Standard, $Mode)" + $BuildDir = "build-$Compiler-$Standard-$Mode" + cmake -E make_directory $BuildDir + Push-Location $BuildDir + + # CMake configure + try { + cmake $env:GITHUB_WORKSPACE ` + -DCMAKE_BUILD_TYPE=$Mode ` + -DCMAKE_CXX_FLAGS="-std=$Standard" ` + -DCMAKE_CXX_COMPILER=$Compiler + } catch { + $Failures += "$Compiler $Standard $Mode (cmake configure)" + Pop-Location + Write-Host "::endgroup::" + continue + } + + # Build + try { + cmake --build . --config $Mode + } catch { + $Failures += "$Compiler $Standard $Mode (build)" + Pop-Location + Write-Host "::endgroup::" + continue + } + + # Test executable path + $TestExe = Join-Path $PWD "Tests.exe" + if (-not (Test-Path $TestExe)) { + $TestExe = Join-Path $PWD $Mode "Tests.exe" + } + + # Run tests + if (Test-Path $TestExe) { + try { + & $TestExe + } catch { + $Failures += "$Compiler $Standard $Mode (tests)" + } + } else { + Write-Host "โš ๏ธ No test binary found in $BuildDir" + $Failures += "$Compiler $Standard $Mode (no test binary)" + } + + Pop-Location + Write-Host "::endgroup::" + } + } +} + +# Summary +Write-Host "" +Write-Host "๐Ÿงพ Build Matrix Summary:" +if ($Failures.Count -eq 0) { + Write-Host "โœ… All builds and tests passed!" +} else { + Write-Host "โŒ $($Failures.Count) failed combination(s):" + foreach ($fail in $Failures) { + Write-Host " - $fail" + } + exit 1 +} diff --git a/.github/scripts/build-matrix.sh b/.github/scripts/build-matrix.sh new file mode 100644 index 0000000..fb53fec --- /dev/null +++ b/.github/scripts/build-matrix.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Fail early if required environment variables are missing +if [ -z "${COMPILERS:-}" ]; then + echo "โŒ COMPILERS is required" + exit 1 +fi + +if [ -z "${STANDARDS:-}" ]; then + echo "โŒ STANDARDS is required" + exit 1 +fi + +if [ -z "${MODES:-}" ]; then + echo "โŒ MODES is required" + exit 1 +fi + +# Convert space-separated strings into arrays +COMPILERS=($COMPILERS) +STANDARDS=($STANDARDS) +MODES=($MODES) + +echo "๐Ÿ—๏ธ Running build matrix" +echo "Compilers: ${COMPILERS[*]}" +echo "Standards: ${STANDARDS[*]}" +echo "Modes: ${MODES[*]}" +echo + +# Track failed combinations +failures=() + +for COMPILER in "${COMPILERS[@]}"; do + for STANDARD in "${STANDARDS[@]}"; do + for MODE in "${MODES[@]}"; do + echo "::group::$COMPILER ($STANDARD, $MODE)" + BUILD_DIR="build-${COMPILER}-${STANDARD}-${MODE}" + + cmake -E make_directory "$BUILD_DIR" + cd "$BUILD_DIR" + + if ! cmake "$GITHUB_WORKSPACE" \ + -DCMAKE_BUILD_TYPE="$MODE" \ + -DCMAKE_CXX_FLAGS="-std=$STANDARD" \ + -DCMAKE_CXX_COMPILER="$COMPILER"; then + failures+=("$COMPILER $STANDARD $MODE (cmake configure)") + cd .. + echo "::endgroup::" + continue + fi + + if ! cmake --build . --config "$MODE"; then + failures+=("$COMPILER $STANDARD $MODE (build)") + cd .. + echo "::endgroup::" + continue + fi + + if ! ./Tests; then + failures+=("$COMPILER $STANDARD $MODE (tests)") + cd .. + echo "::endgroup::" + continue + fi + + cd .. + echo "::endgroup::" + done + done +done + +# Summary +echo +echo "๐Ÿงพ Summary:" +if [ ${#failures[@]} -eq 0 ]; then + echo "โœ… All builds and tests passed!" +else + echo "โŒ ${#failures[@]} failed combination(s):" + for fail in "${failures[@]}"; do + echo " - $fail" + done + exit 1 +fi diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f324a8f..24e8387 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,108 +4,95 @@ permissions: on: push: - branches: - - main + branches: [ main ] pull_request: - branches: - - main + branches: [ main ] jobs: - ubuntu-latest: - runs-on: ubuntu-latest - strategy: - matrix: - compiler: [ g++-11, g++-12, clang++-14, clang++-15 ] - standard: [ c++14, c++17, c++20 ] - mode: [ Debug, Release ] + ubuntu-noble: + name: "Ubuntu Noble" + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - name: Install Dependencies - run: sudo apt-get install g++-11 g++-12 clang-14 clang-15 -y + - name: "Make Script Executable" + run: chmod +x .github/scripts/build-matrix.sh - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/Atomic/build + - uses: actions/cache@v4 + with: + path: /var/cache/apt/archives + key: apt-cache-ubuntu-noble-latest - - name: Build - shell: bash - working-directory: ${{runner.workspace}}/Atomic/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_FLAGS=-std=${{ matrix.standard }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler}}; cmake --build . --config ${{ matrix.mode }} + - run: sudo apt-get install -y g++-11 g++-12 clang-14 clang-15 + - name: Run Build Matrix + run: | + COMPILERS="g++-11 g++-12 clang++-14 clang++-15" \ + STANDARDS="c++14 c++17 c++20" \ + MODES="Debug Release" \ + .github/scripts/build-matrix.sh - - name: Run Tests - working-directory: ${{runner.workspace}}/Atomic/build - shell: bash - run: ./Tests - ubuntu-jammy: + name: "Ubuntu Jammy" runs-on: ubuntu-22.04 - strategy: - matrix: - compiler: [ g++-9, g++-10, clang++-11, clang++-12, clang++-13, clang++-14, clang++-15 ] - standard: [ c++14, c++17, c++2a ] - mode: [ Debug, Release ] steps: - uses: actions/checkout@v4 - - name: Install Dependencies - run: sudo apt-get install g++-9 g++-10 clang-11 clang-12 clang-13 clang-14 clang-15 -y + - name: "Make Script Executable" + run: chmod +x .github/scripts/build-matrix.sh - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/Atomic/build + - uses: actions/cache@v4 + with: + path: /var/cache/apt/archives + key: apt-cache-ubuntu-jammy-latest - - name: Build - shell: bash - working-directory: ${{runner.workspace}}/Atomic/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_FLAGS=-std=${{ matrix.standard }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler}}; cmake --build . --config ${{ matrix.mode }} - - - name: Run Tests - working-directory: ${{runner.workspace}}/Atomic/build - shell: bash - run: ./Tests + - run: sudo apt-get install -y g++-10 clang-11 clang-12 clang-13 clang-14 clang-15 + - name: Run Build Matrix + run: | + COMPILERS="g++-10 clang++-11 clang++-12 clang++-13 clang++-14 clang++-15" \ + STANDARDS="c++14 c++17 c++20" \ + MODES="Debug Release" \ + .github/scripts/build-matrix.sh macos: - strategy: - matrix: - compiler: [ c++, g++-13, g++-14 ] - standard: [ c++14, c++17, c++20 ] - mode: [ Debug, Release ] - os: [ macos-15, macos-14 ] - runs-on: ${{ matrix.os }} + name: "MacOS 15" + runs-on: macos-15 steps: - uses: actions/checkout@v4 - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}/Atomic/build - - - name: Build - shell: bash - working-directory: ${{runner.workspace}}/Atomic/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_FLAGS=-std=${{ matrix.standard }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler}}; cmake --build . --config ${{ matrix.mode }} - - - name: Run Tests - working-directory: ${{runner.workspace}}/Atomic/build - shell: bash - run: ./Tests - - windows: - strategy: - matrix: - compiler: [ clang, gcc, msvc-14.0, msvc-14.2 ] - standard: [ c++14, c++17, c++20, c++23 ] - mode: [ Debug, Release ] - os: [ windows-2025, windows-2022 ] - runs-on: ${{ matrix.os }} + - name: "Make Script Executable" + run: chmod +x .github/scripts/build-matrix.sh + + - name: Run Build Matrix + run: | + COMPILERS="c++ g++-13 g++-14" \ + STANDARDS="c++14 c++17 c++20" \ + MODES="Debug Release" \ + .github/scripts/build-matrix.sh + + windows-2022: + name: "Windows 2022" + runs-on: windows-2022 steps: - uses: actions/checkout@v4 - - name: Create Build Environment - run: cmake -E make_directory ${{runner.workspace}}\build - - - name: Build - shell: bash - working-directory: ${{runner.workspace}}\build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.mode }} -DCMAKE_CXX_FLAGS=-std=${{ matrix.standard }} -DCMAKE_CXX_COMPILER=${{ matrix.compiler}}; cmake --build . --config ${{ matrix.mode }} + - name: Run Build Matrix + shell: pwsh + run: | + $env:COMPILERS = "clang gcc msvc-14.0 msvc-14.2" + $env:STANDARDS = "c++14 c++17 c++20 c++23" + $env:MODES = "Debug Release" + .github\scripts\build-matrix.ps1 + + windows-2025: + name: "Windows 2025" + runs-on: windows-2025 + steps: + - uses: actions/checkout@v4 - - name: Run Tests - working-directory: ${{runner.workspace}}\build\${{ matrix.mode }} - run: ./Tests.exe \ No newline at end of file + - name: Run Build Matrix + shell: pwsh + run: | + $env:COMPILERS = "clang gcc msvc-14.0 msvc-14.2" + $env:STANDARDS = "c++14 c++17 c++20 c++23" + $env:MODES = "Debug Release" + .github\scripts\build-matrix.ps1 \ No newline at end of file