ci: add GitHub Actions workflow and minimal test suite
This commit is contained in:
4 files changed
+100
No files matched your search
@@ -0,0 +1,30 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: JohnnyMorganz/stylua-action@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
version: latest
|
||||||
|
args: --check lua/ plugin/
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install Neovim
|
||||||
|
run: |
|
||||||
|
wget -q https://github.com/neovim/neovim/releases/download/v0.12.0/nvim-linux-x86_64.appimage -O /tmp/nvim.appimage
|
||||||
|
chmod +x /tmp/nvim.appimage
|
||||||
|
/tmp/nvim.appimage --appimage-extract > /dev/null 2>&1
|
||||||
|
echo "$PWD/squashfs-root/usr/bin" >> $GITHUB_PATH
|
||||||
|
- name: Run tests
|
||||||
|
run: ./scripts/test.sh
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Minimal init for testing tiny-packupdate.nvim
|
||||||
|
vim.opt.rtp:prepend(".")
|
||||||
|
vim.opt.rtp:prepend("deps/mini.nvim")
|
||||||
|
vim.cmd("runtime plugin/tiny-packupdate.lua")
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Clone mini.nvim for test framework (if not cached)
|
||||||
|
if [ ! -d deps/mini.nvim ]; then
|
||||||
|
mkdir -p deps
|
||||||
|
git clone --depth 1 https://github.com/echasnovski/mini.nvim deps/mini.nvim
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
nvim --headless -u scripts/minimal_init.lua -c "lua require('mini.test').setup(); MiniTest.run_file('tests/test_init.lua')"
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
local T = MiniTest.new_set()
|
||||||
|
local eq = MiniTest.expect.equality
|
||||||
|
|
||||||
|
-- ── Setup tests ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
T["setup"] = MiniTest.new_set()
|
||||||
|
|
||||||
|
T["setup"]["creates user command with default name"] = function()
|
||||||
|
-- plugin/ auto-loaded via minimal_init, so PackUpdate should exist
|
||||||
|
local cmds = vim.api.nvim_get_commands({})
|
||||||
|
eq(cmds["PackUpdate"] ~= nil, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
T["setup"]["respects custom command name"] = function()
|
||||||
|
require("tiny-packupdate").setup({ command = "PlugSync" })
|
||||||
|
local cmds = vim.api.nvim_get_commands({})
|
||||||
|
eq(cmds["PlugSync"] ~= nil, true)
|
||||||
|
-- Cleanup: delete the custom command
|
||||||
|
vim.api.nvim_del_user_command("PlugSync")
|
||||||
|
end
|
||||||
|
|
||||||
|
T["setup"]["is idempotent"] = function()
|
||||||
|
-- Calling setup twice should not error
|
||||||
|
require("tiny-packupdate").setup()
|
||||||
|
require("tiny-packupdate").setup()
|
||||||
|
local cmds = vim.api.nvim_get_commands({})
|
||||||
|
eq(cmds["PackUpdate"] ~= nil, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
T["setup"]["sets highlight group"] = function()
|
||||||
|
require("tiny-packupdate").setup()
|
||||||
|
local hl = vim.api.nvim_get_hl(0, { name = "TinyPackProgress" })
|
||||||
|
eq(hl.link ~= nil or hl.fg ~= nil, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ── Timestamp tests ───────────────────────────────────────────────────
|
||||||
|
|
||||||
|
T["timestamp"] = MiniTest.new_set()
|
||||||
|
|
||||||
|
T["timestamp"]["roundtrip read/write"] = function()
|
||||||
|
local path = vim.fn.stdpath("data") .. "/tiny-packupdate-last"
|
||||||
|
-- Write a known timestamp
|
||||||
|
local f = io.open(path, "w")
|
||||||
|
f:write("1700000000")
|
||||||
|
f:close()
|
||||||
|
-- Read it back through the module's stamp path
|
||||||
|
local f2 = io.open(path, "r")
|
||||||
|
local val = tonumber(f2:read("*a"))
|
||||||
|
f2:close()
|
||||||
|
eq(val, 1700000000)
|
||||||
|
-- Cleanup
|
||||||
|
os.remove(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
return T
|
||||||
Reference in new issue
Block a user