blob: e21b4d2198e5eb83ec45e60c5b504a41698bc649 [file] [log] [blame]
Nicolas Ioossc9adfe22017-02-05 12:40:01 +01001# 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
Nicolas Iooss9a0279e2017-06-28 23:42:19 +020014 - PYVER=python3.6 RUBYLIBVER=2.4
Nicolas Iooss1edb93c2017-06-28 23:42:21 +020015 - PYVER=python3.6 RUBYLIBVER=2.4 TEST_FLAGS_OVERRIDE=1
Nicolas Iooss9a0279e2017-06-28 23:42:19 +020016 - PYVER=python3.6 RUBYLIBVER=2.4 LINKER=gold
17 - PYVER=python3.6 RUBYLIBVER=2.4 LINKER=bfd
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010018
19 # Test several Python versions
Nicolas Iooss9a0279e2017-06-28 23:42:19 +020020 - 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
Nicolas Iooss6d9258e2017-09-23 15:45:53 +020024 - PYVER=pypy RUBYLIBVER=2.4
25 - PYVER=pypy3 RUBYLIBVER=2.4
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010026
27 # Test several Ruby versions
Nicolas Iooss9a0279e2017-06-28 23:42:19 +020028 - PYVER=python3.6 RUBYLIBVER=2.2
29 - PYVER=python3.6 RUBYLIBVER=2.3
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010030
Nicolas Ioossff2e3682017-08-05 12:16:49 +020031matrix:
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
Nicolas Ioossb1ea8122017-08-05 12:16:48 +020038# Use Travis-CI Ubuntu 14.04 Trusty infrastructure, "full image" variant
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010039sudo: required
40dist: trusty
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 refpolicy Makefile for sepolgen tests
66 - sudo mkdir -p /usr/share/selinux/default
67 - sudo curl -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 -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
Nicolas Iooss6d9258e2017-09-23 15:45:53 +020077 # Download the required python version if it is not installed
78 - VIRTUAL_ENV="$HOME/virtualenv/$PYVER"
79 - if ! [ -d "$VIRTUAL_ENV" ] ; then
80 curl -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
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010085before_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"
Nicolas Iooss1cd3e1a2017-02-19 22:53:29 +010095 # 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"
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010097 # 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
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200114 # 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
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100117script:
118 # Start by installing everything into $DESTDIR
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200119 - make install $EXPLICIT_MAKE_VARS -k
120 - make install-pywrap $EXPLICIT_MAKE_VARS -k
121 - make install-rubywrap $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100122
123 # Now that everything is installed, run "make all" to build everything which may have not been built
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200124 - make all $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100125
126 # Set up environment variables for the tests
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100127 - 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)
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100133 - echo "$LD_LIBRARY_PATH"
134 - echo "$PATH"
135 - echo "$PYTHONPATH"
136 - echo "$RUBYLIB"
137
138 # Run tests
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200139 - make test $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100140
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"
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200153 - make clean distclean $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100154 - |-
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
158notifications:
159 email:
160 on_success: never