diff options
author | Simon McVittie <smcv@collabora.com> | 2018-12-17 17:44:16 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-07-15 15:51:05 +0100 |
commit | 69e7c4f58e9244acfc8b23a6beaf73124bb19ce0 (patch) | |
tree | eb9ed4eed1ab81e2e9678cc6e46716c5282da79c | |
parent | 745230046f0497582e2ee4b3648b32624451e754 (diff) |
Update CI build infrastructure from dbus
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | .travis.yml | 8 | ||||
-rw-r--r-- | tools/ci-Dockerfile.in | 10 | ||||
-rwxr-xr-x | tools/ci-build.sh | 14 | ||||
-rwxr-xr-x | tools/ci-install.sh | 165 | ||||
-rwxr-xr-x | tools/travis-ci-setup.sh | 53 |
5 files changed, 195 insertions, 55 deletions
diff --git a/.travis.yml b/.travis.yml index f694f12..4bd7a9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ cache: - $HOME/.ccache install: - test -z "$dbus_ci_system_python" || deactivate - - tools/travis-ci-setup.sh + - ./tools/ci-install.sh python: - "3.6" - "3.6-dev" @@ -53,5 +53,11 @@ matrix: - python: "3.5" env: dbus_ci_system_python=python3-dbg + - python: "3.4" + env: + ci_docker=debian:jessie-slim ci_suite=jessie dbus_ci_system_python=python3 + - python: "3.4" + env: + ci_docker=debian:jessie-slim ci_suite=jessie dbus_ci_system_python=python3-dbg # vim:set sw=2 sts=2 et: diff --git a/tools/ci-Dockerfile.in b/tools/ci-Dockerfile.in new file mode 100644 index 0000000..70607ec --- /dev/null +++ b/tools/ci-Dockerfile.in @@ -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 dbus_ci_system_python="@dbus_ci_system_python@" /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 e9e2fb7..f511d26 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -30,10 +30,22 @@ srcdir="$(pwd)" builddir="$(mktemp -d -t "builddir.XXXXXX")" prefix="$(mktemp -d -t "prefix.XXXXXX")" -if [ -n "$dbus_ci_parallel" ]; then +if [ -z "$dbus_ci_parallel" ]; then dbus_ci_parallel=2 fi +if [ -n "$ci_docker" ]; then + exec docker run \ + --env=ci_distro="${ci_distro}" \ + --env=ci_docker="" \ + --env=ci_suite="${ci_suite}" \ + --env=dbus_ci_parallel="${dbus_ci_parallel}" \ + --env=dbus_ci_system_python="${dbus_ci_system_python-}" \ + --privileged \ + ci-image \ + tools/ci-build.sh +fi + if [ -n "$TRAVIS" ] && [ -n "$dbus_ci_system_python" ]; then # Reset to standard paths to use the Ubuntu version of python unset LDFLAGS diff --git a/tools/ci-install.sh b/tools/ci-install.sh new file mode 100755 index 0000000..91a2cc9 --- /dev/null +++ b/tools/ci-install.sh @@ -0,0 +1,165 @@ +#!/bin/bash + +# Copyright © 2015-2018 Collabora Ltd. +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation files +# (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, +# publish, distribute, sublicense, and/or sell copies of the Software, +# and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set -euo pipefail +set -x + +NULL= + +# ci_distro: +# OS distribution in which we are testing +# Typical values: ubuntu, debian; maybe fedora in future +: "${ci_distro:=ubuntu}" + +# ci_docker: +# If non-empty, this is the name of a Docker image. ci-install.sh will +# fetch it with "docker pull" and use it as a base for a new Docker image +# named "ci-image" in which we will do our testing. +: "${ci_docker:=}" + +# ci_host: +# Either "native", or an Autoconf --host argument to cross-compile +# the package (not currently supported for dbus-python) +: "${ci_host:=native}" + +# ci_in_docker: +# Used internally by ci-install.sh. If yes, we are inside the Docker image +# (ci_docker is empty in this case). +: "${ci_in_docker:=no}" + +# ci_suite: +# OS suite (release, branch) in which we are testing. +# Typical values for ci_distro=debian: sid, jessie +# Typical values for ci_distro=fedora might be 25, rawhide +: "${ci_suite:=xenial}" + +if [ $(id -u) = 0 ]; then + sudo= +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}/" \ + -e "s/@dbus_ci_system_python@/${dbus_ci_system_python-}/" \ + < 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 + + $sudo apt-get -qq -y update + + $sudo apt-get -qq -y install \ + autoconf \ + autoconf-archive \ + automake \ + autotools-dev \ + ccache \ + dbus \ + debhelper \ + dh-autoreconf \ + docbook-xml \ + docbook-xsl \ + gcc \ + gnome-desktop-testing \ + gtk-doc-tools \ + libdbus-1-dev \ + libglib2.0-dev \ + libtool \ + make \ + sudo \ + wget \ + xmlto \ + ${NULL} + + if [ -n "${dbus_ci_system_python-}" ]; then + sudo apt-get -qq -y install \ + ${dbus_ci_system_python} \ + ${dbus_ci_system_python%-dbg}-docutils \ + ${dbus_ci_system_python%-dbg}-gi \ + ${dbus_ci_system_python%-dbg}-pip \ + ${dbus_ci_system_python%-dbg}-setuptools \ + ${NULL} + + if [ "${dbus_ci_system_python%-dbg}" != "${dbus_ci_system_python}" ]; then + sudo apt-get -qq -y install ${dbus_ci_system_python%-dbg}-gi-dbg + fi + + if [ "$dbus_ci_system_python" = python ]; then + sudo apt-get -qq -y install python-gobject-2 + fi + fi + + if [ "$ci_in_docker" = yes ]; then + # Add the user that we will use to do the build inside the + # Docker container, and let them use sudo + adduser --disabled-password --gecos "" user + echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd + chmod 0440 /etc/sudoers.d/nopasswd + fi + + case "$ci_suite" in + (jessie|xenial) + # autoconf-archive in Debian 8 and Ubuntu 16.04 is too old, + # use the one from Debian 9 instead + wget http://deb.debian.org/debian/pool/main/a/autoconf-archive/autoconf-archive_20160916-1_all.deb + $sudo dpkg -i autoconf-archive_*_all.deb + rm autoconf-archive_*_all.deb + ;; + esac + ;; + + (*) + echo "Don't know how to set up ${ci_distro}" >&2 + exit 1 + ;; +esac + +if [ -n "${dbus_ci_system_python-}" ]; then + "$dbus_ci_system_python" -m pip install --user \ + sphinx \ + sphinx_rtd_theme \ + tap.py \ + ${NULL} +else + pip install \ + sphinx \ + sphinx_rtd_theme \ + tap.py \ + ${NULL} +fi + +# vim:set sw=4 sts=4 et: diff --git a/tools/travis-ci-setup.sh b/tools/travis-ci-setup.sh deleted file mode 100755 index a28d050..0000000 --- a/tools/travis-ci-setup.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -set -e -set -u -NULL= - -sudo apt-get -qq -y update -sudo apt-get -qq -y install \ - autoconf \ - automake \ - ccache \ - dbus \ - gnome-desktop-testing \ - libdbus-1-dev \ - libtool \ - ${NULL} - -if [ -n "${dbus_ci_system_python-}" ]; then - sudo apt-get -qq -y install \ - ${dbus_ci_system_python} \ - ${dbus_ci_system_python%-dbg}-docutils \ - ${dbus_ci_system_python%-dbg}-gi \ - ${dbus_ci_system_python%-dbg}-pip \ - ${dbus_ci_system_python%-dbg}-setuptools \ - ${NULL} - - if [ "${dbus_ci_system_python%-dbg}" != "${dbus_ci_system_python}" ]; then - sudo apt-get -qq -y install ${dbus_ci_system_python%-dbg}-gi-dbg - fi - - if [ "$dbus_ci_system_python" = python ]; then - sudo apt-get -qq -y install python-gobject-2 - fi -fi - -wget \ -http://deb.debian.org/debian/pool/main/a/autoconf-archive/autoconf-archive_20160916-1_all.deb -sudo dpkg -i autoconf-archive_*_all.deb -rm autoconf-archive_*_all.deb - -if [ -n "${dbus_ci_system_python-}" ]; then - "$dbus_ci_system_python" -m pip install --user \ - sphinx \ - sphinx_rtd_theme \ - tap.py \ - ${NULL} -else - pip install \ - sphinx \ - sphinx_rtd_theme \ - tap.py \ - ${NULL} -fi |