Skip to content

Commit 184b674

Browse files
committed
Add comprehensive testing and CI setup
- Add plenary.nvim test suite with 9 test cases covering all plugin functionality - Add GitHub Actions CI testing Neovim v0.8, v0.9, v0.10, stable, and nightly - Add Makefile with development commands (test, lint, format, install, health) - Add stylua code formatting with proper configuration - Use hash-pinned GitHub Actions for security - Test coverage: plugin loading, filetype detection, tree-sitter, otter.nvim, health checks
1 parent cbc4dda commit 184b674

File tree

7 files changed

+348
-67
lines changed

7 files changed

+348
-67
lines changed

.github/workflows/ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: CI
3+
4+
"on":
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- "*"
11+
workflow_dispatch: {}
12+
merge_group:
13+
14+
concurrency:
15+
group: ${{github.workflow}}-${{github.ref}}
16+
cancel-in-progress: true
17+
18+
env:
19+
LUA_VERSION: "5.5"
20+
21+
jobs:
22+
test:
23+
name: Test
24+
25+
runs-on: ubuntu-24.04
26+
27+
strategy:
28+
matrix:
29+
neovim-version: ['v0.8', 'v0.9', 'v0.10', 'stable', 'nightly']
30+
31+
steps:
32+
- name: Checkout
33+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
34+
35+
- name: Setup Neovim
36+
uses: MunifTanjim/setup-neovim-action@5595675b7a0187e70489af966a26c43179d8ea5d # v1.1.0
37+
with:
38+
tag: ${{ matrix.neovim-version }}
39+
40+
- name: Setup dependencies
41+
run: make install
42+
43+
- name: Run tests
44+
run: make test
45+
46+
- name: Run health check
47+
run: make health
48+
49+
lint:
50+
name: Lint
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Checkout
55+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
56+
57+
- name: Setup Lua
58+
uses: leafo/gh-actions-lua@8aace3457a2fcf3f3c4e9007ecc6b869ff6d74d6 # v11.0.0
59+
with:
60+
luaVersion: ${{ env.LUA_VERSION }}
61+
62+
- name: Setup Luarocks
63+
uses: leafo/gh-actions-luarocks@4c082a5fad45388feaeb0798dbd82dbd7dc65bca # v5
64+
65+
- name: Install stylua
66+
run: luarocks install --server=https://luarocks.org/dev stylua
67+
68+
- name: Check formatting
69+
run: make lint

Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.PHONY: test lint format clean install help
2+
3+
# Default target
4+
help:
5+
@echo "Available commands:"
6+
@echo " test - Run all tests"
7+
@echo " lint - Check code formatting"
8+
@echo " format - Format code with stylua"
9+
@echo " health - Run plugin health check"
10+
@echo " install - Install dependencies for local development"
11+
@echo " clean - Clean temporary files"
12+
@echo " help - Show this help message"
13+
14+
# Test the plugin
15+
test:
16+
@echo "Running tests..."
17+
nvim --headless --noplugin -u tests/minimal_init.lua \
18+
-c "lua require('plenary.test_harness').test_directory('tests')"
19+
20+
# Check code formatting
21+
lint:
22+
@echo "Checking code formatting..."
23+
stylua --check .
24+
25+
# Format code
26+
format:
27+
@echo "Formatting code..."
28+
stylua .
29+
30+
# Run health check
31+
health:
32+
@echo "Running health check..."
33+
nvim --headless -c "runtime! plugin/arizona.lua" -c "checkhealth arizona" -c "quit"
34+
35+
# Install development dependencies
36+
install:
37+
@echo "Installing development dependencies..."
38+
@mkdir -p ~/.local/share/nvim/site/pack/dev/start
39+
@if [ ! -d ~/.local/share/nvim/site/pack/dev/start/plenary.nvim ]; then \
40+
echo "Installing plenary.nvim..."; \
41+
git clone https://github.com/nvim-lua/plenary.nvim \
42+
~/.local/share/nvim/site/pack/dev/start/plenary.nvim; \
43+
fi
44+
@if [ ! -d ~/.local/share/nvim/site/pack/dev/start/nvim-treesitter ]; then \
45+
echo "Installing nvim-treesitter..."; \
46+
git clone https://github.com/nvim-treesitter/nvim-treesitter \
47+
~/.local/share/nvim/site/pack/dev/start/nvim-treesitter; \
48+
fi
49+
@if [ ! -d ~/.local/share/nvim/site/pack/dev/start/otter.nvim ]; then \
50+
echo "Installing otter.nvim..."; \
51+
git clone https://github.com/jmbuhr/otter.nvim \
52+
~/.local/share/nvim/site/pack/dev/start/otter.nvim; \
53+
fi
54+
@echo "Dependencies installed!"
55+
56+
# Clean temporary files
57+
clean:
58+
@echo "Cleaning temporary files..."
59+
@find . -name "*.tmp" -delete
60+
@find . -name ".DS_Store" -delete
61+
@echo "Clean complete!"
62+
63+
# CI target (used by GitHub Actions)
64+
ci: lint test health

lua/arizona/health.lua

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,42 @@
33
local M = {}
44

