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.7 RUBYLIBVER=2.6 15 - PYVER=python3.7 RUBYLIBVER=2.6 TEST_FLAGS_OVERRIDE=1 16 - PYVER=python3.7 RUBYLIBVER=2.6 LINKER=gold 17 - PYVER=python3.7 RUBYLIBVER=2.6 LINKER=bfd 18 19 # Test several Python versions 20 - PYVER=python2.7 RUBYLIBVER=2.6 21 - PYVER=python3.5 RUBYLIBVER=2.6 22 - PYVER=python3.6 RUBYLIBVER=2.6 23 - PYVER=pypy2.7-6.0 RUBYLIBVER=2.6 24 - PYVER=pypy3.5-6.0 RUBYLIBVER=2.6 25 26 # Test several Ruby versions (http://rubies.travis-ci.org/) 27 - PYVER=python3.7 RUBYLIBVER=2.5.1 28 - PYVER=python3.7 RUBYLIBVER=2.4 29 - PYVER=python3.7 RUBYLIBVER=2.3 30 - PYVER=python3.7 RUBYLIBVER=2.2 31 32matrix: 33 exclude: 34 - compiler: clang 35 env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=gold 36 - compiler: clang 37 env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=bfd 38 39# Use Travis-CI Ubuntu 16.04 Xenial Xerus infrastructure, "full image" variant 40sudo: required 41dist: xenial 42 43# Install SELinux userspace utilities dependencies 44addons: 45 apt: 46 packages: 47 - bison 48 - flex 49 - gawk 50 - gettext 51 - libaudit-dev 52 - libbz2-dev 53 - libcap-dev 54 - libcap-ng-dev # This package is not whitelisted for the container infrastructure (https://github.com/travis-ci/apt-package-whitelist/issues/1096) 55 - libcunit1-dev 56 - libdbus-glib-1-dev 57 - libncurses5-dev 58 - libpcre3-dev 59 - patch 60 - python3-dev 61 - python-dev 62 - swig 63 - xmlto 64 65install: 66 # Download and install refpolicy headers for sepolgen tests 67 - curl --location --retry 10 -o "$TRAVIS_BUILD_DIR/refpolicy.tar.bz2" https://github.com/SELinuxProject/refpolicy/releases/download/RELEASE_2_20180701/refpolicy-2.20180701.tar.bz2 68 - tar -C "$TRAVIS_BUILD_DIR" -xvjf "$TRAVIS_BUILD_DIR/refpolicy.tar.bz2" 69 # Make refpolicy Makefile use the new toolchain when building modules 70 - sed -e "s,^PREFIX :=.*,PREFIX := \$(DESTDIR)/usr," -i "$TRAVIS_BUILD_DIR/refpolicy/support/Makefile.devel" 71 - sudo make -C "$TRAVIS_BUILD_DIR/refpolicy" install-headers 72 - sudo rm -rf "$TRAVIS_BUILD_DIR/refpolicy.tar.bz2" "$TRAVIS_BUILD_DIR/refpolicy" 73 - sudo mkdir -p /etc/selinux 74 - echo 'SELINUXTYPE=refpolicy' | sudo tee /etc/selinux/config 75 - echo 'SELINUX_DEVEL_PATH = /usr/share/selinux/refpolicy' | sudo tee /etc/selinux/sepolgen.conf 76 77 # Make sepolgen tests work without really installing anything in the real root (doing this would conflict with Ubuntu packages) 78 - sed -e "s,\"\(/usr/bin/[cs]\),\"$TRAVIS_BUILD_DIR/installdir\1," -i python/sepolgen/src/sepolgen/module.py 79 80 # Download the required python version if it is not installed 81 - VIRTUAL_ENV="$HOME/virtualenv/$PYVER" 82 - if ! [ -d "$VIRTUAL_ENV" ] ; then 83 curl --retry 10 -o python.tar.bz2 "https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/16.04/x86_64/${PYVER/python/python-}.tar.bz2" && 84 sudo tar xjf python.tar.bz2 --directory / && 85 rm python.tar.bz2 ; 86 fi 87 88 # Install flake8 for the given python version 89 - $VIRTUAL_ENV/bin/pip install flake8 90 91before_script: 92 # Build and install in a temporary directory to run tests 93 - export DESTDIR="$TRAVIS_BUILD_DIR/installdir" 94 95 # Configure the variables for Python parts 96 - export VIRTUAL_ENV="$HOME/virtualenv/$PYVER" 97 - export PYTHON="$VIRTUAL_ENV/bin/python" 98 # Use the header files in /opt/python/... for Python because the virtualenvs do not provide Python.h 99 - export PKG_CONFIG_PATH="/opt/python/$($PYTHON -c 'import sys;print("%d.%d.%d" % sys.version_info[:3])')/lib/pkgconfig" 100 # PyPy does not provide a config file for pkg-config 101 # libpypy-c.so is provided in bin/libpypy-c.so for PyPy and bin/libpypy3-c.so for PyPy3 102 - if echo "$PYVER" | grep -q pypy ; then 103 export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include ; 104 export PYLIBS="$($PYTHON -c 'import sys;print("-L%s/bin -l%s" % (sys.prefix, "pypy-c" if sys.version_info < (3,) else "pypy3-c"))')" ; 105 fi 106 107 # Find the Ruby executable with version $RUBYLIBVER 108 - rvm reinstall ruby-$RUBYLIBVER --binary 109 - export RUBY="$(ls -d -1 "$HOME/.rvm/rubies/ruby-$RUBYLIBVER"*/bin/ruby | head -n 1)" 110 111 # Set the linker in $CC so that it gets used everywhere 112 - if [ -n "$LINKER" ]; then CC="$CC -fuse-ld=$LINKER" ; fi 113 114 # Show variables and versions (to help debugging) 115 - echo "$CC" ; $CC --version 116 - echo "$PYTHON" ; $PYTHON --version 117 - echo "$RUBY" ; $RUBY --version 118 119 # If TEST_FLAGS_OVERRIDE is defined, test that overriding CFLAGS, LDFLAGS and other variables works fine 120 - if [ -n "$TEST_FLAGS_OVERRIDE" ]; then EXPLICIT_MAKE_VARS="CFLAGS=-I$DESTDIR/usr/include LDFLAGS=-L$DESTDIR/usr/lib LDLIBS= CPPFLAGS=" ; fi 121 122script: 123 # Start by installing everything into $DESTDIR 124 - make install $EXPLICIT_MAKE_VARS -k 125 - make install-pywrap $EXPLICIT_MAKE_VARS -k 126 - make install-rubywrap $EXPLICIT_MAKE_VARS -k 127 128 # Now that everything is installed, run "make all" to build everything which may have not been built 129 - make all $EXPLICIT_MAKE_VARS -k 130 131 # Set up environment variables for the tests 132 - . ./scripts/env_use_destdir 133 134 # Show variables (to help debugging issues) 135 - echo "$LD_LIBRARY_PATH" 136 - echo "$PATH" 137 - echo "$PYTHONPATH" 138 - echo "$RUBYLIB" 139 140 # Run tests 141 - make test $EXPLICIT_MAKE_VARS 142 143 # Test Python and Ruby wrappers 144 - $PYTHON -c 'import selinux;import selinux.audit2why;import semanage;print(selinux.is_selinux_enabled())' 145 - $RUBY -e 'require "selinux";require "semanage";puts Selinux::is_selinux_enabled()' 146 147 # Run Python linter 148 - PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8 149 150 # Remove every installed files 151 - rm -rf "$DESTDIR" 152 153 # Test that "git status" looks clean, or print a clear error message 154 - |- 155 git status --short | sed -n 's/^??/error: missing .gitignore entry for/p' | (! grep '^') 156 157 # Clean up everything and show which file would be added to "make clean" 158 - make clean distclean $EXPLICIT_MAKE_VARS 159 - |- 160 git ls-files --ignored --others --exclude-standard | sed 's/^/error: "make clean distclean" did not remove /' | (! grep '^') 161 162# Do not spam by email so long as the build succeeds 163notifications: 164 email: 165 on_success: never 166