1 # Define the building environment 2 language: c 3 4 matrix: 5 fast_finish: true 6 7 compiler: 8 - clang 9 - gcc 10 11 env: 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 31 sudo: required 32 dist: trusty 33 34 # Install SELinux userspace utilities dependencies 35 addons: 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 56 install: 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 69 before_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 - export PYPREFIX="$($PYTHON -c 'import sys;print("python%d" % sys.version_info[0])')" 80 # PyPy does not provide a config file for pkg-config nor a pypy-c.so 81 - if echo "$PYVER" | grep -q pypy ; then export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include PYLIBS= ; fi 82 # Python virtualenvs do not support "import site; print(site.getsitepackages()[0]" 83 # cf. https://github.com/pypa/virtualenv/issues/355#issuecomment-10250452 84 - export PYSITEDIR="$DESTDIR/usr/lib/$($PYTHON -c 'import sys;print("python%d.%d" % sys.version_info[:2])')/site-packages" 85 86 # Find the Ruby executable with version $RUBYLIBVER 87 - export RUBY="$(ls -d -1 "$HOME/.rvm/rubies/ruby-$RUBYLIBVER"*/bin/ruby | head -n 1)" 88 89 # Set the linker in $CC so that it gets used everywhere 90 - if [ -n "$LINKER" ]; then CC="$CC -fuse-ld=$LINKER" ; fi 91 92 # Show variables and versions (to help debugging) 93 - echo "$CC" ; $CC --version 94 - echo "$PYTHON" ; $PYTHON --version 95 - echo "$RUBY" ; $RUBY --version 96 97 script: 98 # Start by installing everything into $DESTDIR 99 - make install -k 100 - make install-pywrap -k 101 - make install-rubywrap -k 102 103 # Now that everything is installed, run "make all" to build everything which may have not been built 104 - make all -k 105 106 # Set up environment variables for the tests 107 - export CFLAGS="-I$DESTDIR/usr/include" 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 "$CFLAGS" 115 - echo "$LD_LIBRARY_PATH" 116 - echo "$PATH" 117 - echo "$PYTHONPATH" 118 - echo "$RUBYLIB" 119 120 # Run tests 121 - make test 122 123 # Test Python and Ruby wrappers 124 - $PYTHON -c 'import selinux;import selinux.audit2why;import semanage;print(selinux.is_selinux_enabled())' 125 - $RUBY -e 'require "selinux";require "semanage";puts Selinux::is_selinux_enabled()' 126 127 # Remove every installed files 128 - rm -rf "$DESTDIR" 129 130 # Test that "git status" looks clean, or print a clear error message 131 - |- 132 git status --short | sed -n 's/^??/error: missing .gitignore entry for/p' | (! grep '^') 133 134 # Clean up everything and show which file would be added to "make clean" 135 - make clean distclean 136 - |- 137 git ls-files --ignored --others --exclude-standard | sed 's/^/error: "make clean distclean" did not remove /' | (! grep '^') 138 139 # Do not spam by email so long as the build succeeds 140 notifications: 141 email: 142 on_success: never 143