# Run UndefinedBehaviorSanitizer
name: UBSAN

on:
  workflow_call:

env:
  GITHUB_REPO:  pmem/pmdk
  DOCKER_REPO:  ghcr.io/pmem/pmdk
  HOST_WORKDIR: /home/runner/work/pmdk/pmdk
  WORKDIR:      utils/docker
  PMDK_CC:      gcc
  PMDK_CXX:     g++
  MAKE_PKG:     0
  SRC_CHECKERS: 0
  OS:           ubuntu
  OS_VER:       22.04
  UBSAN:        1
  FAULT_INJECTION: 1

jobs:
  linux:
    name: Linux
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        build: ['debug', 'nondebug']
    steps:
      - name: Clone the git repo
        uses: actions/checkout@v4

      - name: Pull the image
        run: cd $WORKDIR && ./pull-or-rebuild-image.sh

      - name: Build libraries with Undefined Behavior Sanitizer and run tests
        env:
          TEST_BUILD: ${{ matrix.build }}
        run: cd $WORKDIR && ./build-CI.sh
