name: CI

on: [push, pull_request]

env:
  VERBOSE: 1

jobs:
  #  whitespace-errors:
  #  runs-on: ubuntu-latest
  #  steps:
  #  - uses: actions/checkout@v4
  #  - name: check
  #    run: git diff-index --check --cached 4b825dc642cb6eb9a060e54bf8d69288fbee4904

  gcc14-x86_64:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-14
      TARGET: x86_64
      ENABLE_VALGRIND: 1
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc14-x86_64-sanitizers:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-14
      CFLAGS: '-O1 -g -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined -Wno-error=inline -Wno-error=format-overflow'
      LDFLAGS: '-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined'
      ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
      UBSAN_OPTIONS: print_stacktrace=1:print_summary=1:halt_on_error=1
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc13-x86_64-sanitizers:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-13
      CFLAGS: '-O1 -g -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined -Wno-error=inline -Wno-error=format-overflow'
      LDFLAGS: '-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined'
      ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
      UBSAN_OPTIONS: print_stacktrace=1:print_summary=1:halt_on_error=1
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc13-x86_64:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-13
      TARGET: x86_64
      ENABLE_VALGRIND: 1
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc12-x86_64-sanitizers:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-12
      CFLAGS: '-O1 -g -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined -Wno-error=inline -Wno-error=format-overflow'
      LDFLAGS: '-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined'
      ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
      UBSAN_OPTIONS: print_stacktrace=1:print_summary=1:halt_on_error=1
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc12-x86_64:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-12
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc11-x86_64-sanitizers:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-11
      CFLAGS: '-O1 -g -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined -Wno-error=inline -Wno-error=format-overflow'
      LDFLAGS: '-fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer -fsanitize=undefined'
      ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
      UBSAN_OPTIONS: print_stacktrace=1:print_summary=1:halt_on_error=1
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  gcc11-x86_64:
    runs-on: ubuntu-24.04
    env:
      CC: gcc-11
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh

  clang18-x86_64:
    runs-on: ubuntu-24.04
    env:
      CC: clang-18
      TARGET: x86_64
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: install dependencies
      run: ci/install-dependencies.sh
    - name: build check
      run: ci/build.sh
