name: Test

on: [ push ]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        neovim-version: [ "v0.9.0", "v0.9.1", "stable", "nightly" ]

    steps:
      - uses: actions/checkout@v3
      - uses: MunifTanjim/setup-neovim-action@v1
        with:
          tag: ${{ matrix.neovim-version }}
      - name: Install Neovim plugins
        run: |
          mkdir -p ~/.local/share/nvim/site/pack/nfnl-tests/start
          git clone https://github.com/nvim-lua/plenary.nvim.git ~/.local/share/nvim/site/pack/nfnl-tests/start/plenary
          git clone https://github.com/bakpakin/fennel.vim.git ~/.local/share/nvim/site/pack/nfnl-tests/start/fennel.vim
          ln -s ${GITHUB_WORKSPACE} ~/.local/share/nvim/site/pack/nfnl-tests/start/nfnl
      - name: Trust the project configuration file
        run: |
          nvim --headless -c 'edit .nfnl.fnl' -c trust -c qa
      - name: Test with plenary / busted
        run: |
          ./script/test
