summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2018-01-29 10:07:05 +0000
committerSimon McVittie <smcv@debian.org>2018-01-29 12:33:46 +0000
commitedb963ef0614c7e6732667b35ddb6347ad71fcd2 (patch)
tree119064439c1806ec6f56e57b89dcb81bc9be350a
parent6890e68cf7fcb053575d9474c7ee76ecc374608b (diff)
downloaddbus-glib-edb963ef0614c7e6732667b35ddb6347ad71fcd2.tar.gz
Add Travis-CI integration
Signed-off-by: Simon McVittie <smcv@debian.org>
-rw-r--r--.travis.yml37
-rw-r--r--tools/ci-Dockerfile.in10
-rwxr-xr-xtools/ci-build.sh164
-rwxr-xr-xtools/ci-install.sh130
4 files changed, 341 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..9a0568a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,37 @@
+# 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.
+
+sudo: required
+dist: trusty
+language: c
+script:
+ - ./tools/ci-install.sh
+ - ci_parallel=2 ci_sudo=yes ./tools/ci-build.sh
+
+env:
+ - ci_variant=production
+ - ci_variant=debug
+ - 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
index 0000000..e198b0d
--- /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 /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
new file mode 100755
index 0000000..caafe32
--- /dev/null
+++ b/tools/ci-build.sh
@@ -0,0 +1,164 @@
+#!/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_buildsys:
+# Build system under test: autotools is the only option right now
+: "${ci_buildsys:=autotools}"
+
+# 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.
+#
+# If empty, we test on "bare metal".
+# Typical values: ubuntu:xenial, debian:jessie-slim
+: "${ci_docker:=}"
+
+# ci_host:
+# See ci-install.sh
+: "${ci_host:=native}"
+
+# ci_parallel:
+# A number of parallel jobs, passed to make -j
+: "${ci_parallel:=1}"
+
+# ci_sudo:
+# If yes, assume we can get root using sudo; if no, only use current user
+: "${ci_sudo:=no}"
+
+# ci_test:
+# If yes, run tests; if no, just build
+: "${ci_test:=yes}"
+
+# ci_test_fatal:
+# If yes, test failures break the build; if no, they are reported but ignored
+: "${ci_test_fatal:=yes}"
+
+# ci_variant:
+# One of debug, reduced, legacy, production
+: "${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
+ fi
+}
+
+# We require dbus-run-session, but it isn't in the version of dbus in
+# Ubuntu 14.04. Take the version from dbus-1.10.0 and alter it to be
+# standalone.
+if ! command -v dbus-run-session >/dev/null; then
+ drsdir="$(mktemp -d -t "d-r-s.XXXXXX")"
+ curl -o "$drsdir/dbus-run-session.c" \
+ "https://cgit.freedesktop.org/dbus/dbus/plain/tools/dbus-run-session.c?h=dbus-1.10.0"
+ sed -e 's/^ //' > "$drsdir/config.h" <<EOF
+ #include <stdlib.h>
+
+ #define VERSION "1.10.0~local"
+ #define dbus_setenv my_dbus_setenv
+
+ static inline int
+ my_dbus_setenv (const char *name, const char *value)
+ {
+ if (value)
+ return !setenv (name, value, 1);
+ else
+ return !unsetenv (name);
+ }
+EOF
+ cc -I"${drsdir}" -o"${drsdir}/dbus-run-session" \
+ "${drsdir}/dbus-run-session.c" \
+ $(pkg-config --cflags --libs dbus-1) \
+ ${NULL}
+ export PATH="${drsdir}:$PATH"
+
+ # Force the build to be run even though dbus is less than version 1.8.
+ export DBUS_CFLAGS="$(pkg-config --cflags dbus-1)"
+ export DBUS_LIBS="$(pkg-config --libs dbus-1)"
+fi
+
+NOCONFIGURE=1 ./autogen.sh
+
+srcdir="$(pwd)"
+mkdir ci-build-${ci_variant}-${ci_host}
+cd ci-build-${ci_variant}-${ci_host}
+
+make="make -j${ci_parallel} V=1 VERBOSE=1"
+
+case "$ci_buildsys" in
+ (autotools)
+ case "$ci_variant" in
+ (debug)
+ set _ "$@"
+ set "$@" --enable-tests
+ shift
+ # The test coverage for OOM-safety is too
+ # verbose to be useful on travis-ci.
+ export DBUS_TEST_MALLOC_FAILURES=0
+ ;;
+
+ (*)
+ ;;
+ esac
+
+ ../configure \
+ --enable-installed-tests \
+ --enable-maintainer-mode \
+ "$@"
+
+ ${make}
+ [ "$ci_test" = no ] || ${make} check || maybe_fail_tests
+ cat test/test-suite.log || :
+ [ "$ci_test" = no ] || ${make} distcheck || maybe_fail_tests
+
+ ${make} install DESTDIR=$(pwd)/DESTDIR
+ ( cd DESTDIR && find . )
+
+ if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ]; then
+ sudo ${make} install
+ fi
+ ;;
+esac
+
+# vim:set sw=4 sts=4 et:
diff --git a/tools/ci-install.sh b/tools/ci-install.sh
new file mode 100755
index 0000000..f5b7e40
--- /dev/null
+++ b/tools/ci-install.sh
@@ -0,0 +1,130 @@
+#!/bin/bash
+
+# Copyright © 2015-2016 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-glib)
+: "${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:=trusty}"
+
+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}/" \
+ < 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
+
+ $sudo apt-get -qq -y update
+
+ $sudo apt-get -qq -y install \
+ autoconf-archive \
+ automake \
+ autotools-dev \
+ build-essential \
+ dbus \
+ debhelper \
+ dh-autoreconf \
+ gnome-desktop-testing \
+ gtk-doc-tools \
+ libdbus-1-dev \
+ libexpat-dev \
+ libglib2.0-dev \
+ wget \
+ ${NULL}
+
+ 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 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, and older
+ # gnome-common has files in common with it
+ wget http://deb.debian.org/debian/pool/main/a/autoconf-archive/autoconf-archive_20160916-1_all.deb
+ wget http://deb.debian.org/debian/pool/main/g/gnome-common/gnome-common_3.18.0-3_all.deb
+ $sudo dpkg -i --auto-deconfigure autoconf-archive_*_all.deb gnome-common_*_all.deb
+ rm autoconf-archive_*_all.deb gnome-common_*_all.deb
+ ;;
+ esac
+ ;;
+
+ (*)
+ echo "Don't know how to set up ${ci_distro}" >&2
+ exit 1
+ ;;
+esac
+
+# vim:set sw=4 sts=4 et: