diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0c792c5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:trusty + +RUN apt-get update && apt-get install -y tar curl git +RUN apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev + +RUN git clone https://github.com/yyuu/pyenv.git /root/.pyenv \ + && echo 'eval "$(pyenv init -)"' >> /root/.bash_profile + +ENV PYENV_ROOT /root/.pyenv +ENV PATH $PYENV_ROOT/bin:/pyenv/venv/bin:$PATH + +RUN mkdir /pyenv +WORKDIR /pyenv + +ADD .python-version .python-version +ADD requirements.txt requirements.txt +ADD dev-requirements.txt dev-requirements.txt + +RUN . ~/.bash_profile \ + && pyenv install --skip-existing \ + && pyenv rehash \ + && pip install virtualenv \ + && ([ -d venv ] || virtualenv venv) \ + && . venv/bin/activate \ + && pip install -r requirements.txt \ + && pip install -r dev-requirements.txt + +RUN mkdir /reppy +WORKDIR /reppy + +ADD . . + +RUN git submodule update --init --recursive + +CMD make test + diff --git a/Makefile b/Makefile index 042e6ae..ba6e6d1 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ test: reppy/robots.so nosetests --with-coverage tests +test-docker: + docker build -t reppy-tests . && docker run --rm reppy-tests + docker rmi reppy-tests + reppy/%.so: reppy/%.py* reppy/rep-cpp/src/* reppy/rep-cpp/include/* reppy/rep-cpp/deps/url-cpp/include/* reppy/rep-cpp/deps/url-cpp/src/* python setup.py build_ext --inplace diff --git a/README.md b/README.md index 575f4c6..a009f9b 100644 --- a/README.md +++ b/README.md @@ -181,11 +181,18 @@ Tests may be run in `vagrant`: make test ``` +Alternatively, they may be run in a Docker container: + +```bash +make docker-test +``` + Development =========== Environment ----------- + To launch the `vagrant` image, we only need to `vagrant up` (though you may have to provide a `--provider` flag): @@ -202,12 +209,25 @@ make test Running Tests ------------- + +### Vagrant + Tests are run with the top-level `Makefile`: ```bash make test ``` +### Docker + +To use Docker to run the tests, you only need to run `make test-docker` on your local machine: + +```bash +make test-docker +``` + +This will build an image, run the tests in a container, then delete the container and image. + PRs === These are not all hard-and-fast rules, but in general PRs have the following expectations: