-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use vim-testbed to run Vader tests on Travis #88
Conversation
The build is failing at the moment due to vint. The previous Pretty strange to me and I have no clue why this is occurring but I guess having vint warnings means it's being useful so this should be a good thing. |
Ah, I realize what's wrong. vint is currently linting the |
a6b21f3
to
3245f5d
Compare
Should be working now! |
Good job 👍 I'll prepare some tests then. P.S: If this issue is related to this PR, note that you need the |
@@ -1,8 +1,10 @@ | |||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yaml-lint complains if there's no document start marker, so I'd put that back in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,19 @@ | |||
IMAGE ?= prashcr/vim8s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should use a Dockerfile
hosted in this repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I would host the dockerfile in the repo and have it auto-build on the docker hub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I just changed this. You'll have to link your GitHub and set up an automated build for this repo at hub.docker.com
$(DOCKER) $$vim '+Vader! test/*'; \ | ||
done | ||
|
||
.PHONY: test-setup test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a make clean
rule in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefile doesn't create files anymore. We could still add a make clean for docker containers but that would undermine caching and people could just do that manually if they happened to be running Docker on their own machine. And we don't need clean for Travis anyway.
|
||
$(PLUGINS)/vader.vim: | ||
mkdir -p $(PLUGINS) | ||
cd $(PLUGINS) && git clone https://github.com/junegunn/vader.vim.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reference a particular commit ID so tests won't start failing if Vader updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I opened issue #89 to list some important tests we should focus on after this gets in. |
You'll have a conflict now the style checking branch as been merged. The |
Thanks for the feedback, I've incorporated most of the requested changes so far. I noticed 1 additional thing I'd like to fix, which I'm working on at the moment
I also just started considering the process of adding linters, and similar to above, I believe they should also be added to the Dockerfile, consisting of a git clone and ENV PATH of the linter as well as its pre-requisite languages (e.g. Node.js, Ruby) |
Cool. See if you can get it to somehow cache installation of pip modules and Vader.vim. Maybe we could create a new image which contains what we need, and use that pre-defined image. |
It caches a particular commit of Vader.vim now, cloning directly inside the container. Once the automated docker hub build is created, Travis should pass. Installing linters, pip, npm, etc. should be trivial to add, I'll do that in another commit though, enough rebasing for a day 😅 |
Amended again to fix a typo. |
Hmm, there's a problem with my commit. Even though I clone vader.vim into the /home/plugins directory, it simply doesn't exist in the container. |
install: | | ||
pip install vim-vint==0.3.9 | ||
script: | | ||
vint -s . && make test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way we can run both programs here? If a pull request contains some style issues, then it won't run the other tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I can change that to a ||
.
However, as a logical OR this means that if only one of them fail, the Travis build will still be a "pass"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be some bashism to accomplish returning non-zero if either of them error yet still being able to run both, I'll try and find it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can just run them line after line on Travis, and it will capture the error codes of all programs run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting two env
items would be one way to do it. Set a variable different in different environments for Travis, and run one command or the other based on the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we put them line after line, we will only get the error code of the last line. I've implemented the solution I found and it's working well.
I haven't ever really used Docker, so I'm not sure myself. I'll leave it to you. |
a140653
to
6147a4d
Compare
Looking good to go now, I did a demo build on a separate branch using the same Dockerfile (hosted on my Docker Hub): https://travis-ci.org/prashcr/ale/builds/167034172 I moved vint from I'm not 100% if that's the best idea, so let me know. |
@@ -1,8 +1,7 @@ | |||
--- | |||
sudo: required | |||
services: | |||
- docker | |||
language: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travis-yaml still requires a language so I left that there.
It looks like it's not quite running at the moment. |
for vim in $$vims; do \ | ||
$(DOCKER) $$vim '+Vader! test/*' || EXIT=$$?; \ | ||
done; \ | ||
$(DOCKER) vint -s /testplugin || EXIT=$$?; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this check all of the .vim
files in the repo, outside of tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks the entire repo, because of this line
DOCKER = docker run -a stderr --rm -v $(PWD):/testplugin -v $(PWD)/test:/home "$(IMAGE)"
This part in particular mounts pwd, which is this repo, into the /testplugin directory of the container.
-v $(PWD):/testplugin
I did this because that's how the vim-testbed scripts seemed to work.
Yep it won't work here at the moment, let me explain. We have a Dockerfile that describes a Docker image which is basically a built cache of all the pre-requisites (vim, vint, vader, etc.) for our
I use Docker Hub to host the Docker image. The neat feature of Docker Hub is that you can link it to a GitHub repo containing a Dockerfile such that every push to a branch on the GitHub repo triggers a build that creates a new image(e.g. downloads and builds vim, vint, vader, etc.) The bottom line is that the Travis build consists of just two steps
Previously, the Makefile pointed to a Docker Hub image that I created, linked to a GitHub repo of my own. (As is still the case with the demo build in my previous comment). As per the suggestion to move the Dockerfile here instead, I pointed the Makefile to the In order for the Travis build to work with the Dockerfile in this repo,
|
I see. I'll have a go at finishing this when I have some time. |
Hmm, one easy solution I can think of is to just build the image in Travis for now. It'll take 2-3 minutes to run but should just work. Then later you can remove the build step and pull from Docker Hub instead if you choose. |
Nah, I'll set up the Docker image and such. I'll probably merge this tonight and temporarily break Travis CI builds for a bit until it starts running the tests, after some shouting at it. |
Right, time to break things and fix them again. |
In addition to the current
vint
script currently on Travis, I added infrastructure for automated testing with Vader inside a Docker container with multiple vim builds that are cached on Docker Hub.Most of what I wrote is copied from https://github.com/tweekmonster/vim-testbed/tree/master/example, except I created a new Docker image based on vim-testbed containing vim v8.0.0000 and v8.0.0027.
It was quite a lot for me to wrap my head around at first as well, but I'm convinced the benefits are worth it. I understand the Makefile and Docker Hub image can be a bit daunting. However, from a tester's perspective, all they need to know is that
test/
vimrc
there which is used in testsAs this is quite a lot already for one PR so I only included a very basic Vader test as an example.
Versus our current approach
Refactoring #59
@KabbAmine Try running adding your Vader tests to this and let me know how it goes.