Skip to content

Commit 99991a3

Browse files
authored
Use Docker for easier test running (#86)
Switches to CircleCI instead of Travis, which handles running tests in Docker much better, especially since Travis is really slow (~30min vs 2.5min on CircleCI). The Docker image is based on https://github.com/tweekmonster/vim-testbed, and targets are added to the Makefile to build/push it.
1 parent ef1c1d0 commit 99991a3

File tree

7 files changed

+88
-15
lines changed

7 files changed

+88
-15
lines changed

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: 2
2+
3+
jobs:
4+
test:
5+
docker:
6+
- image: blueyed/vim-python-pep8-indent-vims-for-test:1@sha256:8c77867e1fdf673a6df0ecf6628f8e4d80579a0a097ec196109ca0bc145d86c0
7+
steps:
8+
- checkout
9+
- run:
10+
name: Run tests
11+
command: |
12+
Xvfb :99 &
13+
DISPLAY=:99 VIMRUNNER_REUSE_SERVER=1 rspec spec
14+
15+
checkqa:
16+
docker:
17+
- image: circleci/python:3.7
18+
steps:
19+
- checkout
20+
- run:
21+
name: Lint
22+
command: |
23+
pip install --user vim-vint
24+
~/.local/bin/vint **/*.vim
25+
26+
workflows:
27+
version: 2
28+
test:
29+
jobs:
30+
- test
31+
- checkqa

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!Gemfile
3+
!indent
4+
!spec

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CONTRIBUTING.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ Running Tests
2020
- Run the tests with the command::
2121

2222
$ rspec spec
23+
- Alternatively you can use Docker::
24+
25+
$ make test_docker
26+
27+
- You can select tests based on line numbers, e.g.::
28+
29+
$ rspec ./spec/indent/indent_spec.rb:385
30+
$ make test_docker RSPEC_ARGS=./spec/indent/indent_spec.rb:385
2331

2432
Thank you for considering to contribute!
2533

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM testbed/vim:latest
2+
3+
RUN apk --no-cache add gtk+2.0-dev libx11-dev libxt-dev mcookie xauth xvfb
4+
RUN install_vim -tag master --with-features=normal \
5+
--disable-channel --disable-netbeans --disable-xim \
6+
--enable-gui=gtk2 --with-x -build
7+
RUN ln -s /vim-build/bin/vim-master /usr/bin/gvim
8+
RUN gvim --version
9+
10+
WORKDIR /vim-python-pep8-indent
11+
12+
ADD Gemfile .
13+
RUN apk --no-cache add coreutils ruby-bundler
14+
RUN bundle install
15+
16+
ADD indent ./indent
17+
ADD spec ./spec
18+
19+
ENTRYPOINT ["rspec", "spec"]

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,23 @@ test_slow:
66

77
test_visible:
88
VIMRUNNER_REUSE_SERVER=1 bundle exec rspec
9+
10+
# Run tests in dockerized Vims.
11+
DOCKER_REPO:=blueyed/vim-python-pep8-indent-vims-for-test
12+
DOCKER_TAG:=1
13+
DOCKER_IMAGE:=$(DOCKER_REPO):$(DOCKER_TAG)
14+
15+
docker_image:
16+
docker build -t $(DOCKER_REPO):$(DOCKER_TAG) .
17+
docker_push:
18+
docker push $(DOCKER_REPO):$(DOCKER_TAG)
19+
docker_update_latest:
20+
docker tag $(DOCKER_REPO):$(DOCKER_TAG) $(DOCKER_REPO):latest
21+
docker push $(DOCKER_REPO):latest
22+
23+
test_docker: XVFB_ERRORFILE:=/dev/null
24+
test_docker:
25+
@set -x; export DISPLAY=$(if $(VIMRUNNER_TEST_DISPLAY),$(VIMRUNNER_TEST_DISPLAY),172.17.0.1:99; Xvfb -ac -listen tcp :99 >$(XVFB_ERRORFILE) 2>&1 & XVFB_PID=$$!); \
26+
docker run --rm -ti -e DISPLAY -e VIMRUNNER_REUSE_SERVER=1 \
27+
-v $(CURDIR):/vim-python-pep8-indent $(DOCKER_IMAGE) $(RSPEC_ARGS) \
28+
$(if $(VIMRUNNER_TEST_DISPLAY),,; ret=$$?; kill $$XVFB_PID; exit $$ret)

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: '2'
2+
services:
3+
rspec:
4+
build: .
5+
volumes:
6+
- .:/vim-python-pep8-indent

0 commit comments

Comments
 (0)