|
| 1 | +name: cmake Ubuntu Sanitizers |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + |
| 10 | +env: |
| 11 | + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| 12 | + BUILD_TYPE: Debug |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + # The CMake configure and build commands are platform agnostic and should work equally |
| 17 | + # well on Windows or Mac. You can convert this to a matrix build if you need |
| 18 | + # cross-platform coverage. |
| 19 | + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + os: [ubuntu-22.04] |
| 25 | + sanitizer: [asan_ubsan, tsan] |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + |
| 30 | + - name: Install Conan |
| 31 | + id: conan |
| 32 | + uses: turtlebrowser/get-conan@main |
| 33 | + |
| 34 | + - name: Create default profile |
| 35 | + run: conan profile detect |
| 36 | + |
| 37 | + - name: Install conan dependencies |
| 38 | + run: conan install conanfile.py -s build_type=${{env.BUILD_TYPE}} --build=missing |
| 39 | + |
| 40 | + - name: Normalize build type |
| 41 | + shell: bash |
| 42 | + # The build type is Capitalized, e.g. Release, but the preset is all lowercase, e.g. release. |
| 43 | + # There is no built in way to do string manipulations on GHA as far as I know.` |
| 44 | + run: echo "BUILD_TYPE_LOWERCASE=$(echo "${BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV |
| 45 | + |
| 46 | + - name: Configure CMake |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + if [[ "${{ matrix.sanitizer }}" == "asan_ubsan" ]]; then |
| 50 | + cmake --preset conan-${{ env.BUILD_TYPE_LOWERCASE }} \ |
| 51 | + -DBTCPP_ENABLE_ASAN:BOOL=ON -DBTCPP_ENABLE_UBSAN:BOOL=ON |
| 52 | + else |
| 53 | + cmake --preset conan-${{ env.BUILD_TYPE_LOWERCASE }} \ |
| 54 | + -DBTCPP_ENABLE_TSAN:BOOL=ON |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Build |
| 58 | + shell: bash |
| 59 | + run: cmake --build --preset conan-${{ env.BUILD_TYPE_LOWERCASE }} |
| 60 | + |
| 61 | + - name: run test (Linux + Address and Undefined Behavior Sanitizers) |
| 62 | + env: |
| 63 | + GTEST_COLOR: "On" |
| 64 | + ASAN_OPTIONS: "color=always" |
| 65 | + UBSAN_OPTIONS: "halt_on_error=1:print_stacktrace=1:color=always" |
| 66 | + TSAN_OPTIONS: "color=always" |
| 67 | + # There is a known issue with TSAN on recent kernel versions. Without the vm.mmap_rnd_bits=28 |
| 68 | + # workaround all binaries with TSan enabled crash with "FATAL: ThreadSanitizer: unexpected memory mapping" |
| 69 | + run: sudo sysctl vm.mmap_rnd_bits=28 && ctest --test-dir build/${{env.BUILD_TYPE}} --output-on-failure |
0 commit comments