From 113d6c97e85286b50410ec1e0fcc3cd674a727c6 Mon Sep 17 00:00:00 2001 From: Dmytro Soltys Date: Tue, 8 Apr 2025 19:18:54 +0200 Subject: [PATCH] chore: Add docker test runners for local development --- .dockerignore | 8 ++++++++ Makefile | 25 +++++++++++++++++++++++++ test/new/Makefile | 18 ++++++++---------- vim.Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 Makefile create mode 100644 vim.Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..780d2f3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.github +.gitignore +.gitlab-ci-yml +.luacheckrc +.projections.json +.vintrc +*Dockerfile +test/new/env diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a2245ac --- /dev/null +++ b/Makefile @@ -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 diff --git a/test/new/Makefile b/test/new/Makefile index 3b0283b..4b30c36 100644 --- a/test/new/Makefile +++ b/test/new/Makefile @@ -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 diff --git a/vim.Dockerfile b/vim.Dockerfile new file mode 100644 index 0000000..8595200 --- /dev/null +++ b/vim.Dockerfile @@ -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"]