From 2d0ecc406f7b8a2c4fab5a7ed83967f6a35cbd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Sat, 16 Mar 2024 23:22:59 +0100 Subject: [PATCH] feat(ci): add luals checks on CI (#16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📃 Summary [apply 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 | 14 ++++++++++++-- README.md | 1 + 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .luacheckrc create mode 100644 .luarc.json diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d366984..b3cb4cc 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 4b3caad..929091c 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 0000000..084dc49 --- /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 0000000..1b8485f --- /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 d234a56..e2e2d78 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -# we disable the `all` command because some external tool might run it automatically .SUFFIXES: -all: +all: documentation lint luals test # runs all the test files. test: + make deps nvim --version | head -n 1 && echo '' nvim --headless --noplugin -u ./scripts/minimal_init.lua \ -c "lua require('mini.test').setup()" \ @@ -39,6 +39,16 @@ documentation-ci: deps documentation lint: stylua . -g '*.lua' -g '!deps/' +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 + # setup setup: ./scripts/setup.sh diff --git a/README.md b/README.md index b439a5d..fe55d9c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ - Tests with [mini.nvim `test` plugin](https://github.com/echasnovski/mini.nvim/blob/main/lua/mini/test.lua) - Versioned testing with [`bob`](https://github.com/MordechaiHadad/bob) - Linting with [Stylua](https://github.com/JohnnyMorganz/StyLua) +- LuaLS checks on CI (inspired by [lukas-reineke/ci-template.nvim](https://github.com/lukas-reineke/ci-template.nvim)) ## 📋 Installation