blob: 7a9e73ce55db1702d249146d376232df424a1617 [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 Ioossdbcada02019-01-20 20:19:32 +010014 - 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 Ioossc9adfe22017-02-05 12:40:01 +010018
19 # Test several Python versions
Nicolas Ioossdbcada02019-01-20 20:19:32 +010020 - 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 Ioossc9adfe22017-02-05 12:40:01 +010025
Nicolas Ioossdbcada02019-01-20 20:19:32 +010026 # Test several Ruby versions (http://rubies.travis-ci.org/)
27 - PYVER=python3.7 RUBYLIBVER=2.5.1
Nicolas Ioossb5e2da22018-08-19 15:43:30 +020028 - PYVER=python3.7 RUBYLIBVER=2.4
29 - PYVER=python3.7 RUBYLIBVER=2.3
30 - PYVER=python3.7 RUBYLIBVER=2.2
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010031
Nicolas Ioossff2e3682017-08-05 12:16:49 +020032matrix:
33 exclude:
34 - compiler: clang
Nicolas Ioossdbcada02019-01-20 20:19:32 +010035 env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=gold
Nicolas Ioossff2e3682017-08-05 12:16:49 +020036 - compiler: clang
Nicolas Ioossdbcada02019-01-20 20:19:32 +010037 env: PYVER=python3.7 RUBYLIBVER=2.6 LINKER=bfd
Nicolas Ioossff2e3682017-08-05 12:16:49 +020038
Nicolas Ioossb5e2da22018-08-19 15:43:30 +020039# Use Travis-CI Ubuntu 16.04 Xenial Xerus infrastructure, "full image" variant
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010040sudo: required
Nicolas Ioossb5e2da22018-08-19 15:43:30 +020041dist: xenial
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010042
43# Install SELinux userspace utilities dependencies
44addons:
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
65install:
Nicolas Iooss53c7a042019-01-05 20:37:55 +010066 # 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 Ioossc9adfe22017-02-05 12:40:01 +010073 - sudo mkdir -p /etc/selinux
74 - echo 'SELINUXTYPE=refpolicy' | sudo tee /etc/selinux/config
Nicolas Iooss53c7a042019-01-05 20:37:55 +010075 - echo 'SELINUX_DEVEL_PATH = /usr/share/selinux/refpolicy' | sudo tee /etc/selinux/sepolgen.conf
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010076
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 Iooss6d9258e2017-09-23 15:45:53 +020080 # Download the required python version if it is not installed
81 - VIRTUAL_ENV="$HOME/virtualenv/$PYVER"
82 - if ! [ -d "$VIRTUAL_ENV" ] ; then
Nicolas Ioossb5e2da22018-08-19 15:43:30 +020083 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 Iooss6d9258e2017-09-23 15:45:53 +020084 sudo tar xjf python.tar.bz2 --directory / &&
85 rm python.tar.bz2 ;
86 fi
87
Nicolas Iooss41764b72018-08-04 14:57:39 +020088 # Install flake8 for the given python version
89 - $VIRTUAL_ENV/bin/pip install flake8
90
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010091before_script:
Nicolas Ioossc9adfe22017-02-05 12:40:01 +010092 # 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 Iooss1cd3e1a2017-02-19 22:53:29 +010098 # 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 Iooss111c5412019-01-20 20:19:31 +0100100 # 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 Ioossc9adfe22017-02-05 12:40:01 +0100106
107 # Find the Ruby executable with version $RUBYLIBVER
Jason Zamanb2d710d2018-05-21 15:44:08 +0800108 - rvm reinstall ruby-$RUBYLIBVER --binary
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100109 - 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 Iooss1edb93c2017-06-28 23:42:21 +0200119 # 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 Ioossc9adfe22017-02-05 12:40:01 +0100122script:
123 # Start by installing everything into $DESTDIR
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200124 - make install $EXPLICIT_MAKE_VARS -k
125 - make install-pywrap $EXPLICIT_MAKE_VARS -k
126 - make install-rubywrap $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100127
128 # Now that everything is installed, run "make all" to build everything which may have not been built
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200129 - make all $EXPLICIT_MAKE_VARS -k
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100130
131 # Set up environment variables for the tests
Nicolas Iooss9e0ed5c2019-01-20 20:19:33 +0100132 - . ./scripts/env_use_destdir
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100133
134 # Show variables (to help debugging issues)
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100135 - echo "$LD_LIBRARY_PATH"
136 - echo "$PATH"
137 - echo "$PYTHONPATH"
138 - echo "$RUBYLIB"
139
140 # Run tests
Nicolas Iooss1edb93c2017-06-28 23:42:21 +0200141 - make test $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100142
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 Iooss41764b72018-08-04 14:57:39 +0200147 # Run Python linter
148 - PATH="$VIRTUAL_ENV/bin:$PATH" ./scripts/run-flake8
149
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100150 # 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 Iooss1edb93c2017-06-28 23:42:21 +0200158 - make clean distclean $EXPLICIT_MAKE_VARS
Nicolas Ioossc9adfe22017-02-05 12:40:01 +0100159 - |-
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
163notifications:
164 email:
165 on_success: never