Commit 367526af authored by Simon McVittie's avatar Simon McVittie

travis-ci: Add and use infrastructure to build and test in Docker

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: 's avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall's avatarPhilip Withnall <philip.withnall@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98889
parent c807f383
......@@ -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:
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
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment