From ec8e69a30ff863128bbec06ffc4ccd17cf4d4e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Sat, 16 Mar 2024 23:16:31 +0100 Subject: [PATCH] chore: try luals on ci (#316) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📃 Summary [trying out recommendations](https://www.reddit.com/r/neovim/comments/1bfdp9m/comment/kv2ljvo/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button) --- .github/workflows/main.yml | 20 ++++++++++++++++++++ .gitignore | 2 +- .luacheckrc | 4 ++++ .luarc.json | 11 +++++++++++ Makefile | 18 +++++++++++++----- tests/test_buffers.lua | 2 +- 6 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .luacheckrc create mode 100644 .luarc.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebc499cd..65d4a9e7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,9 @@ on: pull_request: types: [opened, synchronize] +env: + LUA_LS_VERSION: 3.7.4 + concurrency: group: github.head_ref cancel-in-progress: true @@ -64,12 +67,29 @@ jobs: path: _neovim key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }} + - name: restore luals cache + uses: actions/cache@v4 + id: cache + with: + path: .ci/lua-ls + key: ${{ env.LUA_LS_VERSION }} + + - name: setup luals + if: ${{ steps.cache.outputs.cache-hit != 'true' }} + run: mkdir -p .ci/lua-ls && curl -sL "https://github.com/LuaLS/lua-language-server/releases/download/${{ env.LUA_LS_VERSION }}/lua-language-server-${{ env.LUA_LS_VERSION }}-linux-x64.tar.gz" | tar xzf - -C "${PWD}/.ci/lua-ls" + - name: setup neovim uses: rhysd/action-setup-vim@v1 with: neovim: true version: ${{ matrix.neovim_version }} + - name: run luals + run: | + export PATH="${PWD}/.ci/lua-ls/bin:${PATH}" + nvim --version + make luals-ci + - name: run tests run: make test-ci diff --git a/.gitignore b/.gitignore index 4b3caad9..929091c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ deps **.DS_Store -.luarc.json +.ci diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 00000000..084dc497 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,4 @@ +globals = { "vim", "MiniTest" } +max_line_length = false + +exclude_files = { "deps" } diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 00000000..1b8485f6 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,11 @@ +{ + "runtime.version": "LuaJIT", + "diagnostics.globals": [ + "vim", + "MiniTest" + ], + "workspace.library": [ + "/usr/local/share/nvim/runtime/lua", + ".ci/neovim/share/nvim/runtime/lua" + ] +} diff --git a/Makefile b/Makefile index afcc684e..9b73bb58 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,10 @@ TESTFILES=options mappings API splits tabs integrations buffers colors autocmds scratchpad commands -all: +all: documentation lint luals test test: + make deps nvim --version | head -n 1 && echo '' nvim --headless --noplugin -u ./scripts/minimal_init.lua \ -c "lua MiniTest.run({ execute = { reporter = MiniTest.gen_reporter.stdout({ group_depth = 2 }) } })" @@ -21,22 +22,19 @@ $(addprefix test-, $(TESTFILES)): test-%: nvim --version | head -n 1 && echo '' nvim --headless --noplugin -u ./scripts/minimal_init.lua \ -c "lua MiniTest.run_file('tests/test_$*.lua', { execute = { reporter = MiniTest.gen_reporter.stdout({ group_depth = 2 }) } })" - deps: - @mkdir -p deps + git clone --depth 1 https://github.com/nvim-lua/plenary.nvim deps/plenary git clone --depth 1 https://github.com/echasnovski/mini.nvim deps/mini.nvim git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter deps/nvim-treesitter git clone --depth 1 https://github.com/nvim-treesitter/playground deps/playground git clone --depth 1 https://github.com/nvim-neotest/neotest deps/neotest git clone --depth 1 https://github.com/nvim-tree/nvim-tree.lua deps/nvimtree git clone --depth 1 https://github.com/nvim-neo-tree/neo-tree.nvim deps/neo-tree - git clone --depth 1 https://github.com/nvim-lua/plenary.nvim deps/plenary git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons deps/nvim-web-devicons git clone --depth 1 https://github.com/MunifTanjim/nui.nvim deps/nui git clone --depth 1 https://github.com/antoinemadec/FixCursorHold.nvim deps/fixcursorhold git clone --depth 1 https://github.com/mfussenegger/nvim-dap deps/nvimdap git clone --depth 1 https://github.com/rcarriga/nvim-dap-ui deps/nvimdapui - test-ci: deps test @@ -47,3 +45,13 @@ documentation-ci: deps documentation lint: stylua . -g '*.lua' -g '!deps/' -g '!nightly/' + +luals-ci: + rm -rf .ci/lua-ls/log + lua-language-server --configpath .luarc.json --logpath .ci/lua-ls/log --check . + [ -f .ci/lua-ls/log/check.json ] && { cat .ci/lua-ls/log/check.json 2>/dev/null; exit 1; } || true + +luals: + mkdir -p .ci/lua-ls + curl -sL "https://github.com/LuaLS/lua-language-server/releases/download/3.7.4/lua-language-server-3.7.4-darwin-x64.tar.gz" | tar xzf - -C "${PWD}/.ci/lua-ls" + make luals-ci diff --git a/tests/test_buffers.lua b/tests/test_buffers.lua index bef32536..2fea2ca5 100644 --- a/tests/test_buffers.lua +++ b/tests/test_buffers.lua @@ -220,7 +220,7 @@ T["curr"]["closing `curr` window without any other window quits Neovim"] = funct -- neovim is closed, so it errors Helpers.expect.error(function() - helpers.winsInTab(child) + Helpers.winsInTab(child) end) end