Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.
Merged
88 changes: 88 additions & 0 deletions .github/scripts/build-matrix.ps1
Original file line number Diff line number Diff line change
@@ -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
}
84 changes: 84 additions & 0 deletions .github/scripts/build-matrix.sh
Original file line number Diff line number Diff line change
@@ -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
147 changes: 67 additions & 80 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
Loading