1# Define the building environment 2language: c 3 4matrix: 5 fast_finish: true 6 7compiler: 8 - clang 9 - gcc 10 11env: 12 matrix: 13 # Test the last version of Python and Ruby together, with some linkers 14 - PYVER=python3.5 RUBYLIBVER=2.3 15 - PYVER=python3.5 RUBYLIBVER=2.3 LINKER=gold 16 - PYVER=python3.5 RUBYLIBVER=2.3 LINKER=bfd 17 18 # Test several Python versions 19 - PYVER=python2.7 RUBYLIBVER=2.3 20 - PYVER=python3.3 RUBYLIBVER=2.3 21 - PYVER=python3.4 RUBYLIBVER=2.3 22 - PYVER=pypy RUBYLIBVER=2.3 23 #- PYVER=pypy3 RUBYLIBVER=2.3 # PyPy3 5.5.0 provides the Python2 form of some structures, which makes it incompatible with SWIG 24 25 # Test several Ruby versions 26 - PYVER=python3.5 RUBYLIBVER=2.0 27 - PYVER=python3.5 RUBYLIBVER=2.1 28 - PYVER=python3.5 RUBYLIBVER=2.2 29 30# Use Travis-CI Ubuntu 14.04 Trusty infrastructure 31sudo: required 32dist: trusty 33 34# Install SELinux userspace utilities dependencies 35addons: 36 apt: 37 packages: 38 - bison 39 - flex 40 - gawk 41 - gettext 42 - libaudit-dev 43 - libbz2-dev 44 - libcap-dev 45 - libcap-ng-dev # This package is not whitelisted for the container infrastructure (https://github.com/travis-ci/apt-package-whitelist/issues/1096) 46 - libcunit1-dev 47 - libdbus-glib-1-dev 48 - libncurses5-dev 49 - libpcre3-dev 50 - patch 51 - python3-dev 52 - python-dev 53 - swig 54 - xmlto 55 56install: 57 # Download refpolicy Makefile for sepolgen tests 58 - sudo mkdir -p /usr/share/selinux/default 59 - sudo curl -o /usr/share/selinux/default/Makefile 'https://raw.githubusercontent.com/TresysTechnology/refpolicy/RELEASE_2_20170204/support/Makefile.devel' 60 - sudo sed "s,^PREFIX :=.*,PREFIX := $TRAVIS_BUILD_DIR/installdir/usr," -i /usr/share/selinux/default/Makefile 61 - sudo mkdir -p /usr/share/selinux/refpolicy/include 62 - sudo curl -o /usr/share/selinux/refpolicy/include/build.conf 'https://raw.githubusercontent.com/TresysTechnology/refpolicy/RELEASE_2_20170204/build.conf' 63 - sudo mkdir -p /etc/selinux 64 - echo 'SELINUXTYPE=refpolicy' | sudo tee /etc/selinux/config 65 66 # Make sepolgen tests work without really installing anything in the real root (doing this would conflict with Ubuntu packages) 67 - sed -e "s,\"\(/usr/bin/[cs]\),\"$TRAVIS_BUILD_DIR/installdir\1," -i python/sepolgen/src/sepolgen/module.py 68 69before_script: 70 # clang on Travis-CI 14.04 environment is too old to support -Wdouble-promotion 71 - if "$CC" --version |grep -q clang; then sed 's/ -Wdouble-promotion / /' -i libselinux/src/Makefile libselinux/utils/Makefile ; fi 72 73 # Build and install in a temporary directory to run tests 74 - export DESTDIR="$TRAVIS_BUILD_DIR/installdir" 75 76 # Configure the variables for Python parts 77 - export VIRTUAL_ENV="$HOME/virtualenv/$PYVER" 78 - export PYTHON="$VIRTUAL_ENV/bin/python" 79 # Use the header files in /opt/python/... for Python because the virtualenvs do not provide Python.h 80 - export PKG_CONFIG_PATH="/opt/python/$($PYTHON -c 'import sys;print("%d.%d.%d" % sys.version_info[:3])')/lib/pkgconfig" 81 # PyPy does not provide a config file for pkg-config nor a pypy-c.so 82 - if echo "$PYVER" | grep -q pypy ; then export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include PYLIBS= ; fi 83 # Python virtualenvs do not support "import site; print(site.getsitepackages()[0]" 84 # cf. https://github.com/pypa/virtualenv/issues/355#issuecomment-10250452 85 - export PYSITEDIR="$DESTDIR/usr/lib/$($PYTHON -c 'import sys;print("python%d.%d" % sys.version_info[:2])')/site-packages" 86 87 # Find the Ruby executable with version $RUBYLIBVER 88 - export RUBY="$(ls -d -1 "$HOME/.rvm/rubies/ruby-$RUBYLIBVER"*/bin/ruby | head -n 1)" 89 90 # Set the linker in $CC so that it gets used everywhere 91 - if [ -n "$LINKER" ]; then CC="$CC -fuse-ld=$LINKER" ; fi 92 93 # Show variables and versions (to help debugging) 94 - echo "$CC" ; $CC --version 95 - echo "$PYTHON" ; $PYTHON --version 96 - echo "$RUBY" ; $RUBY --version 97 98script: 99 # Start by installing everything into $DESTDIR 100 - make install -k 101 - make install-pywrap -k 102 - make install-rubywrap -k 103 104 # Now that everything is installed, run "make all" to build everything which may have not been built 105 - make all -k 106 107 # Set up environment variables for the tests 108 - export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" 109 - export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" 110 - export PYTHONPATH="$PYSITEDIR" 111 - export RUBYLIB="$DESTDIR/$($RUBY -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$($RUBY -e 'puts RbConfig::CONFIG["vendorarchdir"]')" 112 113 # Show variables (to help debugging issues) 114 - echo "$LD_LIBRARY_PATH" 115 - echo "$PATH" 116 - echo "$PYTHONPATH" 117 - echo "$RUBYLIB" 118 119 # Run tests 120 - make test 121 122 # Test Python and Ruby wrappers 123 - $PYTHON -c 'import selinux;import selinux.audit2why;import semanage;print(selinux.is_selinux_enabled())' 124 - $RUBY -e 'require "selinux";require "semanage";puts Selinux::is_selinux_enabled()' 125 126 # Remove every installed files 127 - rm -rf "$DESTDIR" 128 129 # Test that "git status" looks clean, or print a clear error message 130 - |- 131 git status --short | sed -n 's/^??/error: missing .gitignore entry for/p' | (! grep '^') 132 133 # Clean up everything and show which file would be added to "make clean" 134 - make clean distclean 135 - |- 136 git ls-files --ignored --others --exclude-standard | sed 's/^/error: "make clean distclean" did not remove /' | (! grep '^') 137 138# Do not spam by email so long as the build succeeds 139notifications: 140 email: 141 on_success: never 142