]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
travis-ci: refactor and add .travis-functions.sh
authorRuediger Meier <ruediger.meier@ga-group.nl>
Sun, 1 Jun 2014 22:58:01 +0000 (00:58 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 6 Jun 2014 14:18:44 +0000 (16:18 +0200)
Travis yaml syntax, where we can only use shell one-liners, is awful
and ugly. We add a real shell script and source it from .travis.yml.

This commit squashes a lot changes because we don't want to pollute
history with this meta CI stuff.

Highlights of this commit:
  - enable make distcheck
  - cleanup configure options (enable all progs, with python and docs)
  - shorter config.log dump
  - out-of-tree build supported
  - workaround broken libtool on travis host
  - now it's easy to add temporary debugging stuff
  - testing locally is possible now

What are we testing now:
  - gcc and clang compiler
  - configure mostly with --enable-all-programs, --with-python and
    --enable-gtk-doc
  - make check with and without root permissions
  - make distcheck
  - make install (with and without --prefix as well as DESTDIR=...)
  - usually we always build in-tree but distcheck does out-of-tree

What do we want/expect at all:
  - This travis setup is intended to always work without fixing or
    updating this build script all the time. Thats why we only use a
    few configure flags.
  - We want to avoid predictable failures on travis host to not make
    developers tired of this machinery. Any tested feature which is
    known to be (sometimes) broken should be fixed or skipped as soon
    as possible.
  - If this works like wanted then in future almost any point in master
    commit history should at least survive the build and common tests
    on this reference host/arch. Moreover we will have a comparable,
    deterministic build log history. This could make bisecting real
    bugs easier.
  - It's not our goal to test any kind of config flags, host setup and
    arch combination. This would be done better by external build
    scripts which do not live within the project itself.
  - Of course this machinery can be also used to reproduce bugs with
    more exotic config and host setup by pushing a debug branch with
    modified travis script to github.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
.travis-functions.sh [new file with mode: 0755]
.travis.yml

diff --git a/.travis-functions.sh b/.travis-functions.sh
new file mode 100755 (executable)
index 0000000..ed491f4
--- /dev/null
@@ -0,0 +1,128 @@
+#!/bin/bash
+
+#
+# .travis-functions.sh:
+#   - helper functions to be sourced from .travis.yml
+#   - designed to respect travis' environment but testing locally is possible
+#
+
+if [ ! -f "configure.ac" ]; then
+       echo ".travis-functions.sh must be sourced from source dir" >&2
+       return 1 || exit 1
+fi
+
+# some config settings
+MAKE="make -j4"
+DUMP_CONFIG_LOG="short"
+
+# We could test (exotic) out-of-tree build dirs using relative or abs paths.
+# After sourcing this script we are living in build dir. Tasks for source dir
+# have to use $SOURCE_DIR.
+SOURCE_DIR="."
+BUILD_DIR="."
+CONFIGURE="$SOURCE_DIR/configure"
+
+mkdir -p "$BUILD_DIR"
+cd "$BUILD_DIR" || return 1 || exit 1
+
+function configure_travis
+{
+       "$CONFIGURE" "$@"
+       err=$?
+       if [ "$DUMP_CONFIG_LOG" = "short" ]; then
+               grep -B1 -A10000 "^## Output variables" config.log | grep -v "_FALSE="
+       elif [ "$DUMP_CONFIG_LOG" = "full" ]; then
+               cat config.log
+       fi
+       return $err
+}
+
+function check_nonroot
+{
+       configure_travis \
+               --disable-use-tty-group \
+               --with-python \
+               --enable-all-programs \
+               --enable-gtk-doc \
+               || return
+       $MAKE || return
+       $MAKE check || return
+       $MAKE install DESTDIR=/tmp/dest || return
+}
+
+function check_root
+{
+       configure_travis \
+               --with-python \
+               --enable-all-programs \
+               || return
+       $MAKE || return
+       $MAKE check TS_COMMAND="true" || return
+       sudo -E $MAKE check TS_OPTS='--parallel=1' || return
+       sudo $MAKE install || return
+}
+
+function check_dist
+{
+       configure_travis \
+               || return
+       $MAKE distcheck || return
+}
+
+function travis_before_script
+{
+       pushd "$SOURCE_DIR" || return
+       set -o xtrace
+
+       ./autogen.sh
+       ret=$?
+
+       # workaround for broken pylibmount install relink
+       [ $ret -eq 0 ] && \
+               sed -i 's/\(link_all_deplibs\)=no/\1=unknown/' ./configure
+
+       set +o xtrace
+       popd
+       return $ret
+}
+
+function travis_script
+{
+       local ret
+       set -o xtrace
+
+       case "$MAKE_CHECK" in
+       nonroot)
+               check_nonroot
+               ;;
+       root)
+               check_root
+               ;;
+       dist)
+               check_dist
+               ;;
+       *)
+               echo "error, check environment (travis.yml)" >&2
+               false
+               ;;
+       esac
+
+       # We exit here with case-switch return value!
+       ret=$?
+       set +o xtrace
+       return $ret
+}
+
+function travis_after_script
+{
+       local diff_dir
+       local tmp
+
+       # find diff dir from check as well as from distcheck
+       diff_dir=$(find -type d -a -name "diff" | grep "tests/diff" | head -n 1)
+       if [ -d "$diff_dir" ]; then
+               tmp=$(find "$diff_dir" -type f | sort)
+               echo -en "dump test diffs:\n${tmp}\n"
+               echo "$tmp" | xargs -r cat
+       fi
+}
index a4dde3ad29ced33797c9e9f8bca7e190cb35a9fe..a1a15e48e7452f5537ffca77b8d1ab9ee7c01bd2 100644 (file)
@@ -10,44 +10,26 @@ compiler:
 env:
   - MAKE_CHECK="nonroot"
   - MAKE_CHECK="root"
+  - MAKE_CHECK="dist"
 
 install:
   # install some packages from Ubuntu's default sources
   - sudo apt-get -qq update
   - sudo apt-get install -qq
     bc
+    dnsutils
+    libcap-ng-dev
     libpam-dev
     libudev-dev
     gtk-doc-tools
+    ntp
 
 before_script:
-  - ./autogen.sh
+  - source ./.travis-functions.sh
+  - travis_before_script
 
 script:
-  - export MAKE="make -j4"
-  # make distcheck still does not work on travis
-  - (./configure
-      --disable-use-tty-group
-      --enable-chfn-chsh
-      --enable-line
-      --enable-mesg
-      --enable-newgrp
-      --enable-reset
-      --enable-tunelp
-      --enable-vipw
-      --enable-write
-    ; err=$?; cat config.log; exit $err)
-    && $MAKE
-    && if [ "$MAKE_CHECK" = "nonroot" ]; then
-         $MAKE check
-         && $MAKE install DESTDIR=/tmp/dest
-         && $MAKE dist;
-       elif [ "$MAKE_CHECK" = "root" ]; then
-         $MAKE check TS_COMMAND="true"
-         && sudo -E $MAKE check TS_OPTS='--parallel=1';
-       fi
+  - travis_script
 
 after_script:
-  - test -d tests/diff
-    && echo "cat test diffs:"
-    && find tests/diff -type f | xargs -r cat
+  - travis_after_script