name: CI

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: "*"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.actor }}
  cancel-in-progress: true

jobs:
  unit-tests:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rev: [nightly, v0.10.3]
        include:
          - os: macos-latest
            install-deps: brew update && brew install fzf ripgrep fd
          - os: windows-latest
            install-deps: choco install fzf ripgrep fd
          - os: ubuntu-latest
            install-deps: |
              sudo apt-get update && sudo apt-get install -y ripgrep fd-find
              wget -O - https://github.com/junegunn/fzf/releases/download/v0.58.0/fzf-0.58.0-linux_amd64.tar.gz | tar zxfv -
              sudo mv ./fzf /bin

    steps:
      - uses: actions/checkout@v4

      - uses: rhysd/action-setup-vim@v1
        with:
          neovim: true
          version: ${{ matrix.rev }}

      - name: Install Dependencies
        shell: bash
        run: |
          ${{ matrix.install-deps }}
          fzf --version
          nvim --version
          rg --version
          if [ "$RUNNER_OS" == "Linux" ]; then
            fdfind --version
          else
            fd --version
          fi
          make deps

      - name: Run tests
        run: |
          make test
