|
| 1 | +name: Sanitizer and Performance Checks |
| 2 | + |
| 3 | +# Phase 0: Mandatory sanitizer builds (TSan, ASan, UBSan) |
| 4 | +# These checks are REQUIRED and will block merges if they fail |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + - 'claude/**' # Claude's working branches |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +jobs: |
| 16 | + thread_sanitizer: |
| 17 | + name: ThreadSanitizer (MANDATORY) |
| 18 | + runs-on: ubuntu-latest |
| 19 | + timeout-minutes: 30 |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: recursive |
| 25 | + |
| 26 | + - name: Install dependencies |
| 27 | + run: | |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install -y cmake build-essential clang |
| 30 | +
|
| 31 | + - name: Build with TSan |
| 32 | + run: | |
| 33 | + mkdir -p build_tsan |
| 34 | + cd build_tsan |
| 35 | + cmake -DCMAKE_CXX_COMPILER=clang++ \ |
| 36 | + -DCMAKE_C_COMPILER=clang \ |
| 37 | + -DENABLE_TSAN=ON \ |
| 38 | + -DBUILD_BENCHMARKS=ON \ |
| 39 | + .. |
| 40 | + make -j$(nproc) |
| 41 | +
|
| 42 | + - name: Run stress tests with TSan |
| 43 | + run: | |
| 44 | + cd build_tsan |
| 45 | + ./stress_test_concurrent |
| 46 | + env: |
| 47 | + TSAN_OPTIONS: "halt_on_error=1 history_size=7" |
| 48 | + |
| 49 | + - name: Check for TSan warnings |
| 50 | + if: failure() |
| 51 | + run: | |
| 52 | + echo "❌ ThreadSanitizer detected data races!" |
| 53 | + echo "This is a MANDATORY check - fix all data races before merging." |
| 54 | + exit 1 |
| 55 | +
|
| 56 | + address_sanitizer: |
| 57 | + name: AddressSanitizer (MANDATORY) |
| 58 | + runs-on: ubuntu-latest |
| 59 | + timeout-minutes: 30 |
| 60 | + |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + with: |
| 64 | + submodules: recursive |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + sudo apt-get update |
| 69 | + sudo apt-get install -y cmake build-essential clang |
| 70 | +
|
| 71 | + - name: Build with ASan |
| 72 | + run: | |
| 73 | + mkdir -p build_asan |
| 74 | + cd build_asan |
| 75 | + cmake -DCMAKE_CXX_COMPILER=clang++ \ |
| 76 | + -DCMAKE_C_COMPILER=clang \ |
| 77 | + -DENABLE_ASAN=ON \ |
| 78 | + -DBUILD_BENCHMARKS=ON \ |
| 79 | + .. |
| 80 | + make -j$(nproc) |
| 81 | +
|
| 82 | + - name: Run benchmarks with ASan |
| 83 | + run: | |
| 84 | + cd build_asan |
| 85 | + ./benchmark_construction small_uniform |
| 86 | + ./benchmark_query small_uniform |
| 87 | + env: |
| 88 | + ASAN_OPTIONS: "halt_on_error=1 detect_leaks=1" |
| 89 | + |
| 90 | + - name: Run stress tests with ASan |
| 91 | + run: | |
| 92 | + cd build_asan |
| 93 | + timeout 60 ./stress_test_concurrent |
| 94 | + env: |
| 95 | + ASAN_OPTIONS: "halt_on_error=1 detect_leaks=1" |
| 96 | + |
| 97 | + undefined_behavior_sanitizer: |
| 98 | + name: UndefinedBehaviorSanitizer (MANDATORY) |
| 99 | + runs-on: ubuntu-latest |
| 100 | + timeout-minutes: 30 |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v4 |
| 104 | + with: |
| 105 | + submodules: recursive |
| 106 | + |
| 107 | + - name: Install dependencies |
| 108 | + run: | |
| 109 | + sudo apt-get update |
| 110 | + sudo apt-get install -y cmake build-essential clang |
| 111 | +
|
| 112 | + - name: Build with UBSan |
| 113 | + run: | |
| 114 | + mkdir -p build_ubsan |
| 115 | + cd build_ubsan |
| 116 | + cmake -DCMAKE_CXX_COMPILER=clang++ \ |
| 117 | + -DCMAKE_C_COMPILER=clang \ |
| 118 | + -DENABLE_UBSAN=ON \ |
| 119 | + -DBUILD_BENCHMARKS=ON \ |
| 120 | + .. |
| 121 | + make -j$(nproc) |
| 122 | +
|
| 123 | + - name: Run benchmarks with UBSan |
| 124 | + run: | |
| 125 | + cd build_ubsan |
| 126 | + ./benchmark_construction small_uniform |
| 127 | + ./benchmark_query small_uniform |
| 128 | + env: |
| 129 | + UBSAN_OPTIONS: "halt_on_error=1 print_stacktrace=1" |
| 130 | + |
| 131 | + benchmark_baseline: |
| 132 | + name: Performance Baseline Check |
| 133 | + runs-on: ubuntu-latest |
| 134 | + timeout-minutes: 45 |
| 135 | + |
| 136 | + steps: |
| 137 | + - uses: actions/checkout@v4 |
| 138 | + with: |
| 139 | + submodules: recursive |
| 140 | + |
| 141 | + - name: Install dependencies |
| 142 | + run: | |
| 143 | + sudo apt-get update |
| 144 | + sudo apt-get install -y cmake build-essential |
| 145 | +
|
| 146 | + - name: Build benchmarks |
| 147 | + run: | |
| 148 | + mkdir -p build_benchmark |
| 149 | + cd build_benchmark |
| 150 | + cmake -DCMAKE_BUILD_TYPE=Release \ |
| 151 | + -DENABLE_PROFILING=ON \ |
| 152 | + -DBUILD_BENCHMARKS=ON \ |
| 153 | + .. |
| 154 | + make -j$(nproc) |
| 155 | +
|
| 156 | + - name: Run benchmarks |
| 157 | + run: | |
| 158 | + cd build_benchmark |
| 159 | + ./benchmark_construction small_uniform > construction_results.txt |
| 160 | + ./benchmark_query small_uniform > query_results.txt |
| 161 | +
|
| 162 | + - name: Upload benchmark results |
| 163 | + uses: actions/upload-artifact@v4 |
| 164 | + with: |
| 165 | + name: benchmark-results-${{ github.sha }} |
| 166 | + path: | |
| 167 | + build_benchmark/construction_results.txt |
| 168 | + build_benchmark/query_results.txt |
| 169 | + build_benchmark/*.csv |
| 170 | +
|
| 171 | + - name: Check for performance regressions |
| 172 | + run: | |
| 173 | + # Placeholder for future regression checking |
| 174 | + # Will compare against Phase 0 baseline once established |
| 175 | + echo "✓ Benchmarks completed successfully" |
| 176 | + echo "TODO: Compare against Phase 0 baseline" |
| 177 | +
|
| 178 | + concurrent_stress_long: |
| 179 | + name: Long-Running Stress Test (10 min) |
| 180 | + runs-on: ubuntu-latest |
| 181 | + timeout-minutes: 15 |
| 182 | + # Only run on main branch and manual triggers to save CI time |
| 183 | + if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' |
| 184 | + |
| 185 | + steps: |
| 186 | + - uses: actions/checkout@v4 |
| 187 | + with: |
| 188 | + submodules: recursive |
| 189 | + |
| 190 | + - name: Install dependencies |
| 191 | + run: | |
| 192 | + sudo apt-get update |
| 193 | + sudo apt-get install -y cmake build-essential clang |
| 194 | +
|
| 195 | + - name: Build with TSan |
| 196 | + run: | |
| 197 | + mkdir -p build_tsan_long |
| 198 | + cd build_tsan_long |
| 199 | + cmake -DCMAKE_CXX_COMPILER=clang++ \ |
| 200 | + -DCMAKE_C_COMPILER=clang \ |
| 201 | + -DENABLE_TSAN=ON \ |
| 202 | + -DBUILD_BENCHMARKS=ON \ |
| 203 | + .. |
| 204 | + make -j$(nproc) |
| 205 | +
|
| 206 | + - name: Run 10-minute torture test |
| 207 | + run: | |
| 208 | + cd build_tsan_long |
| 209 | + # Run for 10 minutes (600 seconds) |
| 210 | + timeout 600 ./stress_test_concurrent || { |
| 211 | + if [ $? -eq 124 ]; then |
| 212 | + echo "✓ Stress test ran for full 10 minutes" |
| 213 | + exit 0 |
| 214 | + else |
| 215 | + echo "❌ Stress test failed before timeout" |
| 216 | + exit 1 |
| 217 | + fi |
| 218 | + } |
| 219 | + env: |
| 220 | + TSAN_OPTIONS: "halt_on_error=1 history_size=7" |
| 221 | + |
| 222 | + build_status_summary: |
| 223 | + name: Build Status Summary |
| 224 | + runs-on: ubuntu-latest |
| 225 | + needs: [thread_sanitizer, address_sanitizer, undefined_behavior_sanitizer, benchmark_baseline] |
| 226 | + if: always() |
| 227 | + |
| 228 | + steps: |
| 229 | + - name: Check build status |
| 230 | + run: | |
| 231 | + echo "===================================" |
| 232 | + echo " Sanitizer Build Status Summary " |
| 233 | + echo "===================================" |
| 234 | + echo "" |
| 235 | + echo "ThreadSanitizer: ${{ needs.thread_sanitizer.result }}" |
| 236 | + echo "AddressSanitizer: ${{ needs.address_sanitizer.result }}" |
| 237 | + echo "UBSanitizer: ${{ needs.undefined_behavior_sanitizer.result }}" |
| 238 | + echo "Benchmarks: ${{ needs.benchmark_baseline.result }}" |
| 239 | + echo "" |
| 240 | +
|
| 241 | + # Fail if any mandatory check failed |
| 242 | + if [ "${{ needs.thread_sanitizer.result }}" != "success" ] || \ |
| 243 | + [ "${{ needs.address_sanitizer.result }}" != "success" ] || \ |
| 244 | + [ "${{ needs.undefined_behavior_sanitizer.result }}" != "success" ]; then |
| 245 | + echo "❌ MANDATORY SANITIZER CHECKS FAILED" |
| 246 | + echo "All sanitizer checks must pass before merging." |
| 247 | + exit 1 |
| 248 | + fi |
| 249 | +
|
| 250 | + echo "✓ All mandatory checks passed" |
0 commit comments