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