name: BE20_API CI Windows
on:
  pull_request:
    branches: [ main ]
  push:
    branches: [ main ]


jobs:
  build:
    runs-on: 'windows-latest'
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          submodules: recursive

      # ----------------------------
      # Windows ( mSYS2 UCRT64)
      # ----------------------------
      - name: Setup MSYS2
        uses: msys2/setup-msys2@v2
        with:
          update: true
          msystem: ucrt64
          path-type: inherit

      - name: Install Windows dependencies and bootstrap
        shell: msys2 {0}
        env:
          WANT_AUTOCONF: "2.71"
        run: |
          pacman -Syu --noconfirm
          pacman -S --needed --noconfirm base-devel automake autoconf pkgconf mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-make \
               mingw-w64-ucrt-x86_64-re2 mingw-w64-ucrt-x86_64-abseil-cpp mingw-w64-ucrt-x86_64-sqlite3 mingw-w64-ucrt-x86_64-openssl \
               mingw-w64-ucrt-x86_64-expat
          bash bootstrap.sh

      - name: configure for windows (ucrt64)
        shell: msys2 {0}
        run: |
          ./configure --prefix=/ucrt64

      # ----------------------------
      # build + test windows
      # ----------------------------
      - name: make check
        shell: msys2 {0}
        run: |
          make 
          ./test_be20_api.exe
          make check  || (for fn in test*.log ; do echo ""; echo $fn ; cat $fn ; done; exit 1)

      - uses: ammaraskar/gcc-problem-matcher@master
        name: GCC Problem Matcher

