Skip to content

Commit 6585cbe

Browse files
authored
build: add luacov integration (#419)
1 parent 5e9a08b commit 6585cbe

File tree

9 files changed

+76
-0
lines changed

9 files changed

+76
-0
lines changed

.codecov.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
informational: true
6+
only_pulls: true
7+
patch:
8+
default:
9+
informational: true
10+
only_pulls: true

.github/workflows/ci.yml

+25
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,32 @@ jobs:
4141
mv nvim.appimage ./build/nvim
4242
}
4343
44+
- name: Get Luver Cache Key
45+
id: luver-cache-key
46+
env:
47+
CI_RUNNER_OS: ${{ runner.os }}
48+
run: |
49+
echo "::set-output name=value::${CI_RUNNER_OS}-luver-v1-$(date -u +%Y-%m-%d)"
50+
shell: bash
51+
- name: Setup Luver Cache
52+
uses: actions/cache@v2
53+
with:
54+
path: ~/.local/share/luver
55+
key: ${{ steps.luver-cache-key.outputs.value }}
56+
- name: Setup Lua
57+
uses: MunifTanjim/luver-action@v1
58+
with:
59+
default: 5.1.5
60+
lua_versions: 5.1.5
61+
luarocks_versions: 5.1.5:3.8.0
62+
- name: Setup luacov
63+
run: |
64+
luarocks install luacov
65+
4466
- name: Run tests
4567
run: |
4668
export PATH="${PWD}/build/:${PATH}"
4769
./scripts/test.sh
70+
71+
- name: Upload coverage to Codecov
72+
uses: codecov/codecov-action@v2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ tags
4444

4545
# Others
4646
.testcache
47+
luacov.*.out

.luacov

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include = {
2+
"lua%/neo%-tree",
3+
}

scripts/test.sh

+29
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
luacov_dir=""
6+
57
while [[ $# -gt 0 ]]; do
68
case "${1}" in
79
--clean)
@@ -36,6 +38,8 @@ function setup_environment() {
3638
if [[ ! -d "${plugins_dir}/plenary.nvim" ]]; then
3739
echo "[plugins] plenary.nvim: installing..."
3840
git clone https://github.com/nvim-lua/plenary.nvim "${plugins_dir}/plenary.nvim"
41+
# this commit broke luacov
42+
git -C "${plugins_dir}/plenary.nvim" revert --no-commit 9069d14a120cadb4f6825f76821533f2babcab92
3943
echo "[plugins] plenary.nvim: installed"
4044
echo
4145
fi
@@ -44,6 +48,31 @@ function setup_environment() {
4448
echo
4549
}
4650

51+
function luacov_start() {
52+
luacov_dir="$(dirname "$(luarocks which luacov 2>/dev/null | head -1)")"
53+
if [[ "${luacov_dir}" == "." ]]; then
54+
luacov_dir=""
55+
fi
56+
57+
if test -n "${luacov_dir}"; then
58+
rm -f luacov.*.out
59+
export LUA_PATH=";;${luacov_dir}/?.lua"
60+
fi
61+
}
62+
63+
function luacov_end() {
64+
if test -n "${luacov_dir}"; then
65+
luacov
66+
67+
echo
68+
tail -n +$(($(grep -n "^Summary$" luacov.report.out | cut -d":" -f1) - 1)) luacov.report.out
69+
fi
70+
}
71+
4772
setup_environment
4873

74+
luacov_start
75+
4976
make test
77+
78+
luacov_end

tests/neo-tree/command/command_current_spec.lua

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pcall(require, "luacov")
2+
13
local Path = require("plenary.path")
24
local util = require("tests.helpers.util")
35
local verify = require("tests.helpers.verify")

tests/neo-tree/command/command_spec.lua

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pcall(require, "luacov")
2+
13
local util = require("tests.helpers.util")
24
local verify = require("tests.helpers.verify")
35
local config = require("neo-tree").config

tests/neo-tree/sources/filesystem/filesystem_command_spec.lua

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pcall(require, "luacov")
2+
13
local util = require("tests.helpers.util")
24
local verify = require("tests.helpers.verify")
35
local config = require("neo-tree").config

tests/neo-tree/sources/filesystem/filesystem_netrw_hijack_spec.lua

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pcall(require, "luacov")
2+
13
local util = require("tests.helpers.util")
24
local verify = require("tests.helpers.verify")
35
local utils = require("neo-tree.utils")

0 commit comments

Comments
 (0)