Skip to content

Commit

Permalink
feat!: run luarocks test with neovim(-nightly) as a lua interpreter (#47
Browse files Browse the repository at this point in the history
)

* feat: run luarocks test with neovim(-nightly)

* ci: build luarocks-tag-release-action and push to cachix

* docs(readme): bump major version
  • Loading branch information
mrcjkb authored Jun 4, 2023
1 parent da322ea commit 3e20658
Show file tree
Hide file tree
Showing 14 changed files with 479 additions and 71 deletions.
12 changes: 12 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
return {
_all = {
coverage = false
},
default = {
verbose = true
},
tests = {
ROOT = {"tests"},
verbose = true
},
}
24 changes: 22 additions & 2 deletions .github/workflows/pr.yml → .github/workflows/nix-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
name: "Tests and checks"
on: pull_request

on:
pull_request:
push:
jobs:
checks:
runs-on: ubuntu-latest
Expand All @@ -11,6 +12,25 @@ jobs:
- uses: cachix/install-nix-action@v21
- name: Nix checks
run: nix flake check -L
build:
name: ${{ matrix.attribute }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
attribute:
- .#luarocks-tag-release-action
- .#devShells.x86_64-linux.default
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v21
- uses: cachix/cachix-action@v12
with:
name: neorocks
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build --accept-flake-config "${{matrix.attribute}}" -L
tests:
runs-on: ubuntu-latest
name: Tests
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
result
/luarocks
/lua_modules
/.luarocks
7 changes: 7 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ignore = {
"631", -- max_line_length
"122", -- read-only field of global variable
}
read_globals = {
"vim",
"describe",
"it",
"assert"
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Ability to run `luarocks test` with Neovim as an interpreter.

## [v4.0.1] - 2023-03-29
### Changed
Expand Down
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
```
> **Note**
>
> Use the `v4` tag to keep up with the latest releases, without breaking changes.
> Use the `v5` tag to keep up with the latest releases, without breaking changes.

## Inputs

Expand All @@ -73,7 +73,7 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
dependencies: |
plenary.nvim
Expand All @@ -89,12 +89,35 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
labels: |
neovim
```

### `test_interpreters`

Lua interpreters to run `luarocks test` with.
If no interpreter is set, or no [.busted file](https://lunarmodules.github.io/busted/#usage)
is present, no tests will be run.

Supported interpreters:

* `neovim-stable` - With access to the [Neovim 0.9 Lua API](https://neovim.io/doc/user/lua.html).
* `neovim-nightly` - With access to the Neovim nightly Lua API.
* `lua` - Plain luajit

Example:

```yaml
- name: LuaRocks Test and Upload
uses: nvim-neorocks/luarocks-tag-release@v5
with:
test_interpreters: |
neovim-stable
neovim-nightly
```

### `copy_directories`

Directories in the source directory to be copied to the rock installation prefix as-is. Useful for installing documentation and other files such as samples and tests.
Expand All @@ -103,7 +126,7 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
copy_directories: |
{{ neovim.plugin.dirs }}
Expand Down Expand Up @@ -151,7 +174,7 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
detailed_description: |
Publishes packages to LuaRocks when a git tag is pushed.
Expand All @@ -170,7 +193,7 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
template: "/path/to/my/template.rockspec"
```
Expand All @@ -185,7 +208,7 @@ Example:

```yaml
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
with:
license: "MIT"
```
Expand Down Expand Up @@ -225,7 +248,7 @@ jobs:
- name: Get new commits
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v4
uses: nvim-neorocks/luarocks-tag-release@v5
if: ${{ env.NEW_COMMIT_COUNT > 0 }}
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
Expand Down
13 changes: 12 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,21 @@ inputs:
But sometimes, GitHub does not recognise it,
in which case LuaRocks will fall back to this one.
required: false
test_interpreters:
description: |
Lua interpreters to run `luarocks test` with.
If not set, no tests will be run.
At the moment, "lua", "neovim-stable" and "neovim-nightly" are supported.
required: false
default: |
neovim-stable
neovim-nightly
runs:
using: "composite"
steps:
- uses: cachix/install-nix-action@v21
- run: nix profile install "${{ github.action_path }}#luarocks-tag-release-action"
- run: |
nix profile install --accept-flake-config "${{ github.action_path }}#luarocks-tag-release-action"
shell: bash
- run: luarocks-tag-release-action
env:
Expand All @@ -69,4 +79,5 @@ runs:
INPUT_TEMPLATE: ${{ inputs.template }}
INPUT_UPLOAD: ${{ inputs.upload }}
INPUT_LICENSE: ${{ inputs.license }}
INPUT_TEST_INTERPRETERS: ${{ inputs.test_interpreters }}
shell: bash
18 changes: 18 additions & 0 deletions bin/luarocks-tag-release-action.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ end
local license_input = os.getenv('INPUT_LICENSE')
local template_input = os.getenv('INPUT_TEMPLATE')

local interpreters_input = os.getenv('INPUT_TEST_INTERPRETERS')
---@type lua_interpreter[]
local test_interpreters = {}
if interpreters_input then
for _, input in pairs(parse_list_args(interpreters_input)) do
if input == 'neovim-stable' then
table.insert(test_interpreters, 'neolua')
elseif input == 'neovim-nightly' then
table.insert(test_interpreters, 'neolua-nightly')
elseif input == 'lua' then
table.insert(test_interpreters, 'lua')
else
error('Test interpreter ' .. input .. ' not supported.')
end
end
end

---@type Args
local args = {
github_repo = github_repo,
Expand All @@ -106,6 +123,7 @@ local args = {
or action_path .. '/resources/rockspec.template',
upload = getenv_or_err('INPUT_UPLOAD') == 'true',
license = license_input ~= '' and license_input or nil,
luarocks_test_interpreters = test_interpreters,
}
table.insert(args.dependencies, 1, 'lua >= 5.1')

Expand Down
Loading

0 comments on commit 3e20658

Please sign in to comment.