Skip to content
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

Add support for running tests in a Docker container #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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:
Expand Down