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 | dbcada0 | 2019-01-20 20:19:32 +0100 | [diff] [blame] | 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 |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 18 | |
| 19 | # Test several Python versions |
Nicolas Iooss | dbcada0 | 2019-01-20 20:19:32 +0100 | [diff] [blame] | 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 |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 25 | |
Nicolas Iooss | dbcada0 | 2019-01-20 20:19:32 +0100 | [diff] [blame] | 26 | # Test several Ruby versions (http://rubies.travis-ci.org/) |
| 27 | - PYVER=python3.7 RUBYLIBVER=2.5.1 |
Nicolas Iooss | b5e2da2 | 2018-08-19 15:43:30 +0200 | [diff] [blame] | 28 | - PYVER=python3.7 RUBYLIBVER=2.4 |
| 29 | - PYVER=python3.7 RUBYLIBVER=2.3 |
| 30 | - PYVER=python3.7 RUBYLIBVER=2.2 |
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 |
Nicolas Iooss | dbcada0 | 2019-01-20 20:19:32 +0100 | [diff] [blame] | 35 | env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=gold |
Nicolas Iooss | ff2e368 | 2017-08-05 12:16:49 +0200 | [diff] [blame] | 36 | - compiler: clang |
Nicolas Iooss | dbcada0 | 2019-01-20 20:19:32 +0100 | [diff] [blame] | 37 | env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=bfd |
Nicolas Iooss | ff2e368 | 2017-08-05 12:16:49 +0200 | [diff] [blame] | 38 | |
Nicolas Iooss | b5e2da2 | 2018-08-19 15:43:30 +0200 | [diff] [blame] | 39 | # Use Travis-CI Ubuntu 16.04 Xenial Xerus infrastructure, "full image" variant |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 40 | sudo: required |
Nicolas Iooss | b5e2da2 | 2018-08-19 15:43:30 +0200 | [diff] [blame] | 41 | dist: xenial |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 42 | |
| 43 | # Install SELinux userspace utilities dependencies |
| 44 | addons: |
| 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 | |
| 65 | install: |
Nicolas Iooss | 53c7a04 | 2019-01-05 20:37:55 +0100 | [diff] [blame] | 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" |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 73 | - sudo mkdir -p /etc/selinux |
| 74 | - echo 'SELINUXTYPE=refpolicy' | sudo tee /etc/selinux/config |
Nicolas Iooss | 53c7a04 | 2019-01-05 20:37:55 +0100 | [diff] [blame] | 75 | - echo 'SELINUX_DEVEL_PATH = /usr/share/selinux/refpolicy' | sudo tee /etc/selinux/sepolgen.conf |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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 | |
Nicolas Iooss | 6d9258e | 2017-09-23 15:45:53 +0200 | [diff] [blame] | 80 | # Download the required python version if it is not installed |
| 81 | - VIRTUAL_ENV="$HOME/virtualenv/$PYVER" |
| 82 | - if ! [ -d "$VIRTUAL_ENV" ] ; then |
Nicolas Iooss | b5e2da2 | 2018-08-19 15:43:30 +0200 | [diff] [blame] | 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" && |
Nicolas Iooss | 6d9258e | 2017-09-23 15:45:53 +0200 | [diff] [blame] | 84 | sudo tar xjf python.tar.bz2 --directory / && |
| 85 | rm python.tar.bz2 ; |
| 86 | fi |
| 87 | |
Nicolas Iooss | 41764b7 | 2018-08-04 14:57:39 +0200 | [diff] [blame] | 88 | # Install flake8 for the given python version |
| 89 | - $VIRTUAL_ENV/bin/pip install flake8 |
| 90 | |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 91 | before_script: |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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" |
Nicolas Iooss | 1cd3e1a | 2017-02-19 22:53:29 +0100 | [diff] [blame] | 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" |
Nicolas Iooss | 111c541 | 2019-01-20 20:19:31 +0100 | [diff] [blame] | 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 |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 106 | |
| 107 | # Find the Ruby executable with version $RUBYLIBVER |
Jason Zaman | b2d710d | 2018-05-21 15:44:08 +0800 | [diff] [blame] | 108 | - rvm reinstall ruby-$RUBYLIBVER --binary |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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 | |
Nicolas Iooss | 1edb93c | 2017-06-28 23:42:21 +0200 | [diff] [blame] | 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 | |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 122 | script: |
| 123 | # Start by installing everything into $DESTDIR |
Nicolas Iooss | 1edb93c | 2017-06-28 23:42:21 +0200 | [diff] [blame] | 124 | - make install $EXPLICIT_MAKE_VARS -k |
| 125 | - make install-pywrap $EXPLICIT_MAKE_VARS -k |
| 126 | - make install-rubywrap $EXPLICIT_MAKE_VARS -k |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 127 | |
| 128 | # 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] | 129 | - make all $EXPLICIT_MAKE_VARS -k |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 130 | |
| 131 | # Set up environment variables for the tests |
Nicolas Iooss | 9e0ed5c | 2019-01-20 20:19:33 +0100 | [diff] [blame] | 132 | - . ./scripts/env_use_destdir |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 133 | |
| 134 | # Show variables (to help debugging issues) |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 135 | - echo "$LD_LIBRARY_PATH" |
| 136 | - echo "$PATH" |
| 137 | - echo "$PYTHONPATH" |
| 138 | - echo "$RUBYLIB" |
| 139 | |
| 140 | # Run tests |
Nicolas Iooss | 1edb93c | 2017-06-28 23:42:21 +0200 | [diff] [blame] | 141 | - make test $EXPLICIT_MAKE_VARS |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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 | |
Nicolas Iooss | 41764b7 | 2018-08-04 14:57:39 +0200 | [diff] [blame] | 147 | # Run Python linter |
| 148 | - PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8 |
| 149 | |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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" |
Nicolas Iooss | 1edb93c | 2017-06-28 23:42:21 +0200 | [diff] [blame] | 158 | - make clean distclean $EXPLICIT_MAKE_VARS |
Nicolas Iooss | c9adfe2 | 2017-02-05 12:40:01 +0100 | [diff] [blame] | 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 |
| 163 | notifications: |
| 164 | email: |
| 165 | on_success: never |