Skip to content

Commit

Permalink
feat(ci): add luals checks on CI (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Mar 16, 2024
1 parent 79bb970 commit 2d0ecc4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
deps
**.DS_Store
.luarc.json
.ci
4 changes: 4 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
globals = { "vim", "MiniTest" }
max_line_length = false

exclude_files = { "deps" }
11 changes: 11 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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()" \
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2d0ecc4

Please sign in to comment.