name: Ubuntu 24.04 CI (GCC 13) With Memory Sanitizer

on: [push, pull_request]

jobs:
  ubuntu-build-address-sanitizer:
    if: >-
      ! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
      ! contains(toJSON(github.event.commits.*.message), '[skip github]')
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: dependencies/.cache
          key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
      - name: Use cmake with address sanitizer
        run: |
          mkdir builddebug &&
          cd builddebug &&
          cmake -DSIMDJSON_SANITIZE=ON -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF ..  &&
          cmake --build .   &&
          ctest --output-on-failure -LE explicitonly -j
  ubuntu-build-undefined-sanitizer:
    if: >-
      ! contains(toJSON(github.event.commits.*.message), '[skip ci]') &&
      ! contains(toJSON(github.event.commits.*.message), '[skip github]')
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: dependencies/.cache
          key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
      - name: Use cmake with undefined sanitizer
        run: |
          mkdir builddebugundefsani &&
          cd builddebugundefsani &&
          cmake -DSIMDJSON_SANITIZE_UNDEFINED=ON -DCMAKE_BUILD_TYPE=Debug -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_DEVELOPER_MODE=ON -DBUILD_SHARED_LIBS=OFF ..  &&
          cmake --build .   &&
          ctest --output-on-failure -LE explicitonly -j
