Skip to content

Commit

Permalink
Merge pull request #14 from yriveiro/docker-tests
Browse files Browse the repository at this point in the history
feat: dockerize tests
  • Loading branch information
yriveiro authored Jan 7, 2024
2 parents 22f3548 + 18fdb36 commit 01421c3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM alpine:3

WORKDIR /nvim

RUN <<EOF
\apk --no-cache update
\apk add --no-cache neovim=0.9.4-r0 git=2.43.0-r0 make=4.4.1-r2

\git clone --depth 1 https://github.com/nvim-lua/plenary.nvim /nvim/plugins/plenary.nvim
\git clone --depth 1 https://github.com/tjdevries/tree-sitter-lua /nvim/plugins/tree-sitter-lua
\git clone --depth 1 https://github.com/neovim/nvim-lspconfig /nvim/plugins/nvim-lspconfig
\git clone --depth 1 https://github.com/mfussenegger/nvim-dap /nvim/plugins/nvim-dap
EOF

WORKDIR /nvim-dap

COPY --chmod=775 . .
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test:
bash ./scripts/run_tests.sh
@printf "\nRunning tests\n"
@docker run -it --rm local/nvim-dap:latest sh ./scripts/run_tests.sh

lint:
@printf "\nRunning luacheck\n"
Expand All @@ -8,4 +9,7 @@ lint:
docgen:
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "luafile ./scripts/gendocs.lua" -c 'qa'

.PHONY: test lint docgen
build:
@docker buildx build -t local/nvim-dap .

.PHONY: test lint docgen build
7 changes: 5 additions & 2 deletions scripts/gendocs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ docs.test = function()
docgen.write(input_file, output_file_handle)
end

output_file_handle:write(' vim:tw=78:ts=8:ft=help:norl:\n')
output_file_handle:close()
if output_file_handle then
output_file_handle:write(' vim:tw=78:ts=8:ft=help:norl:\n')
output_file_handle:close()
end

vim.cmd([[checktime]])
end

Expand Down
6 changes: 3 additions & 3 deletions scripts/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vim.cmd([[set runtimepath+=.]])
vim.cmd([[set rtp+=~/.local/share/nvim/site/pack/vendor/star/plenary.nvim/]])
vim.cmd([[set rtp+=~/.local/share/nvim/site/pack/vendor/star/nvim-dap]])
vim.cmd([[set rtp+=~/.local/share/nvim/site/pack/vendor/star/nvim-lspconfig]])
vim.cmd([[set rtp+=/nvim/plugins/plenary.nvim]])
vim.cmd([[set rtp+=/nvim/plugins/nvim-dap]])
vim.cmd([[set rtp+=/nvim/plugins/nvim-lspconfig]])

vim.cmd([[runtime! plugin/plenary.vim]])
vim.cmd([[runtime! plugin/nvim-dap.vim]])
Expand Down
24 changes: 14 additions & 10 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env bash
#!/bin/sh

HERE="$(dirname "$(realpath "$0")")"
MINIMAL_TEST="scripts/minimal_init.lua"

HERE="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
cd $HERE/..

run() {
nvim --headless --noplugin -u scripts/minimal_init.lua \
-c "PlenaryBustedDirectory $1 { minimal_init = './scripts/minimal_init.lua' }"
nvim --headless --noplugin -u "${MINIMAL_TEST}" \
-c "PlenaryBustedDirectory $1 { minimal_init = './${MINIMAL_TEST}' }"
}

if [[ $2 = '--summary' ]]; then
## really simple results summary by filtering plenary busted output
run tests/$1 2> /dev/null | grep -E '^\S*(Success|Fail(ed)?|Errors?)\s*:'
else
run tests/$1
fi
case "$2" in
'--summary')
run tests/$1 2>/dev/null | grep -E '^\S*(Success|Fail(ed)?|Errors?)\s*:'
;;
*)
run tests/$1
;;
esac

0 comments on commit 01421c3

Please sign in to comment.