File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ strategy :
13+ fail-fast : false
14+ matrix :
15+ neovim : ['v0.11.0', 'nightly']
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Setup Neovim
20+ uses : rhysd/action-setup-vim@v1
21+ with :
22+ neovim : true
23+ version : ${{ matrix.neovim }}
24+
25+ - name : Install LuaRocks
26+ run : sudo apt-get install -y luarocks
27+
28+ - name : Install luacov
29+ run : |
30+ sudo luarocks install luacov
31+ sudo luarocks install luacov-reporter-lcov
32+
33+ - name : Clone plenary.nvim
34+ run : |
35+ mkdir -p ~/.local/share/nvim/site/pack/vendor/start
36+ git clone --depth 1 https://github.com/nvim-lua/plenary.nvim \
37+ ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
38+
39+ - name : Run tests
40+ run : ./scripts/test.sh
41+
42+ - name : Run tests with coverage
43+ if : matrix.neovim == 'v0.11.0'
44+ env :
45+ LUA_PATH : ' /usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;;'
46+ LUA_CPATH : ' /usr/local/lib/lua/5.1/?.so;;'
47+ run : ./scripts/test-coverage.sh
48+
49+ - name : Upload coverage to Codecov
50+ if : matrix.neovim == 'v0.11.0'
51+ uses : codecov/codecov-action@v5
52+ with :
53+ files : ./lcov.info
54+ fail_ci_if_error : false
Original file line number Diff line number Diff line change 1+ return {
2+ include = {
3+ "lua/shelltime/.+%.lua$",
4+ },
5+ exclude = {
6+ "tests/",
7+ "plugin/",
8+ },
9+ }
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Run tests with code coverage using luacov
3+ # Requires: luacov, luacov-reporter-lcov installed via luarocks
4+
5+ set -e
6+
7+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
8+ PROJECT_DIR=" $( dirname " $SCRIPT_DIR " ) "
9+
10+ cd " $PROJECT_DIR "
11+
12+ # Clean previous coverage data
13+ rm -f luacov.stats.out luacov.report.out lcov.info
14+
15+ # Run tests with coverage init (loads luacov before test code)
16+ nvim --headless \
17+ -u " $PROJECT_DIR /tests/coverage_init.lua" \
18+ -c " PlenaryBustedDirectory tests/ {minimal_init = 'tests/coverage_init.lua'}" \
19+ 2>&1 || true
20+
21+ # Generate lcov report for Codecov
22+ if [ -f luacov.stats.out ]; then
23+ luacov -r lcov -o lcov.info
24+ echo " Coverage report generated: lcov.info"
25+ else
26+ echo " Warning: No coverage stats generated (luacov may not be installed)"
27+ # Don't fail CI if coverage isn't available
28+ exit 0
29+ fi
Original file line number Diff line number Diff line change 1+ -- Coverage init for running tests with luacov
2+ -- This file wraps minimal_init.lua and adds luacov support
3+
4+ -- Initialize luacov BEFORE loading any other modules
5+ local ok , luacov = pcall (require , ' luacov' )
6+ if not ok then
7+ print (' Warning: luacov not found, running tests without coverage' )
8+ end
9+
10+ -- Load the regular minimal init
11+ local script_path = debug.getinfo (1 , ' S' ).source :sub (2 )
12+ local tests_dir = vim .fn .fnamemodify (script_path , ' :h' )
13+ dofile (tests_dir .. ' /minimal_init.lua' )
14+
15+ -- Save coverage stats on exit
16+ vim .api .nvim_create_autocmd (' VimLeavePre' , {
17+ callback = function ()
18+ if ok and luacov then
19+ local runner = require (' luacov.runner' )
20+ runner .save_stats ()
21+ end
22+ end ,
23+ })
Original file line number Diff line number Diff line change 55local plugin_dir = vim .fn .fnamemodify (debug.getinfo (1 , ' S' ).source :sub (2 ), ' :h:h' )
66vim .opt .rtp :prepend (plugin_dir )
77
8- -- Add tests directory to package path for helpers
8+ -- Add project root to package path for 'tests.helpers' requires
9+ package.path = plugin_dir .. ' /?.lua;' .. package.path
10+ package.path = plugin_dir .. ' /?/init.lua;' .. package.path
11+
12+ -- Add tests directory to package path for 'helpers' requires
913package.path = plugin_dir .. ' /tests/?.lua;' .. package.path
1014package.path = plugin_dir .. ' /tests/?/init.lua;' .. package.path
1115
You can’t perform that action at this time.
0 commit comments