blob: 1b761496dd12467e1c2f70a53a1cc6d97651fb86 [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
24 - PYVER=pypy2 RUBYLIBVER=2.4
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010025 #- 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 Iooss9a0279e2017-06-28 23:42:19 +020028 - PYVER=python3.6 RUBYLIBVER=2.1
29 - PYVER=python3.6 RUBYLIBVER=2.2
30 - PYVER=python3.6 RUBYLIBVER=2.3
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010031
Nicolas Ioossff2e3682017-08-05 12:16:49 +020032matrix:
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 Ioossb1ea8122017-08-05 12:16:48 +020039# Use Travis-CI Ubuntu 14.04 Trusty infrastructure, "full image" variant
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010040sudo: required
41dist: trusty
Nicolas Ioossb1ea8122017-08-05 12:16:48 +020042group: sugilite
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010043
44# Install SELinux userspace utilities dependencies
45addons:
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
66install:
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
79before_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 Iooss1cd3e1a2017-02-19 22:53:29 +010089 # 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 Ioossc9adfe22017-02-05 12:40:01 +010091 # 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 Iooss1edb93c2017-06-28 23:42:21 +0200108 # 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 Ioossc9adfe22017-02-05 12:40:01 +0100111script:
112 # Start by installing everything into $DESTDIR
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200113 - make install $EXPLICIT_MAKE_VARS -k
114 - make install-pywrap $EXPLICIT_MAKE_VARS -k
115 - make install-rubywrap $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100116
117 # Now that everything is installed, run "make all" to build everything which may have not been built
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200118 - make all $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100119
120 # Set up environment variables for the tests
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100121 - 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 Ioossc9adfe22017-02-05 12:40:01 +0100127 - echo "$LD_LIBRARY_PATH"
128 - echo "$PATH"
129 - echo "$PYTHONPATH"
130 - echo "$RUBYLIB"
131
132 # Run tests
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200133 - make test $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100134
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 Iooss1edb93c2017-06-28 23:42:21 +0200147 - make clean distclean $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100148 - |-
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
152notifications:
153 email:
154 on_success: never