aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-12-27 17:00:29 +0100
committerGuido Günther <agx@sigxcpu.org>2016-12-27 17:00:29 +0100
commit9ecb5a4eed538b6240630ed66b68c45f5b1b08e6 (patch)
tree38c406165459b580ff8f72833287d71056114b3e
parent2783ead2d39587982c8275f4bced5c5db180ce93 (diff)
Add helper to run tests in docker container
and use this on travisci. Some ideas taken form travis.debian.net.
-rw-r--r--.travis.yml9
-rw-r--r--HACKING2
-rwxr-xr-xtests/helpers/run-in-docker31
3 files changed, 41 insertions, 1 deletions
diff --git a/.travis.yml b/.travis.yml
index cfae53b..60e7007 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,13 @@
---
+sudo: required
language: python
+
+services:
+ - docker
+
python:
- "2.7"
install: "pip install -r requirements.txt"
-script: flake8
+script:
+ - flake8
+ - tests/helpers/run-in-docker
diff --git a/HACKING b/HACKING
index 237d15c..6fbd41b 100644
--- a/HACKING
+++ b/HACKING
@@ -17,6 +17,8 @@ other tests use:
make all+net
+You can run the tests in a debian/sid docker container by using
+tests/helpers/run-in-docker.
Building the API Docs
---------------------
diff --git a/tests/helpers/run-in-docker b/tests/helpers/run-in-docker
new file mode 100755
index 0000000..0c5ccc8
--- /dev/null
+++ b/tests/helpers/run-in-docker
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+set -eu
+
+echo $(pwd)
+cat >Dockerfile <<EOF
+FROM debian:sid
+ENV DEBIAN_FRONTEND=noninteractive
+RUN echo "deb http://ftp.de.debian.org/debian sid main" > /etc/apt/sources.list
+RUN apt-get update && apt-get dist-upgrade --yes
+RUN apt-get install -y --no-install-recommends build-essential adduser
+RUN adduser gbp --disabled-password --gecos='gbp test user' --shell=/bin/bash --home /git-buildpackage
+
+WORKDIR /git-buildpackage
+COPY . .
+RUN chown -R gbp: .
+
+RUN apt-get -y build-dep .
+# Run as non root so permision tests pass
+CMD su -c "make all+net" gbp
+EOF
+
+CIDFILE="$(mktemp --dry-run)"
+TAG="git-buildpackage/sid"
+echo "Building Docker image ${TAG}"
+docker build . --tag=${TAG}
+docker run --cidfile=${CIDFILE} ${TAG}
+
+docker rm "$(cat ${CIDFILE})" >/dev/null
+rm -f "${CIDFILE}"
+