updated workflow setting #43
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: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| CI: true | |
| BUILD_TYPE: Debug | |
| jobs: | |
| # Security and dependency scanning | |
| security-scan: | |
| name: Security & Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Run security scan | |
| uses: securecodewarrior/github-action-gosec@master | |
| with: | |
| args: ./... | |
| - name: Dependency vulnerability scan | |
| uses: dependency-check/Dependency-Check_Action@main | |
| with: | |
| project: 'ChainedDecos' | |
| path: . | |
| format: 'ALL' | |
| # Code quality checks | |
| quality-checks: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install clang-format and clang-tidy | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format-14 clang-tidy-14 | |
| - name: Check code formatting | |
| run: | | |
| find src -name "*.cpp" -o -name "*.h" | xargs clang-format-14 --dry-run --Werror | |
| - name: Run clang-tidy | |
| run: | | |
| mkdir -p build/tidy | |
| cd build/tidy | |
| cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../.. | |
| find ../../src -name "*.cpp" -exec clang-tidy-14 -p . {} \; || true | |
| # Main test matrix | |
| test: | |
| name: Tests (${{ matrix.os }}, ${{ matrix.compiler }}) | |
| runs-on: ${{ matrix.os }} | |
| needs: [security-scan, quality-checks] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| compiler: gcc | |
| version: 11 | |
| generator: "Unix Makefiles" | |
| - os: ubuntu-22.04 | |
| compiler: clang | |
| version: 14 | |
| generator: "Unix Makefiles" | |
| - os: windows-2022 | |
| compiler: msvc | |
| version: 2022 | |
| generator: "Ninja" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Set up build environment | |
| id: build-env | |
| shell: bash | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| echo "timestamp=$(date -u +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT" | |
| # Optimized caching strategy | |
| - name: Setup ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.ccache | |
| C:\ccache | |
| key: ccache-${{ matrix.os }}-${{ matrix.compiler }}-${{ steps.build-env.outputs.timestamp }} | |
| restore-keys: | | |
| ccache-${{ matrix.os }}-${{ matrix.compiler }}- | |
| ccache-${{ matrix.os }}- | |
| - name: Setup dependency cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .deps | |
| ~/.deps | |
| build/.deps | |
| key: deps-${{ matrix.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt', '**/cmake/*.cmake') }} | |
| restore-keys: | | |
| deps-${{ matrix.os }}-${{ matrix.compiler }}- | |
| deps-${{ matrix.os }}- | |
| # Platform-specific setup | |
| - name: Install dependencies (Ubuntu) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y --no-install-recommends \ | |
| build-essential cmake ninja-build ccache \ | |
| libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev \ | |
| libxcursor-dev libxi-dev libasound2-dev libglu1-mesa-dev \ | |
| libwayland-dev libxkbcommon-dev libegl1-mesa-dev pkg-config | |
| - name: Set compiler environment (Ubuntu) | |
| if: startsWith(matrix.os, 'ubuntu') | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.compiler }}" = "gcc" ]; then | |
| echo "CC=gcc-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| echo "CXX=g++-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| else | |
| echo "CC=clang-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| echo "CXX=clang++-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| fi | |
| - name: Install dependencies (Windows) | |
| if: matrix.os == 'windows-2022' | |
| shell: cmd | |
| run: | | |
| choco install cmake ninja ccache --no-progress -y | |
| # Clean build environment | |
| - name: Clean build environment | |
| shell: bash | |
| run: | | |
| echo "Cleaning build environment..." | |
| rm -rf "${{ steps.build-env.outputs.build-output-dir }}" | |
| rm -rf ".deps" | |
| rm -f CMakeCache.txt cmake_install.cmake | |
| find . -name "CMakeFiles" -type d -exec rm -rf {} + 2>/dev/null || true | |
| # Configure CMake | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| if [ "${{ matrix.os }}" = "windows-2022" ]; then | |
| # Windows configuration | |
| cmake -G "${{ matrix.generator }}" \ | |
| -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_SYSTEM_VERSION=10.0 \ | |
| -DCMAKE_VS_PLATFORM_NAME=x64 \ | |
| -DBUILD_TESTS=ON \ | |
| -DBUILD_BENCHMARKS=ON \ | |
| -DENABLE_COVERAGE=${{ matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc' }} \ | |
| -DENABLE_WARNINGS=ON \ | |
| -DENABLE_UNITY_BUILD=ON \ | |
| -DENABLE_SANITIZERS=${{ startsWith(matrix.os, 'ubuntu') }} \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DENABLE_DEV_TOOLS=ON \ | |
| -DENABLE_DEBUG_INFO=ON \ | |
| -S "${{ github.workspace }}" | |
| else | |
| # Unix/Linux configuration | |
| cmake -G "${{ matrix.generator }}" \ | |
| -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DBUILD_TESTS=ON \ | |
| -DBUILD_BENCHMARKS=ON \ | |
| -DENABLE_COVERAGE=${{ matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc' }} \ | |
| -DENABLE_WARNINGS=ON \ | |
| -DENABLE_UNITY_BUILD=ON \ | |
| -DENABLE_SANITIZERS=ON \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DENABLE_DEV_TOOLS=ON \ | |
| -DENABLE_DEBUG_INFO=ON \ | |
| -S "${{ github.workspace }}" | |
| fi | |
| # Build | |
| - name: Build project | |
| shell: bash | |
| run: | | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| cpu_cores=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) | |
| cmake --build . \ | |
| --config ${{ env.BUILD_TYPE }} \ | |
| --target ChainedDecos ChainedDecosMapEditor ChainedDecosTests benchmarks \ | |
| --parallel $cpu_cores \ | |
| --verbose | |
| # Run tests | |
| - name: Run tests | |
| shell: bash | |
| run: | | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| mkdir -p test_results | |
| echo "Running tests on ${{ matrix.os }} with ${{ matrix.compiler }}..." | |
| # Run CTest with comprehensive output | |
| ctest --output-on-failure \ | |
| --build-config ${{ env.BUILD_TYPE }} \ | |
| --output-junit test_results/junit.xml \ | |
| --timeout 300 | |
| # Copy all test artifacts | |
| find . -name "*test*.xml" -type f -exec cp {} test_results/ \; 2>/dev/null || true | |
| find . -name "*results*.xml" -type f -exec cp {} test_results/ \; 2>/dev/null || true | |
| # Generate coverage report (Ubuntu GCC only) | |
| - name: Generate coverage report | |
| if: matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc' | |
| shell: bash | |
| run: | | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| mkdir -p coverage | |
| # Install lcov if not present | |
| sudo apt-get install -y lcov | |
| # Generate coverage report | |
| lcov --capture --directory . --output-file coverage.info --exclude '/usr/*' --exclude '*/tests/*' --exclude '*/test/*' | |
| lcov --remove coverage.info '*/tests/*' '*/test/*' --output-file coverage.info | |
| lcov --list coverage.info | |
| # Generate HTML report | |
| genhtml coverage.info --output-directory coverage/html --title "ChainedDecos Coverage Report" | |
| # Upload test results | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.compiler }}-${{ steps.build-env.outputs.timestamp }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/test_results/ | |
| ${{ steps.build-env.outputs.build-output-dir }}/Testing/ | |
| retention-days: 7 | |
| # Upload coverage report | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| if: matrix.os == 'ubuntu-22.04' && matrix.compiler == 'gcc' && always() | |
| with: | |
| name: coverage-report-${{ matrix.os }}-${{ matrix.compiler }}-${{ steps.build-env.outputs.timestamp }} | |
| path: ${{ steps.build-env.outputs.build-output-dir }}/coverage/ | |
| retention-days: 30 | |
| # Upload build artifacts (for releases) | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| with: | |
| name: build-artifacts-${{ matrix.os }}-${{ matrix.compiler }}-${{ steps.build-env.outputs.timestamp }} | |
| path: | | |
| ${{ steps.build-env.outputs.build-output-dir }}/bin/ | |
| retention-days: 90 | |
| # Performance benchmarks | |
| benchmark: | |
| name: Performance Benchmarks | |
| runs-on: ubuntu-22.04 | |
| needs: test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y --no-install-recommends \ | |
| build-essential cmake ninja-build ccache \ | |
| libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev \ | |
| libxcursor-dev libxi-dev libasound2-dev libglu1-mesa-dev \ | |
| libwayland-dev libxkbcommon-dev libegl1-mesa-dev pkg-config | |
| - name: Set up build environment | |
| id: build-env | |
| shell: bash | |
| run: | | |
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| - name: Setup ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ccache | |
| key: ccache-benchmark-${{ github.sha }} | |
| restore-keys: ccache-benchmark- | |
| - name: Configure and build benchmarks | |
| shell: bash | |
| run: | | |
| mkdir -p "${{ steps.build-env.outputs.build-output-dir }}" | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| cmake -G "Unix Makefiles" \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DBUILD_TESTS=OFF \ | |
| -DBUILD_BENCHMARKS=ON \ | |
| -DENABLE_WARNINGS=ON \ | |
| -DENABLE_UNITY_BUILD=ON \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -S "${{ github.workspace }}" | |
| cmake --build . --config Release --target benchmarks --parallel $(nproc) | |
| - name: Run benchmarks | |
| shell: bash | |
| run: | | |
| cd "${{ steps.build-env.outputs.build-output-dir }}" | |
| ./bin/benchmarks --benchmark_out=benchmark_results.json --benchmark_out_format=json | |
| - name: Upload benchmark results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results-${{ github.sha }} | |
| path: ${{ steps.build-env.outputs.build-output-dir }}/benchmark_results.json | |
| retention-days: 90 |