Skip to content

Commit aaed30f

Browse files
authored
chore: ci and stylua (#36)
* chore: ci * chore: reformat with stylua * fix: small fix
1 parent d7093a5 commit aaed30f

28 files changed

+1176
-911
lines changed

.github/workflows/ci.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tree-sitter:
7+
name: tree-sitter
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v2
12+
with:
13+
node-version: '14'
14+
- run: npm install
15+
- name: Generate grammar
16+
run: make generate
17+
- name: Run tests
18+
run: ./node_modules/tree-sitter-cli/tree-sitter test
19+
20+
docgen:
21+
name: X64-ubuntu
22+
runs-on: ubuntu-20.04
23+
steps:
24+
- uses: actions/checkout@v2
25+
- run: date +%F > todays-date
26+
- name: Restore cache for today's nightly.
27+
uses: actions/cache@v2
28+
with:
29+
path: _neovim
30+
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
31+
32+
- name: Prepare
33+
run: |
34+
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
35+
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
36+
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
37+
- name: Build parser
38+
run: |
39+
# We have to build the parser every single time to keep up with parser changes
40+
mkdir -p build parser
41+
cc -o ./build/parser.so -I./src src/parser.c src/scanner.cc -shared -Os -lstdc++ -fPIC
42+
ln -s ../build/parser.so parser/lua.so
43+
- name: Run tests
44+
run: |
45+
curl -OL https://raw.githubusercontent.com/norcalli/bot-ci/master/scripts/github-actions-setup.sh
46+
source github-actions-setup.sh nightly-x64
47+
nvim --headless --noplugin \
48+
-u tests/minimal_init.vim \
49+
-c "PlenaryBustedDirectory lua/tests/ {minimal_init = 'tests/minimal_init.vim'}"

.github/workflows/lint.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Linting and style checking
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
luacheck:
7+
name: Luacheck
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Prepare
12+
run: |
13+
sudo apt-get update
14+
sudo apt-get install -y luarocks
15+
sudo luarocks install luacheck
16+
- name: Lint
17+
run: sudo make lualint
18+
19+
stylua:
20+
name: stylua
21+
runs-on: ubuntu-20.04
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: JohnnyMorganz/[email protected]
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
# CLI arguments
28+
args: --color always --check lua/

.luacheckrc

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Rerun tests only if their modification time changed.
2+
cache = true
3+
4+
std = luajit
5+
codes = true
6+
7+
self = false
8+
9+
-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html
10+
ignore = {
11+
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
12+
"122", -- Indirectly setting a readonly global
13+
"331"
14+
}
15+
16+
globals = {
17+
"_",
18+
}
19+
20+
-- Global objects defined by the C code
21+
read_globals = {
22+
"vim",
23+
}

.stylua.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
column_width = 120
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 2
5+
quote_style = "AutoPreferDouble"
6+
no_call_parentheses = true

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ build_parser: generate
3333
gen_howto:
3434
nvim --headless --noplugin -u tests/minimal_init.vim -c "luafile ./scratch/gen_howto.lua" -c 'qa'
3535

36+
lualint:
37+
luacheck lua/docgen
38+
3639
wasm: build_parser
3740
${ts} build-wasm
3841

0 commit comments

Comments
 (0)