diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2016-11-28 13:36:24 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2016-11-28 13:36:24 +0000 |
commit | e4e553ead49246f56f78eeaa622a953038e14a1c (patch) | |
tree | 41cd4e6d9d15d44a0d09f73815c304b09629fbca | |
parent | a31686db79da0ac23e5e01a8fe3e3c266df5b75f (diff) |
travis-ci: Add and use infrastructure to build and test in Dockertry-master
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | tools/ci-Dockerfile.in | 10 | ||||
-rwxr-xr-x | tools/ci-build.sh | 16 | ||||
-rwxr-xr-x | tools/ci-install.sh | 24 |
4 files changed, 52 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index ca059e35..46e90ecd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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,6 @@ 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 # vim:set sw=2 sts=2 et: diff --git a/tools/ci-Dockerfile.in b/tools/ci-Dockerfile.in new file mode 100644 index 00000000..6f2db3e2 --- /dev/null +++ b/tools/ci-Dockerfile.in @@ -0,0 +1,10 @@ +FROM @ci_docker@ +ENV container docker + +ADD tests/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 diff --git a/tools/ci-build.sh b/tools/ci-build.sh index c3b4f498..35cf190a 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -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 diff --git a/tools/ci-install.sh b/tools/ci-install.sh index 596db583..2d229bda 100755 --- a/tools/ci-install.sh +++ b/tools/ci-install.sh @@ -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,21 @@ 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) + # Debian Docker images use httpredir.debian.org but it seems to be + # unreliable; use a CDN instead + 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 @@ -82,6 +97,15 @@ case "$ci_distro" in xvfb \ ${NULL} + 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) wget http://snapshot.debian.org/archive/debian/20160905T163745Z/pool/main/a/autoconf-archive/autoconf-archive_20160320-1_all.deb |