55
function M.check()
6-
local health = vim.health
7-
8-
health.start("Arizona Framework")
9-
10-
-- Core feature: Filetype detection (always works)
11-
if vim.filetype.match({ filename = "test.herl" }) == "arizona" then
12-
health.ok("Filetype detection working (.herl → arizona)")
13-
else
14-
health.error("Filetype detection broken")
15-
end
16-
17-
-- Feature: Tree-sitter parser
18-
local ts_ok, parsers = pcall(require, "nvim-treesitter.parsers")
19-
if ts_ok then
20-
if parsers.get_parser_configs().arizona then
21-
health.ok("Tree-sitter parser configured")
22-
else
23-
health.error("Tree-sitter parser not configured")
24-
end
25-
else
26-
health.warn("nvim-treesitter not available")
27-
end
28-
29-
-- Feature: Language injection
30-
if pcall(require, "otter") then
31-
health.ok("Language injection available (otter.nvim found)")
32-
else
33-
health.warn("Language injection unavailable (install otter.nvim)")
34-
end
35-
36-
-- Current buffer status
37-
local current_ft = vim.bo.filetype
38-
if current_ft == "arizona" then
39-
health.start("Current Buffer")
40-
health.ok("Current buffer is Arizona template file")
41-
end
6+
local health = vim.health
7+
8+
health.start("Arizona Framework")
9+
10+
-- Core feature: Filetype detection (always works)
11+
if vim.filetype.match({ filename = "test.herl" }) == "arizona" then
12+
health.ok("Filetype detection working (.herl → arizona)")
13+
else
14+
health.error("Filetype detection broken")
15+
end
16+
17+
-- Feature: Tree-sitter parser
18+
local ts_ok, parsers = pcall(require, "nvim-treesitter.parsers")
19+
if ts_ok then
20+
if parsers.get_parser_configs().arizona then
21+
health.ok("Tree-sitter parser configured")
22+
else
23+
health.error("Tree-sitter parser not configured")
24+
end
25+
else
26+
health.warn("nvim-treesitter not available")
27+
end
28+
29+
-- Feature: Language injection
30+
if pcall(require, "otter") then
31+
health.ok("Language injection available (otter.nvim found)")
32+
else
33+
health.warn("Language injection unavailable (install otter.nvim)")
34+
end
35+
36+
-- Current buffer status
37+
local current_ft = vim.bo.filetype
38+
if current_ft == "arizona" then
39+
health.start("Current Buffer")
40+
health.ok("Current buffer is Arizona template file")
41+
end
4242
end
4343

4444
return M
45-

plugin/arizona.lua

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,50 @@
33

44
-- Prevent double loading
55
if vim.g.arizona_loaded then
6-
return
6+
return
77
end
88
vim.g.arizona_loaded = 1
99

1010
-- Core feature: Filetype detection
1111
vim.filetype.add({
12-
extension = { herl = "arizona" },
12+
extension = { herl = "arizona" },
1313
})
1414

1515
-- Feature: Tree-sitter parser registration
1616
local function setup_treesitter()
17-
local ok, parser_config = pcall(require, "nvim-treesitter.parsers")
18-
if not ok then
19-
return
20-
end
21-
22-
local parsers = parser_config.get_parser_configs()
23-
parsers.arizona = {
24-
install_info = {
25-
url = "https://github.com/arizona-framework/tree-sitter-arizona",
26-
files = { "src/parser.c" },
27-
branch = "main",
28-
},
29-
filetype = "arizona",
30-
}
17+
local ok, parser_config = pcall(require, "nvim-treesitter.parsers")
18+
if not ok then
19+
return
20+
end
21+
22+
local parsers = parser_config.get_parser_configs()
23+
parsers.arizona = {
24+
install_info = {
25+
url = "https://github.com/arizona-framework/tree-sitter-arizona",
26+
files = { "src/parser.c" },
27+
branch = "main",
28+
},
29+
filetype = "arizona",
30+
}
3131
end
3232

3333
-- Feature: Language injection via otter.nvim
3434
local function setup_language_injection()
35-
local ok, otter = pcall(require, "otter")
36-
if not ok then
37-
return
38-
end
39-
40-
-- Auto-activate on Arizona files
41-
vim.api.nvim_create_autocmd("FileType", {
42-
pattern = "arizona",
43-
group = vim.api.nvim_create_augroup("ArizonaLanguageInjection", { clear = true }),
44-
callback = function()
45-
otter.activate({ "html", "erlang" }, true)
46-
end,
47-
})
35+
local ok, otter = pcall(require, "otter")
36+
if not ok then
37+
return
38+
end
39+
40+
-- Auto-activate on Arizona files
41+
vim.api.nvim_create_autocmd("FileType", {
42+
pattern = "arizona",
43+
group = vim.api.nvim_create_augroup("ArizonaLanguageInjection", { clear = true }),
44+
callback = function()
45+
otter.activate({ "html", "erlang" }, true)
46+
end,
47+
})
4848
end
4949

5050
-- Auto-setup all features
5151
setup_treesitter()
5252
setup_language_injection()
53-

stylua.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
indent_type = "Spaces"
2+
indent_width = 2
3+
column_width = 100
4+
line_endings = "Unix"
5+
quote_style = "AutoPreferDouble"
6+
call_parentheses = "Always"

0 commit comments

Comments
 (0)