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