name: CI
on:
  workflow_dispatch:
  pull_request:
    types: [opened, reopened, synchronize]

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
    - name: Checkout Tree
      uses: actions/checkout@v4
      with:
        submodules: true
    - name: Check Copyright Headers
      run: checks/headers
    - name: Create Z3 Build Directory
      run: mkdir z3/build
    - name: Configure Z3 Build
      working-directory: ${{runner.workspace}}/vampire/z3/build
      run: cmake .. -DCMAKE_BUILD_TYPE=Debug -DZ3_BUILD_EXECUTABLE=OFF -DZ3_BUILD_TEST_EXECUTABLES=OFF
      env:
        CXX: clang++
    - name: Z3 Build
      working-directory: ${{runner.workspace}}/vampire/z3/build
      run: make -j8
    - name: Create Build Directory
      run: mkdir build
    - name: Configure Build
      working-directory: ${{runner.workspace}}/vampire/build
      run: cmake .. -DCMAKE_BUILD_TYPE=Debug
      env:
        CXX: clang++
    - name: Build
      working-directory: ${{runner.workspace}}/vampire/build
      run: make -j8
    - name: Run Unit Tests
      working-directory: ${{runner.workspace}}/vampire/build
      run: ctest --output-on-failure
    - name: Find Vampire Binary
      run: cp build/bin/vampire_* vampire
    - name: Run Sanity Checks
      run: checks/sanity vampire
