update cicd #6
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop, 'feature/*', 'release/*', 'hotfix/*' ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| release: | |
| types: [ published ] | |
| # Allow manual triggering of workflow | |
| workflow_dispatch: | |
| inputs: | |
| build_type: | |
| description: 'Build type' | |
| required: false | |
| default: 'Release' | |
| type: choice | |
| options: | |
| - Release | |
| - Debug | |
| - RelWithDebInfo | |
| env: | |
| # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) | |
| BUILD_TYPE: ${{ github.event.inputs.build_type || 'Release' }} | |
| jobs: | |
| #============================================================================ | |
| # Cross-Platform Testing Matrix | |
| #============================================================================ | |
| test-matrix: | |
| name: Test on ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| # Linux builds | |
| - { | |
| name: "Ubuntu 22.04 GCC 12", | |
| os: ubuntu-22.04, | |
| compiler: gcc, | |
| version: "12", | |
| std: "17 20 23" | |
| } | |
| - { | |
| name: "Ubuntu 22.04 Clang 15", | |
| os: ubuntu-22.04, | |
| compiler: clang, | |
| version: "15", | |
| std: "17 20 23" | |
| } | |
| # macOS builds | |
| - { | |
| name: "macOS 13 Clang", | |
| os: macos-13, | |
| compiler: clang, | |
| version: "default", | |
| std: "17 20 23" | |
| } | |
| # Windows builds | |
| - { | |
| name: "Windows 2022 MSVC 2022", | |
| os: windows-2022, | |
| compiler: msvc, | |
| version: "2022", | |
| std: "17 20" | |
| } | |
| - { | |
| name: "Windows 2022 MinGW", | |
| os: windows-2022, | |
| compiler: mingw, | |
| version: "latest", | |
| std: "17 20" | |
| } | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup compiler (Linux GCC) | |
| if: runner.os == 'Linux' && matrix.config.compiler == 'gcc' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-${{ matrix.config.version }} g++-${{ matrix.config.version }} | |
| echo "CC=gcc-${{ matrix.config.version }}" >> $GITHUB_ENV | |
| echo "CXX=g++-${{ matrix.config.version }}" >> $GITHUB_ENV | |
| - name: Setup compiler (Linux Clang) | |
| if: runner.os == 'Linux' && matrix.config.compiler == 'clang' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-${{ matrix.config.version }} | |
| echo "CC=clang-${{ matrix.config.version }}" >> $GITHUB_ENV | |
| echo "CXX=clang++-${{ matrix.config.version }}" >> $GITHUB_ENV | |
| - name: Setup compiler (Windows MinGW) | |
| if: runner.os == 'Windows' && matrix.config.compiler == 'mingw' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| install: mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja | |
| - name: Setup MSVC environment | |
| if: runner.os == 'Windows' && matrix.config.compiler == 'msvc' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install CMake | |
| uses: lukka/get-cmake@latest | |
| - name: Test each C++ standard | |
| shell: bash | |
| run: | | |
| set -e | |
| for std in ${{ matrix.config.std }}; do | |
| echo "🧪 Testing C++${std}" | |
| echo "===============================================" | |
| build_dir="build-cpp${std}" | |
| # Configure | |
| if [[ "${{ runner.os }}" == "Windows" && "${{ matrix.config.compiler }}" == "mingw" ]]; then | |
| # MinGW specific configuration | |
| cmake -B $build_dir \ | |
| -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
| -DCMAKE_CXX_STANDARD=${std} \ | |
| -DTRLC_PLATFORM_BUILD_TESTS=ON \ | |
| -G "MinGW Makefiles" | |
| else | |
| cmake -B $build_dir \ | |
| -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
| -DCMAKE_CXX_STANDARD=${std} \ | |
| -DTRLC_PLATFORM_BUILD_TESTS=ON | |
| fi | |
| # Build | |
| cmake --build $build_dir --config ${{ env.BUILD_TYPE }} --parallel $(nproc 2>/dev/null || echo 2) | |
| # Test | |
| cd $build_dir | |
| ctest --build-config ${{ env.BUILD_TYPE }} --output-on-failure --verbose | |
| cd .. | |
| echo "✅ C++${std} tests passed" | |
| echo "" | |
| done | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.config.name }}-${{ env.BUILD_TYPE }} | |
| path: | | |
| build-*/Testing/ | |
| build-*/test_reports/ | |
| #============================================================================ | |
| # Architecture-Specific Testing | |
| #============================================================================ | |
| test-architectures: | |
| name: Test Architecture Detection on ${{ matrix.arch }} | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: "x86_64" | |
| runner: ubuntu-22.04 | |
| - arch: "arm64" | |
| runner: ubuntu-22.04 | |
| # Note: GitHub doesn't provide native ARM runners yet, | |
| # so we'll use emulation for ARM testing | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup QEMU for ARM emulation | |
| if: matrix.arch != 'x86_64' | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64 | |
| - name: Test architecture detection | |
| run: | | |
| if [[ "${{ matrix.arch }}" == "x86_64" ]]; then | |
| # Native x86_64 testing | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DTRLC_PLATFORM_BUILD_TESTS=ON | |
| cmake --build build --parallel $(nproc) | |
| cd build && ctest --output-on-failure | |
| else | |
| # ARM64 testing via Docker emulation | |
| docker run --rm --platform linux/arm64 \ | |
| -v $PWD:/workspace -w /workspace \ | |
| arm64v8/ubuntu:22.04 bash -c " | |
| apt-get update && apt-get install -y build-essential cmake | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DTRLC_PLATFORM_BUILD_TESTS=ON | |
| cmake --build build --parallel \$(nproc) | |
| cd build && ctest --output-on-failure | |
| " | |
| fi | |
| #============================================================================ | |
| # Integration and Packaging Tests | |
| #============================================================================ | |
| test-packaging: | |
| name: Test Package Installation | |
| runs-on: ubuntu-22.04 | |
| needs: test-matrix | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Test CMake package installation | |
| run: | | |
| # Test finding the package | |
| cat > CMakeLists.txt << 'EOF' | |
| cmake_minimum_required(VERSION 3.16) | |
| project(test_find_package CXX) | |
| find_package(trlc-platform REQUIRED) | |
| add_executable(test_app test_app.cpp) | |
| target_link_libraries(test_app trlc::platform) | |
| EOF | |
| cat > test_app.cpp << 'EOF' | |
| #include <trlc/platform/core.hpp> | |
| #include <iostream> | |
| int main() { | |
| auto report = trlc::platform::createPlatformReport(); | |
| std::cout << "Package installation test successful!" << std::endl; | |
| std::cout << report.generateSummary() << std::endl; | |
| return 0; | |
| } | |
| EOF | |
| cmake -B test_install -S . | |
| cmake --build test_install | |
| ./test_install/test_app | |
| #============================================================================ | |
| # Final Status Report | |
| #============================================================================ | |
| ci-status: | |
| name: CI/CD Status Summary | |
| runs-on: ubuntu-22.04 | |
| needs: [test-matrix, test-architectures, test-packaging] | |
| if: always() | |
| steps: | |
| - name: Generate status report | |
| run: | | |
| echo "🚀 TRLC Platform CI/CD Pipeline Results" | |
| echo "========================================" | |
| echo "" | |
| echo "📊 Job Status Summary:" | |
| echo " Cross-Platform Tests: ${{ needs.test-matrix.result }}" | |
| echo " Architecture Tests: ${{ needs.test-architectures.result }}" | |
| echo " Packaging: ${{ needs.test-packaging.result }}" | |
| echo "" |