2016-08-06 00:12:55 +03:00
#!/bin/bash
2016-11-28 20:21:46 +03:00
# 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.
2016-08-06 00:12:55 +03:00
set -euo pipefail
set -x
NULL =
2016-11-29 16:06:14 +03:00
# ci_docker:
2017-05-09 18:52:20 +03:00
# If non-empty, this is the name of a Docker image. travis-install.sh will
2016-11-29 16:06:14 +03:00
# 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
2016-08-06 00:12:55 +03:00
: " ${ ci_docker : = } "
2016-11-29 16:06:14 +03:00
# ci_parallel:
# A number of parallel jobs, passed to make -j
2016-08-06 00:12:55 +03:00
: " ${ ci_parallel : =1 } "
2016-11-29 16:06:14 +03:00
# ci_sudo:
# If yes, assume we can get root using sudo; if no, only use current user
2016-08-06 00:12:55 +03:00
: " ${ ci_sudo : =no } "
2016-11-29 16:06:14 +03:00
# ci_test:
# If yes, run tests; if no, just build
2016-08-06 00:12:55 +03:00
: " ${ ci_test : =yes } "
2016-11-29 16:06:14 +03:00
# ci_test_fatal:
# If yes, test failures break the build; if no, they are reported but ignored
2016-08-06 00:12:55 +03:00
: " ${ ci_test_fatal : =yes } "
2016-12-08 05:02:30 +03:00
# ci_configopts:
# Additional args for configure
: " ${ ci_configopts : = } "
2016-08-06 00:12:55 +03:00
if [ -n " $ci_docker " ] ; then
exec docker run \
--env= ci_docker = "" \
--env= ci_parallel = " ${ ci_parallel } " \
--env= ci_sudo = yes \
--env= ci_test = " ${ ci_test } " \
--env= ci_test_fatal = " ${ ci_test_fatal } " \
2016-12-08 05:02:30 +03:00
--env= ci_configopts = " ${ ci_configopts } " \
2016-08-06 00:12:55 +03:00
--privileged \
2016-11-28 20:22:24 +03:00
ci-image \
2017-05-09 18:52:20 +03:00
ci/travis-build.sh
2016-08-06 00:12:55 +03:00
fi
2016-11-28 20:23:08 +03:00
maybe_fail_tests ( ) {
if [ " $ci_test_fatal " = yes ] ; then
exit 1
fi
}
2016-08-06 00:12:55 +03:00
NOCONFIGURE = 1 ./autogen.sh
srcdir = " $( pwd ) "
mkdir ci-build
cd ci-build
make = " make -j ${ ci_parallel } V=1 VERBOSE=1 "
../configure \
--enable-always-build-tests \
2016-12-08 05:02:30 +03:00
${ ci_configopts }
2016-08-06 00:12:55 +03:00
" $@ "
${ make }
[ " $ci_test " = no ] || ${ make } check || maybe_fail_tests
2017-11-16 20:27:14 +03:00
cat test-suite.log || :
2016-11-28 20:24:08 +03:00
[ " $ci_test " = no ] || ${ make } distcheck || maybe_fail_tests
2017-11-16 20:27:14 +03:00
cat test-suite.log || :
2016-08-06 00:12:55 +03:00
${ make } install DESTDIR = $( pwd ) /DESTDIR
( cd DESTDIR && find . )
2016-11-28 15:34:06 +03:00
if [ " $ci_sudo " = yes ] && [ " $ci_test " = yes ] ; then
2016-08-06 00:12:55 +03:00
sudo ${ make } install
env \
LD_LIBRARY_PATH = /usr/local/lib \
GI_TYPELIB_PATH = /usr/local/lib/girepository-1.0 \
${ make } installcheck || \
maybe_fail_tests
2017-11-16 20:27:14 +03:00
cat test-suite.log || :
2016-08-06 00:12:55 +03:00
fi
# vim:set sw=4 sts=4 et: