Skip to content

Commit 14d4f2d

Browse files
mrcjkbmfussenegger
authored andcommitted
ci: Replace plenary.nvim with busted
1 parent 8492131 commit 14d4f2d

File tree

7 files changed

+86
-23
lines changed

7 files changed

+86
-23
lines changed

.busted

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
return {
2+
_all = {
3+
coverage = false,
4+
lpath = "lua/?.lua;lua/?/init.lua",
5+
lua = "~/.luarocks/bin/nlua",
6+
},
7+
default = {
8+
verbose = true
9+
},
10+
tests = {
11+
verbose = true
12+
},
13+
}

.github/workflows/tests.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
pull_request: ~
55
push:
66
branches:
7-
- master
7+
- main
88

99
jobs:
1010
build:
@@ -22,18 +22,21 @@ jobs:
2222
with:
2323
path: _neovim
2424
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}
25-
26-
- name: Prepare plenary
27-
run: |
28-
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
29-
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
30-
3125
- name: Setup neovim
3226
uses: rhysd/action-setup-vim@v1
3327
with:
3428
neovim: true
3529
version: ${{ matrix.neovim_version }}
3630

31+
- name: Setup Lua
32+
uses: leso-kn/gh-actions-lua@master
33+
with:
34+
luaVersion: "5.1"
35+
36+
- name: Setup Luarocks
37+
uses: hishamhm/gh-actions-luarocks@master
38+
with:
39+
luarocksVersion: "3.11.0"
40+
3741
- name: Run tests
38-
run: |
39-
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
42+
run: luarocks test --local

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/luarocks
2+
/lua_modules
3+
/.luarocks

README.md

+35-11
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ This repository is a template for Neovim plugins written in Lua.
55
The intention is that you use this template to create a new repository where you then adapt this readme and add your plugin code.
66
The template includes the following:
77

8-
- GitHub workflows to run linters and tests
9-
- Packaging of tagged releases and upload to [LuaRocks](https://luarocks.org/)
10-
if a [`LUAROCKS_API_KEY`](https://luarocks.org/settings/api-keys) is added
11-
to the [GitHub Actions secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository)
12-
- Minimal test setup
8+
- GitHub workflows and configurations to run linters and tests
9+
- Packaging of tagged releases and upload to [LuaRocks][luarocks]
10+
if a [`LUAROCKS_API_KEY`][luarocks-api-key] is added
11+
to the [GitHub Actions secrets][gh-actions-secrets]
12+
- Minimal test setup:
13+
- A `scm` [rockspec][rockspec-format], `nvim-lua-plugin-scm-1.rockspec`
14+
- A `.busted` file
1315
- EditorConfig
1416
- A .luacheckrc
1517

@@ -22,6 +24,11 @@ To get started writing a Lua plugin, I recommend reading `:help lua-guide` and
2224
Anything that the majority of plugin authors will want to have is in scope of
2325
this starter template. Anything that is controversial is out-of-scope.
2426

27+
## Usage
28+
29+
- Click [Use this template][use-this-template]. Do not fork.
30+
- Rename `nvim-lua-plugin-scm-1.rockspec` and change the `package` name
31+
to the name of your plugin.
2532

2633
## Template License
2734

@@ -41,19 +48,36 @@ The remainder of the README is text that can be preserved in your plugin:
4148
### Run tests
4249

4350

44-
Running tests requires [plenary.nvim][plenary] to be checked out in the parent directory of *this* repository.
51+
Running tests requires either
52+
53+
- [luarocks][luarocks]
54+
- or [busted][busted] and [nlua][nlua]
55+
56+
to be installed[^1].
57+
58+
[^1]: The test suite assumes that `nlua` has been installed
59+
using luarocks into `~/.luarocks/bin/`.
60+
4561
You can then run:
4662

4763
```bash
48-
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
64+
luarocks test --local
65+
# or
66+
busted
4967
```
5068

5169
Or if you want to run a single test file:
5270

5371
```bash
54-
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/path_to_file.lua {minimal_init = 'tests/minimal.vim'}"
72+
luarocks test spec/path_to_file.lua --local
73+
# or
74+
busted spec/path_to_file.lua
5575
```
5676

57-
58-
[nvim-lua-guide]: https://github.com/nanotee/nvim-lua-guide
59-
[plenary]: https://github.com/nvim-lua/plenary.nvim
77+
[rockspec-format]: https://github.com/luarocks/luarocks/wiki/Rockspec-format
78+
[luarocks]: https://luarocks.org
79+
[luarocks-api-key]: https://luarocks.org/settings/api-keys
80+
[gh-actions-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
81+
[busted]: https://lunarmodules.github.io/busted/
82+
[nlua]: https://github.com/mfussenegger/nlua
83+
[use-this-template]: https://github.com/new?template_name=nvim-lua-plugin-template&template_owner=nvim-lua

nvim-lua-plugin-scm-1.rockspec

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
rockspec_format = '3.0'
2+
-- TODO: Rename this file and set the package
3+
package = "nvim-lua-plugin"
4+
version = "scm-1"
5+
source = {
6+
-- TODO: Update this URL
7+
url = "git+https://github.com/nvim-lua/nvim-lua-plugin-template"
8+
}
9+
dependencies = {
10+
-- Add runtime dependencies here
11+
-- e.g. "plenary.nvim",
12+
}
13+
test_dependencies = {
14+
"nlua"
15+
}
16+
build = {
17+
type = "builtin",
18+
copy_directories = {
19+
-- Add runtimepath directories, like
20+
-- 'plugin', 'ftplugin', 'doc'
21+
-- here. DO NOT add 'lua' or 'lib'.
22+
},
23+
}
File renamed without changes.

tests/minimal.vim

-3
This file was deleted.

0 commit comments

Comments
 (0)