name: Linux build with address sanitizer enabled
on:
  schedule:
    - cron: '0 0 * * 0'
  workflow_dispatch:
jobs:
  sanitize-address-undefined:
    runs-on: ubuntu-latest
    container: ghcr.io/lballabio/quantlib-devenv:rolling
    steps:
    - uses: actions/checkout@v6
    - name: Compiler version
      run: |
        gcc --version
    - name: Build
      run: |
        ./autogen.sh
        ./configure --disable-static CC="gcc" CXX="g++" CXXFLAGS="-O2 -g0 -fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer -Wall -Wno-unknown-pragmas -Werror"
        make -j 4
    - name: Run tests
      run: |
        LSAN_OPTIONS=suppressions=.lsan.txt ./test-suite/quantlib-test-suite --log_level=message
    - name: Run examples
      run: |
        make check-examples
  sanitize-thread:
    runs-on: ubuntu-latest
    container: ghcr.io/lballabio/quantlib-devenv:rolling
    steps:
    - uses: actions/checkout@v6
    - name: Compiler version
      run: |
        gcc --version
    - name: Build
      run: |
        ./autogen.sh
        ./configure --disable-static --enable-sessions --enable-thread-safe-observer-pattern CC="gcc" CXX="g++" CXXFLAGS="-O2 -g0 -fsanitize=thread -fno-sanitize-recover=all -Wall -Wno-unknown-pragmas -Werror"
        make -j 4
    - name: Run tests
      run: |
        ./test-suite/quantlib-test-suite --log_level=message
    - name: Run examples
      run: |
        make check-examples
