Home | History | Annotate | Download | only in selinux
      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.6 RUBYLIBVER=2.4
     15     - PYVER=python3.6 RUBYLIBVER=2.4 TEST_FLAGS_OVERRIDE=1
     16     - PYVER=python3.6 RUBYLIBVER=2.4 LINKER=gold
     17     - PYVER=python3.6 RUBYLIBVER=2.4 LINKER=bfd
     18 
     19     # Test several Python versions
     20     - PYVER=python2.7 RUBYLIBVER=2.4
     21     - PYVER=python3.3 RUBYLIBVER=2.4
     22     - PYVER=python3.4 RUBYLIBVER=2.4
     23     - PYVER=python3.5 RUBYLIBVER=2.4
     24     - PYVER=pypy RUBYLIBVER=2.4
     25     - PYVER=pypy3 RUBYLIBVER=2.4
     26 
     27     # Test several Ruby versions
     28     - PYVER=python3.6 RUBYLIBVER=2.2
     29     - PYVER=python3.6 RUBYLIBVER=2.3
     30 
     31 matrix:
     32   exclude:
     33     - compiler: clang
     34       env: PYVER=python3.6 RUBYLIBVER=2.4 LINKER=gold
     35     - compiler: clang
     36       env: PYVER=python3.6 RUBYLIBVER=2.4 LINKER=bfd
     37 
     38 # Use Travis-CI Ubuntu 14.04 Trusty infrastructure, "full image" variant
     39 sudo: required
     40 dist: trusty
     41 
     42 # Install SELinux userspace utilities dependencies
     43 addons:
     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 
     64 install:
     65   # Download refpolicy Makefile for sepolgen tests
     66   - sudo mkdir -p /usr/share/selinux/default
     67   - sudo curl --retry 10 -o /usr/share/selinux/default/Makefile 'https://raw.githubusercontent.com/TresysTechnology/refpolicy/RELEASE_2_20170204/support/Makefile.devel'
     68   - sudo sed "s,^PREFIX :=.*,PREFIX := $TRAVIS_BUILD_DIR/installdir/usr," -i /usr/share/selinux/default/Makefile
     69   - sudo mkdir -p /usr/share/selinux/refpolicy/include
     70   - sudo curl --retry 10 -o /usr/share/selinux/refpolicy/include/build.conf 'https://raw.githubusercontent.com/TresysTechnology/refpolicy/RELEASE_2_20170204/build.conf'
     71   - sudo mkdir -p /etc/selinux
     72   - echo 'SELINUXTYPE=refpolicy' | sudo tee /etc/selinux/config
     73 
     74   # Make sepolgen tests work without really installing anything in the real root (doing this would conflict with Ubuntu packages)
     75   - sed -e "s,\"\(/usr/bin/[cs]\),\"$TRAVIS_BUILD_DIR/installdir\1," -i python/sepolgen/src/sepolgen/module.py
     76 
     77   # Download the required python version if it is not installed
     78   - VIRTUAL_ENV="$HOME/virtualenv/$PYVER"
     79   - if ! [ -d "$VIRTUAL_ENV" ] ; then
     80         curl --retry 10 -o python.tar.bz2 "https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/14.04/x86_64/${PYVER/python/python-}.tar.bz2" &&
     81         sudo tar xjf python.tar.bz2 --directory / &&
     82         rm python.tar.bz2 ;
     83     fi
     84 
     85 before_script:
     86   # clang on Travis-CI 14.04 environment is too old to support -Wdouble-promotion
     87   - if "$CC" --version |grep -q clang; then sed 's/ -Wdouble-promotion / /' -i libselinux/src/Makefile libselinux/utils/Makefile ; fi
     88 
     89   # Build and install in a temporary directory to run tests
     90   - export DESTDIR="$TRAVIS_BUILD_DIR/installdir"
     91 
     92   # Configure the variables for Python parts
     93   - export VIRTUAL_ENV="$HOME/virtualenv/$PYVER"
     94   - export PYTHON="$VIRTUAL_ENV/bin/python"
     95   # Use the header files in /opt/python/... for Python because the virtualenvs do not provide Python.h
     96   - export PKG_CONFIG_PATH="/opt/python/$($PYTHON -c 'import sys;print("%d.%d.%d" % sys.version_info[:3])')/lib/pkgconfig"
     97   # PyPy does not provide a config file for pkg-config nor a pypy-c.so
     98   - if echo "$PYVER" | grep -q pypy ; then export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include PYLIBS= ; fi
     99   # Python virtualenvs do not support "import site; print(site.getsitepackages()[0]"
    100   # cf. https://github.com/pypa/virtualenv/issues/355#issuecomment-10250452
    101   - export PYSITEDIR="$DESTDIR/usr/lib/$($PYTHON -c 'import sys;print("python%d.%d" % sys.version_info[:2])')/site-packages"
    102 
    103   # Find the Ruby executable with version $RUBYLIBVER
    104   - export RUBY="$(ls -d -1 "$HOME/.rvm/rubies/ruby-$RUBYLIBVER"*/bin/ruby | head -n 1)"
    105 
    106   # Set the linker in $CC so that it gets used everywhere
    107   - if [ -n "$LINKER" ]; then CC="$CC -fuse-ld=$LINKER" ; fi
    108 
    109   # Show variables and versions (to help debugging)
    110   - echo "$CC" ; $CC --version
    111   - echo "$PYTHON" ; $PYTHON --version
    112   - echo "$RUBY" ; $RUBY --version
    113 
    114   # If TEST_FLAGS_OVERRIDE is defined, test that overriding CFLAGS, LDFLAGS and other variables works fine
    115   - if [ -n "$TEST_FLAGS_OVERRIDE" ]; then EXPLICIT_MAKE_VARS="CFLAGS=-I$DESTDIR/usr/include LDFLAGS=-L$DESTDIR/usr/lib LDLIBS= CPPFLAGS=" ; fi
    116 
    117 script:
    118   # Start by installing everything into $DESTDIR
    119   - make install $EXPLICIT_MAKE_VARS -k
    120   - make install-pywrap $EXPLICIT_MAKE_VARS -k
    121   - make install-rubywrap $EXPLICIT_MAKE_VARS -k
    122 
    123   # Now that everything is installed, run "make all" to build everything which may have not been built
    124   - make all $EXPLICIT_MAKE_VARS -k
    125 
    126   # Set up environment variables for the tests
    127   - export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
    128   - export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
    129   - export PYTHONPATH="$PYSITEDIR"
    130   - export RUBYLIB="$DESTDIR/$($RUBY -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$($RUBY -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
    131 
    132   # Show variables (to help debugging issues)
    133   - echo "$LD_LIBRARY_PATH"
    134   - echo "$PATH"
    135   - echo "$PYTHONPATH"
    136   - echo "$RUBYLIB"
    137 
    138   # Run tests
    139   - make test $EXPLICIT_MAKE_VARS
    140 
    141   # Test Python and Ruby wrappers
    142   - $PYTHON -c 'import selinux;import selinux.audit2why;import semanage;print(selinux.is_selinux_enabled())'
    143   - $RUBY -e 'require "selinux";require "semanage";puts Selinux::is_selinux_enabled()'
    144 
    145   # Remove every installed files
    146   - rm -rf "$DESTDIR"
    147 
    148   # Test that "git status" looks clean, or print a clear error message
    149   - |-
    150     git status --short | sed -n 's/^??/error: missing .gitignore entry for/p' | (! grep '^')
    151 
    152   # Clean up everything and show which file would be added to "make clean"
    153   - make clean distclean $EXPLICIT_MAKE_VARS
    154   - |-
    155     git ls-files --ignored --others --exclude-standard | sed 's/^/error: "make clean distclean" did not remove /' | (! grep '^')
    156 
    157 # Do not spam by email so long as the build succeeds
    158 notifications:
    159   email:
    160     on_success: never
    161