Skip to content

feat(ci): add luacov-console and enhance installation docs #18

feat(ci): add luacov-console and enhance installation docs

feat(ci): add luacov-console and enhance installation docs #18

Workflow file for this run

name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
neovim-version: ["stable", "nightly"]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
persist-credentials: false
- name: Setup Neovim
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
with:
neovim: true
version: ${{ matrix.neovim-version }}
- name: Setup Lua
uses: leafo/gh-actions-lua@8aace3457a2fcf3f3c4e9007ecc6b869ff6d74d6 # v11
with:
luaVersion: "5.1"
- name: Setup Luarocks
uses: leafo/gh-actions-luarocks@4c082a5fad45388feaeb0798dbd82dbd7dc65bca # v5
- name: Install dependencies
run: |
luarocks install luacheck
luarocks install busted
luarocks install luacov
luarocks install luacov-reporter-lcov
- name: Run Luacheck
run: luacheck lua/ tests/ --no-unused-args --no-max-line-length
- name: Run tests
run: |
chmod +x ./run_tests.sh
./run_tests.sh
- name: Generate coverage report
run: |
# Check if stats file exists (created by busted --coverage)
if [ -f "luacov.stats.out" ]; then
# Generate the regular luacov report
luacov
# Convert to lcov format if luacov-reporter-lcov is installed
if command -v luacov-reporter-lcov &> /dev/null; then
luacov-reporter-lcov
if [ -f "luacov.report.out.lcov" ]; then
cp luacov.report.out.lcov lcov.info
else
# Fallback if lcov format not generated
echo "Creating simple lcov.info from luacov.report.out"
{
echo "TN:"
grep -E "^Summary$" -A1000 luacov.report.out | grep -E "^[^ ].*:" | while read -r line; do
file=$(echo "$line" | cut -d':' -f1)
echo "SF:$file"
percent=$(echo "$line" | grep -oE "[0-9\.]+%" | tr -d '%')
if [ -n "$percent" ]; then
echo "DA:1,1"
echo "LF:1"
echo "LH:$percent"
fi
echo "end_of_record"
done
} > lcov.info
fi
else
echo "luacov-reporter-lcov not found, generating simple lcov.info"
{
echo "TN:"
grep -E "^Summary$" -A1000 luacov.report.out | grep -E "^[^ ].*:" | while read -r line; do
file=$(echo "$line" | cut -d':' -f1)
echo "SF:$file"
percent=$(echo "$line" | grep -oE "[0-9\.]+%" | tr -d '%')
if [ -n "$percent" ]; then
echo "DA:1,1"
echo "LF:1"
echo "LH:$percent"
fi
echo "end_of_record"
done
} > lcov.info
fi
else
echo "No coverage data found in luacov.stats.out"
touch lcov.info
fi
- name: Upload coverage report
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4
with:
files: ./lcov.info
fail_ci_if_error: false
integration-tests:
runs-on: ubuntu-latest
needs: unit-tests
strategy:
matrix:
neovim-version: ["stable"]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
persist-credentials: false
- name: Setup Neovim
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
with:
neovim: true
version: ${{ matrix.neovim-version }}
- name: Install test dependencies
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/claudecode.nvim
- name: Run integration tests
run: |
nvim --headless -u tests/minimal_init.lua -c "lua require('plenary.test_harness').test_directory('tests/integration', {minimal_init = 'tests/minimal_init.lua'})"