Cross-Platform Build #21
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: Cross-Platform Build | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
schedule: | |
- cron: "0 2 * * 5" # Run every Friday at 2:00 UTC | |
workflow_dispatch: | |
jobs: | |
build-matrix: | |
name: Build with ${{ matrix.compiler.name }} | |
runs-on: ubuntu-${{ vars.UBUNTU_VERSION }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: ["ubuntu-${{ vars.UBUNTU_VERSION }}"] | |
compiler: | |
- { | |
name: "gcc", | |
cc: "gcc", | |
cxx: "g++", | |
version: "12", | |
install_macos: "gcc@12", | |
install_ubuntu: "g++-12", | |
} | |
- { | |
name: "clang", | |
cc: "clang", | |
cxx: "clang++", | |
version: "15", | |
install_macos: "llvm@15", | |
install_ubuntu: "clang-15 libc++-15-dev libc++abi-15-dev", | |
} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Setup compilers | |
- name: Setup GCC | |
if: matrix.compiler.name == 'gcc' | |
run: | | |
sudo apt update | |
sudo apt install -y ${{ matrix.compiler.install_ubuntu }} | |
echo "CC=gcc-${{ matrix.compiler.version }}" >> $GITHUB_ENV | |
echo "CXX=g++-${{ matrix.compiler.version }}" >> $GITHUB_ENV | |
- name: Setup Clang | |
if: matrix.compiler.name == 'clang' | |
run: | | |
sudo apt update | |
sudo apt install -y ${{ matrix.compiler.install_ubuntu }} | |
echo "CC=clang-${{ matrix.compiler.version }}" >> $GITHUB_ENV | |
echo "CXX=clang++-${{ matrix.compiler.version }}" >> $GITHUB_ENV | |
# Install dependencies | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y cmake build-essential libboost-all-dev | |
# Configure and build | |
- name: Configure CMake | |
run: | | |
mkdir -p build | |
cd build | |
cmake .. -DCMAKE_BUILD_TYPE=Release | |
- name: Build | |
run: | | |
cd build | |
cmake --build . --config Release | |
- name: Run tests | |
run: | | |
cd build | |
ctest -C Release --output-on-failure | |
continue-on-error: true | |
# Create compiler-specific report | |
- name: Generate compiler report | |
run: | | |
echo "# Build Report for ubuntu-${{ vars.UBUNTU_VERSION }} with ${{ matrix.compiler.name }}" > platform-report.md | |
echo "" >> platform-report.md | |
echo "## Build Environment" >> platform-report.md | |
echo "" >> platform-report.md | |
echo "- OS: ubuntu-${{ vars.UBUNTU_VERSION }}" >> platform-report.md | |
echo "- Compiler: ${{ matrix.compiler.name }} ${{ matrix.compiler.version }}" >> platform-report.md | |
echo "- CC: $CC" >> platform-report.md | |
echo "- CXX: $CXX" >> platform-report.md | |
$CC --version >> compiler-version.txt | |
echo '```' >> platform-report.md | |
cat compiler-version.txt >> platform-report.md | |
echo '```' >> platform-report.md | |
echo "" >> platform-report.md | |
echo "## Build Status" >> platform-report.md | |
if [ -d "build" ]; then | |
echo "- Build directory exists and was created successfully." >> platform-report.md | |
if [ -f "build/thales" ]; then | |
echo "- Executable was built successfully." >> platform-report.md | |
else | |
echo "- Executable was not found." >> platform-report.md | |
fi | |
else | |
echo "- Build directory does not exist." >> platform-report.md | |
fi | |
cat platform-report.md | |
shell: bash | |
- name: Upload platform report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: platform-report-ubuntu-${{ vars.UBUNTU_VERSION }}-${{ matrix.compiler.name }} | |
path: platform-report.md | |
if-no-files-found: warn | |
# Upload build artifacts | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: thales-ubuntu-${{ vars.UBUNTU_VERSION }}-${{ matrix.compiler.name }} | |
path: build/thales | |
if-no-files-found: warn | |
build-summary: | |
name: Cross-Platform Build Summary | |
needs: build-matrix | |
runs-on: ubuntu-${{ vars.UBUNTU_VERSION }} | |
if: always() | |
steps: | |
- name: Download all platform reports | |
uses: actions/download-artifact@v3 | |
with: | |
path: reports | |
- name: Generate summary report | |
run: | | |
echo "# Cross-Platform Build Summary" > summary-report.md | |
echo "" >> summary-report.md | |
echo "| Platform | Compiler | Status |" >> summary-report.md | |
echo "|----------|----------|--------|" >> summary-report.md | |
for report_dir in reports/platform-report-*; do | |
if [ -d "$report_dir" ]; then | |
platform_compiler=$(basename "$report_dir" | sed 's/platform-report-//g') | |
platform=$(echo "$platform_compiler" | cut -d'-' -f1) | |
compiler=$(echo "$platform_compiler" | cut -d'-' -f2) | |
if grep -q "Executable was built successfully" "$report_dir/platform-report.md"; then | |
echo "| $platform | $compiler | ✅ Success |" >> summary-report.md | |
else | |
echo "| $platform | $compiler | ❌ Failed |" >> summary-report.md | |
fi | |
fi | |
done | |
echo "" >> summary-report.md | |
echo "See individual platform reports for details." >> summary-report.md | |
cat summary-report.md | |
- name: Upload summary report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cross-platform-build-summary | |
path: summary-report.md |