Merge pull request #73 from NiceAndPeter/claude/add-member-initialize… #152
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, master, 'claude/**' ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| build-and-test: | |
| name: Build & Test (${{ matrix.compiler }}, ${{ matrix.build-type }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| compiler: [gcc-13, clang-15] | |
| build-type: [Release, Debug] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build | |
| # Install specific compiler versions | |
| if [[ "${{ matrix.compiler }}" == "gcc-13" ]]; then | |
| sudo apt-get install -y g++-13 | |
| echo "CC=gcc-13" >> $GITHUB_ENV | |
| echo "CXX=g++-13" >> $GITHUB_ENV | |
| elif [[ "${{ matrix.compiler }}" == "clang-15" ]]; then | |
| sudo apt-get install -y clang-15 | |
| echo "CC=clang-15" >> $GITHUB_ENV | |
| echo "CXX=clang++-15" >> $GITHUB_ENV | |
| fi | |
| - name: Configure CMake | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ | |
| -DCMAKE_C_COMPILER=${{ env.CC }} \ | |
| -DCMAKE_CXX_COMPILER=${{ env.CXX }} \ | |
| -G Ninja | |
| - name: Build | |
| run: cmake --build build | |
| - name: Run Tests | |
| working-directory: testes | |
| run: | | |
| # Run tests once and check for expected success output | |
| ../build/lua all.lua 2>&1 | tee test_output.txt | |
| grep -q "final OK !!!" test_output.txt || exit 1 | |
| - name: Upload build artifacts | |
| if: matrix.build-type == 'Release' && matrix.compiler == 'gcc-13' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lua-cpp-binary | |
| path: build/lua | |
| retention-days: 7 | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake g++-13 | |
| - name: Configure with strict warnings | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER=gcc-13 \ | |
| -DCMAKE_CXX_COMPILER=g++-13 | |
| - name: Build with -Werror | |
| run: cmake --build build 2>&1 | tee build.log | |
| - name: Check for warnings | |
| run: | | |
| # Build should succeed with zero warnings | |
| if grep -i "warning:" build.log; then | |
| echo "ERROR: Warnings detected in build" | |
| exit 1 | |
| fi | |
| echo "SUCCESS: Zero warnings build" | |
| - name: Verify no errors | |
| run: | | |
| if grep -i "error:" build.log; then | |
| echo "ERROR: Errors detected in build" | |
| exit 1 | |
| fi | |
| echo "SUCCESS: Clean build" | |
| performance-check: | |
| name: Performance Regression Check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake g++-13 | |
| - name: Build Release | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCMAKE_C_COMPILER=gcc-13 \ | |
| -DCMAKE_CXX_COMPILER=g++-13 | |
| cmake --build build | |
| - name: Run 5x Benchmark | |
| working-directory: testes | |
| run: | | |
| echo "Running 5 benchmark iterations..." | |
| for i in 1 2 3 4 5; do | |
| echo "=== Run $i ===" | |
| ../build/lua all.lua 2>&1 | grep "total time:" | tee -a benchmark_results.txt | |
| done | |
| - name: Analyze Performance | |
| working-directory: testes | |
| run: | | |
| # Extract times and calculate average | |
| grep "total time:" benchmark_results.txt | \ | |
| awk '{print $3}' | \ | |
| awk '{sum+=$1; times[NR]=$1} END { | |
| avg=sum/NR; | |
| printf "Average: %.2fs\n", avg; | |
| printf "Runs: "; | |
| for(i=1; i<=NR; i++) printf "%.2fs ", times[i]; | |
| printf "\n"; | |
| # Check against threshold (allow some variance in CI) | |
| # Using 5.00s threshold (more generous than local 4.33s due to CI variance) | |
| if (avg > 5.00) { | |
| printf "PERFORMANCE REGRESSION: %.2fs > 5.00s\n", avg; | |
| exit 1; | |
| } | |
| printf "Performance OK: %.2fs <= 5.00s\n", avg; | |
| }' | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-results | |
| path: testes/benchmark_results.txt | |
| retention-days: 30 | |
| sanitizers: | |
| name: Sanitizer Tests (ASAN + UBSAN) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake clang-15 | |
| - name: Build with sanitizers | |
| run: | | |
| cmake -B build \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_C_COMPILER=clang-15 \ | |
| -DCMAKE_CXX_COMPILER=clang++-15 \ | |
| -DLUA_ENABLE_ASAN=ON \ | |
| -DLUA_ENABLE_UBSAN=ON | |
| cmake --build build | |
| - name: Run tests with sanitizers | |
| working-directory: testes | |
| run: | | |
| # Run with sanitizer options and check for success | |
| ASAN_OPTIONS=detect_leaks=1:halt_on_error=1 \ | |
| UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \ | |
| ../build/lua all.lua 2>&1 | tee test_output.txt | |
| grep -q "final OK !!!" test_output.txt || exit 1 | |
| build-summary: | |
| name: Build Summary | |
| runs-on: ubuntu-latest | |
| needs: [build-and-test, code-quality, performance-check, sanitizers] | |
| if: always() | |
| steps: | |
| - name: Check results | |
| run: | | |
| echo "Build and Test: ${{ needs.build-and-test.result }}" | |
| echo "Code Quality: ${{ needs.code-quality.result }}" | |
| echo "Performance: ${{ needs.performance-check.result }}" | |
| echo "Sanitizers: ${{ needs.sanitizers.result }}" | |
| if [[ "${{ needs.build-and-test.result }}" != "success" ]] || \ | |
| [[ "${{ needs.code-quality.result }}" != "success" ]] || \ | |
| [[ "${{ needs.performance-check.result }}" != "success" ]] || \ | |
| [[ "${{ needs.sanitizers.result }}" != "success" ]]; then | |
| echo "❌ Some checks failed" | |
| exit 1 | |
| fi | |
| echo "✅ All checks passed!" |