Skip to content

Commit

Permalink
ci: Replace plenary.nvim with busted
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored and mfussenegger committed May 31, 2024
1 parent 8492131 commit 14d4f2d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 23 deletions.
13 changes: 13 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua",
lua = "~/.luarocks/bin/nlua",
},
default = {
verbose = true
},
tests = {
verbose = true
},
}
21 changes: 12 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request: ~
push:
branches:
- master
- main

jobs:
build:
Expand All @@ -22,18 +22,21 @@ jobs:
with:
path: _neovim
key: ${{ runner.os }}-x64-${{ hashFiles('todays-date') }}

- name: Prepare plenary
run: |
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
- name: Setup neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim_version }}

- name: Setup Lua
uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"

- name: Setup Luarocks
uses: hishamhm/gh-actions-luarocks@master
with:
luarocksVersion: "3.11.0"

- name: Run tests
run: |
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
run: luarocks test --local
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/luarocks
/lua_modules
/.luarocks
46 changes: 35 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ This repository is a template for Neovim plugins written in Lua.
The intention is that you use this template to create a new repository where you then adapt this readme and add your plugin code.
The template includes the following:

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

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

## Usage

- Click [Use this template][use-this-template]. Do not fork.
- Rename `nvim-lua-plugin-scm-1.rockspec` and change the `package` name
to the name of your plugin.

## Template License

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


Running tests requires [plenary.nvim][plenary] to be checked out in the parent directory of *this* repository.
Running tests requires either

- [luarocks][luarocks]
- or [busted][busted] and [nlua][nlua]

to be installed[^1].

[^1]: The test suite assumes that `nlua` has been installed
using luarocks into `~/.luarocks/bin/`.

You can then run:

```bash
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
luarocks test --local
# or
busted
```

Or if you want to run a single test file:

```bash
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/path_to_file.lua {minimal_init = 'tests/minimal.vim'}"
luarocks test spec/path_to_file.lua --local
# or
busted spec/path_to_file.lua
```


[nvim-lua-guide]: https://github.com/nanotee/nvim-lua-guide
[plenary]: https://github.com/nvim-lua/plenary.nvim
[rockspec-format]: https://github.com/luarocks/luarocks/wiki/Rockspec-format
[luarocks]: https://luarocks.org
[luarocks-api-key]: https://luarocks.org/settings/api-keys
[gh-actions-secrets]: https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository
[busted]: https://lunarmodules.github.io/busted/
[nlua]: https://github.com/mfussenegger/nlua
[use-this-template]: https://github.com/new?template_name=nvim-lua-plugin-template&template_owner=nvim-lua
23 changes: 23 additions & 0 deletions nvim-lua-plugin-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
rockspec_format = '3.0'
-- TODO: Rename this file and set the package
package = "nvim-lua-plugin"
version = "scm-1"
source = {
-- TODO: Update this URL
url = "git+https://github.com/nvim-lua/nvim-lua-plugin-template"
}
dependencies = {
-- Add runtime dependencies here
-- e.g. "plenary.nvim",
}
test_dependencies = {
"nlua"
}
build = {
type = "builtin",
copy_directories = {
-- Add runtimepath directories, like
-- 'plugin', 'ftplugin', 'doc'
-- here. DO NOT add 'lua' or 'lib'.
},
}
File renamed without changes.
3 changes: 0 additions & 3 deletions tests/minimal.vim

This file was deleted.

0 comments on commit 14d4f2d

Please sign in to comment.