chore: Add docker test runners for local development

This commit is contained in:
Dmytro Soltys
2025-04-08 19:18:54 +02:00
committed by TheLeoP
parent c478d4a72b
commit 113d6c97e8
4 changed files with 86 additions and 10 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.github
.gitignore
.gitlab-ci-yml
.luacheckrc
.projections.json
.vintrc
*Dockerfile
test/new/env

25
Makefile Normal file
View File

@@ -0,0 +1,25 @@
PHONY: docker_build docker_test_nvim
RUNFOR ?= nvim
VIMCMD = $(shell if [ $(RUNFOR) = nvim ]; then echo "nvim --headless"; else echo "vim -T dumb --not-a-term -n"; fi)
VIMCMD != if [ $(RUNFOR) = nvim ]; then echo "nvim --headless"; else echo "vim -T dumb --not-a-term -n"; fi
NVIM_VERSION ?= stable
NVIM_ARCH ?= -linux-x86_64
VIM_VERSION ?= v9.1.1287
docker_build:
docker build --tag 'vim-matchup-nvim-stable' \
--file vim.Dockerfile \
--build-arg NVIM_VERSION=${NVIM_VERSION} \
--build-arg NVIM_ARCH=${NVIM_ARCH} \
--build-arg VIM_VERSION=${VIM_VERSION} \
.
docker_test_old: docker_build
docker run --rm -it --pull=never --name nvim vim-matchup-nvim-stable -c 'VIMCMD="${VIMCMD}" test/vader/run'
docker_test_new: docker_build
docker run --rm -it --pull=never --name nvim vim-matchup-nvim-stable -c 'cd ./test/new && make -j1 MYVIM="${VIMCMD}"'
docker_test_shell: docker_build
docker run --rm -it --pull=never --name nvim vim-matchup-nvim-stable

View File

@@ -5,6 +5,7 @@ COVER = covimerage -q run --append --no-report \
--source $(CURDIR)/../../plugin
MYVIM ?= nvim --headless
MAKEFLAGS += --no-print-directory
VENV = . env/bin/activate;
TESTS := $(wildcard test-*)
@@ -19,27 +20,24 @@ sysinfo:
@echo "**** SYSTEM INFORMATION ****"
$(TESTS): env
@. env/bin/activate
mkdir -p cov.tmp
MYVIM="$(COVER) $(MYVIM)" $(MAKE) -C $@
$(VENV) mkdir -p cov.tmp
$(VENV) MYVIM="$(COVER) $(MYVIM)" $(MAKE) -C $@
coverage: coverage.xml
cov.tmp/coverage_covimerage: $(wildcard cov.tmp/_*)
coverage combine $^
$(VENV) coverage combine $^
coverage.xml: env cov.tmp/coverage_covimerage
. env/bin/activate
coverage report -m
coverage html
coverage xml
$(VENV) coverage report -m
$(VENV) coverage html
$(VENV) coverage xml
env: env/pyvenv.cfg
env/pyvenv.cfg:
python3 -m venv env
. env/bin/activate
pip install -r requirements.txt
$(VENV) pip install -r requirements.txt
ifndef MAKECMDGOALS
test: sysinfo

45
vim.Dockerfile Normal file
View File

@@ -0,0 +1,45 @@
FROM debian:latest AS neovim-image
ARG NVIM_VERSION=stable
ARG NVIM_ARCH=-linux-x86_64
ADD --chmod=755 https://github.com/neovim/neovim/releases/download/${NVIM_VERSION}/nvim${NVIM_ARCH}.appimage /nvim-linux-x86_64.appimage
RUN /nvim-linux-x86_64.appimage --appimage-extract
FROM debian:latest AS vim-image
ARG VIM_VERSION=v9.1.1287
ADD --chmod=755 https://github.com/vim/vim-appimage/releases/download/${VIM_VERSION}/Vim-${VIM_VERSION}.glibc2.29-x86_64.AppImage /vim-linux-x86_64.appimage
RUN /vim-linux-x86_64.appimage --appimage-extract
FROM python:latest AS base
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
apt-get update -qq && \
apt-get install --no-install-recommends -y \
git \
ca-certificates \
make
FROM base AS test-prep
WORKDIR /work
COPY test/new/requirements.txt test/new/requirements.txt
COPY test/new/Makefile test/new/Makefile
RUN cd test/new && make env
RUN mkdir -p test/vader/vader.vim && git clone --depth=1 https://github.com/junegunn/vader.vim.git test/vader/vader.vim
FROM python:latest AS nvim
# nvim
COPY --from=neovim-image /squashfs-root /nvim-root
RUN ln -s /nvim-root/AppRun /bin/nvim
# vim
COPY --from=vim-image /squashfs-root /vim-root
RUN ln -s /vim-root/AppRun /bin/vim
WORKDIR /work
ENV HOME=/work
ENV GIT_PAGER=cat
COPY . .
COPY --from=test-prep /work/test test
ENTRYPOINT ["bash"]