]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
travis-ci: Add and use infrastructure to build and test in Docker
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 28 Nov 2016 16:38:37 +0000 (16:38 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Tue, 29 Nov 2016 12:37:48 +0000 (12:37 +0000)
Debian stable, Debian testing and Ubuntu LTS provide a reasonable
spectrum of old and new distributions. I'm only doing one build on
each to avoid a combinatorial explosion of options.

The Docker images don't have any deb-src apt sources set up, so don't
use `apt-get build-dep`; just include dependencies manually.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98889

.travis.yml
tools/ci-Dockerfile.in [new file with mode: 0644]
tools/ci-build.sh
tools/ci-install.sh

index ca059e355a6321f46af20f21cb44afc541df8626..4ffc48c43bc8446bfd819896df00952c7072b1ff 100644 (file)
@@ -23,9 +23,8 @@
 sudo: required
 dist: trusty
 language: c
-install:
-  - ./tools/ci-install.sh
 script:
+  - ./tools/ci-install.sh
   # python-dbus and python-gi aren't available to Travis's version of
   # Python in /opt, which it uses as a default
   - PYTHON=/usr/bin/python ci_parallel=2 ci_sudo=yes ./tools/ci-build.sh
@@ -39,5 +38,8 @@ env:
   - ci_host=mingw
   - ci_host=mingw ci_variant=debug
   - ci_host=mingw ci_buildsys=cmake
+  - ci_docker=ubuntu:xenial ci_distro=ubuntu ci_suite=xenial
+  - ci_docker=debian:jessie-slim ci_distro=debian ci_suite=jessie
+  - ci_docker=debian:stretch-slim ci_distro=debian ci_suite=stretch
 
 # vim:set sw=2 sts=2 et:
diff --git a/tools/ci-Dockerfile.in b/tools/ci-Dockerfile.in
new file mode 100644 (file)
index 0000000..e198b0d
--- /dev/null
@@ -0,0 +1,10 @@
+FROM @ci_docker@
+ENV container docker
+
+ADD tools/ci-install.sh /ci-install.sh
+RUN ci_suite="@ci_suite@" ci_distro="@ci_distro@" ci_in_docker=yes /ci-install.sh
+
+ADD . /home/user/ci
+RUN chown -R user:user /home/user/ci
+WORKDIR /home/user/ci
+USER user
index c3b4f4988ef96548f8cf9e1089d7f96c79ac1771..35cf190a480141b867ffb129d4683fa6d57b4605 100755 (executable)
@@ -27,6 +27,7 @@ set -x
 
 NULL=
 : "${ci_buildsys:=autotools}"
+: "${ci_docker:=}"
 : "${ci_host:=native}"
 : "${ci_parallel:=1}"
 : "${ci_sudo:=no}"
@@ -34,6 +35,21 @@ NULL=
 : "${ci_test_fatal:=yes}"
 : "${ci_variant:=production}"
 
+if [ -n "$ci_docker" ]; then
+    exec docker run \
+        --env=ci_buildsys="${ci_buildsys}" \
+        --env=ci_docker="" \
+        --env=ci_host="${ci_host}" \
+        --env=ci_parallel="${ci_parallel}" \
+        --env=ci_sudo=yes \
+        --env=ci_test="${ci_test}" \
+        --env=ci_test_fatal="${ci_test_fatal}" \
+        --env=ci_variant="${ci_variant}" \
+        --privileged \
+        ci-image \
+        tools/ci-build.sh
+fi
+
 maybe_fail_tests () {
     if [ "$ci_test_fatal" = yes ]; then
         exit 1
index 9731f585cc3b31f82f7ff5893a6cad20ec9fa54e..3fc5ffb20f41dc4918d7f093cfe956d72e592b40 100755 (executable)
@@ -27,7 +27,9 @@ set -x
 
 NULL=
 : "${ci_distro:=ubuntu}"
+: "${ci_docker:=}"
 : "${ci_host:=native}"
+: "${ci_in_docker:=}"
 : "${ci_suite:=trusty}"
 
 if [ $(id -u) = 0 ]; then
@@ -36,8 +38,25 @@ else
     sudo=sudo
 fi
 
+if [ -n "$ci_docker" ]; then
+    sed \
+        -e "s/@ci_distro@/${ci_distro}/" \
+        -e "s/@ci_docker@/${ci_docker}/" \
+        -e "s/@ci_suite@/${ci_suite}/" \
+        < tools/ci-Dockerfile.in > Dockerfile
+    exec docker build -t ci-image .
+fi
+
 case "$ci_distro" in
     (debian|ubuntu)
+        # Don't ask questions, just do it
+        sudo="$sudo env DEBIAN_FRONTEND=noninteractive"
+
+        # Debian Docker images use httpredir.debian.org but it seems to be
+        # unreliable; use a CDN instead
+        $sudo sed -i -e 's/httpredir\.debian\.org/deb.debian.org/g' \
+            /etc/apt/sources.list
+
         # travis-ci has a sources list for Chrome which doesn't support i386
         : | $sudo tee /etc/apt/sources.list.d/google-chrome.list
 
@@ -55,13 +74,13 @@ case "$ci_distro" in
                 ${NULL}
         fi
 
-        $sudo apt-get -qq -y build-dep dbus
-
         $sudo apt-get -qq -y install \
+            autoconf-archive \
             automake \
             autotools-dev \
             debhelper \
             dh-autoreconf \
+            dh-exec \
             doxygen \
             dpkg-dev \
             gnome-desktop-testing \
@@ -76,12 +95,31 @@ case "$ci_distro" in
             python-dbus \
             python-gi \
             valgrind \
+            wget \
             xauth \
             xmlto \
             xsltproc \
             xvfb \
             ${NULL}
 
+        case "$ci_suite" in
+            (trusty)
+                $sudo apt-get -qq -y install libsystemd-daemon-dev
+                ;;
+            (*)
+                $sudo apt-get -qq -y install libsystemd-dev
+                ;;
+        esac
+
+        if [ -n "$ci_in_docker" ]; then
+            # Add the user that we will use to do the build inside the
+            # Docker container, and let them use sudo
+            adduser --disabled-password user </dev/null
+            apt-get -y install sudo
+            echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
+            chmod 0440 /etc/sudoers.d/nopasswd
+        fi
+
         case "$ci_suite" in
             (trusty|jessie)
                 # Ubuntu 14.04's autoconf-archive is too old