name: CI

on: [push, pull_request]

jobs:
  gcc:
    name: c build and tests
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-22.04, macos-12]
        compiler: [gcc, clang]
    steps:
      - uses: actions/checkout@v4
      - name: Prepare
        env:
          CC: ${{ matrix.compiler }}
        run: |
          cc --version
          git clone https://github.com/Conni2461/examiner
          cd examiner
          make && sudo make install
      - name: Build
        env:
          CC: ${{ matrix.compiler }}
          LD_LIBRARY_PATH: /usr/lib:/usr/local/lib
        run: make
      - name: Tests
        env:
          CC: ${{ matrix.compiler }}
          LD_LIBRARY_PATH: /usr/lib:/usr/local/lib
        run: make test

  windows:
    name: windows
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - uses: lukka/get-cmake@latest
      - name: Build
        run: |
          cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
          cmake --build build --config Release

  nvim-tests:
    name: nvim-tests
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-22.04, macos-12]
        rev: [nightly, v0.9.5, v0.10.0]
    steps:
      - uses: actions/checkout@v4
      - uses: rhysd/action-setup-vim@v1
        with:
          neovim: true
          version: ${{ matrix.rev }}
      - name: Prepare
        run: |
          git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ../plenary.nvim
      - name: Build
        run: make
      - name: Tests
        run: |
          nvim --version
          make ntest
