From 7df32fd1901e3a008ca060d807b8bcfc7f6b6d53 Mon Sep 17 00:00:00 2001 From: Ben Fowler Date: Sat, 14 Dec 2024 03:58:01 +0000 Subject: [PATCH] FEAT: add a basic regression test --- .github/workflows/ci.yml | 49 +++++++++++++++++++ Makefile | 11 +++-- lua/tests/automated/telescope_basics_spec.lua | 5 ++ .../telescope_invoke_snippets_previewer.lua | 5 ++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 lua/tests/automated/telescope_basics_spec.lua create mode 100644 lua/tests/automated/telescope_invoke_snippets_previewer.lua diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ab6edc2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: Tests + +on: [push, pull_request] + +jobs: + unit_tests: + name: unit tests + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz + manager: sudo apt-get + #packages: -y fd-find mlocate + - os: ubuntu-20.04 + url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-linux64.tar.gz + manager: sudo apt-get + #packages: -y fd-find mlocate + steps: + - uses: actions/checkout@v2 + - run: date +%F > todays-date + - name: Restore from todays cache + uses: actions/cache@v2 + with: + path: _neovim + key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }} + + - name: Prepare + run: | + ${{ matrix.manager }} update + ${{ matrix.manager }} install ${{ matrix.packages }} + test -d _neovim || { + mkdir -p _neovim + curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim" + } + mkdir -p ~/.local/share/nvim/site/pack/vendor/start + git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim + git clone --depth 1 https://github.com/nvim-telescope/telescope.nvim ~/.local/share/nvim/site/pack/vendor/start/telescope.nvim + git clone --depth 1 https://github.com/L3MON4D3/LuaSnip.nvim ~/.local/share/nvim/site/pack/vendor/start/LuaSnip.nvim + ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start + + - name: Run tests + run: | + export PATH="${PWD}/_neovim/bin:${PATH}" + nvim --version + make test_ci diff --git a/Makefile b/Makefile index c27165e..0b5aadd 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ -.PHONY: lint stylua +.PHONY: test_ci, lint stylua +all: test_ci lint + +test_ci: + @nvim --headless -c "PlenaryBustedDirectory lua/tests/ {}" lint: - luacheck lua/telescope + @luacheck lua/telescope stylua: - stylua --color always lua/ - + @stylua --color always lua/ diff --git a/lua/tests/automated/telescope_basics_spec.lua b/lua/tests/automated/telescope_basics_spec.lua new file mode 100644 index 0000000..05d9aaa --- /dev/null +++ b/lua/tests/automated/telescope_basics_spec.lua @@ -0,0 +1,5 @@ +describe('sanity check tests: ', function() + it('Telescope builtin', function() + vim.cmd [[Telescope builtin]] + end) +end) diff --git a/lua/tests/automated/telescope_invoke_snippets_previewer.lua b/lua/tests/automated/telescope_invoke_snippets_previewer.lua new file mode 100644 index 0000000..2235916 --- /dev/null +++ b/lua/tests/automated/telescope_invoke_snippets_previewer.lua @@ -0,0 +1,5 @@ +describe('plugin smoke tests: ', function() + it('Telescope luasnip', function() + vim.cmd [[Telescope luasnip]] + end) +end)