From a5f1f19b275bd7c09b4f4cf934d47e476bdddf7d Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 21 May 2019 11:37:29 +0200 Subject: [PATCH] travis: move checks into script This makes error handling easier and more robust: https://docs.travis-ci.com/user/job-lifecycle#complex-build-commands --- .travis.yml | 64 +------------------------------------------------ qa/travis.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 63 deletions(-) create mode 100755 qa/travis.sh diff --git a/.travis.yml b/.travis.yml index d6c15faf80..51e7be6846 100644 --- a/.travis.yml +++ b/.travis.yml @@ -216,69 +216,7 @@ matrix: packages: - *packages-without-nssnspr -script: - - | - sh ./autogen.sh - - if [[ "${NO_UNITTESTS}" != "yes" ]]; then - ARGS="${ARGS} --enable-unittests" - fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" - if ! ./configure --enable-nfqueue --enable-hiredis ${ARGS}; then - if [[ "${CONFIGURE_SHOULD_FAIL}" = "yes" ]]; then - EXIT_CODE=0 - else - EXIT_CODE=1 - fi - fi - elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" - ./configure --enable-hiredis --enable-ipfw \ - --enable-lua --with-libpcre-includes=/usr/local/include \ - --with-libpcre-includes=/usr/local/include \ - --with-libpcre-libraries=/usr/local/lib \ - --with-libnss-includes=/usr/local/opt/nss/include/nss \ - --with-libnss-libraries=/usr/local/opt/nss/lib \ - --with-libnspr-includes=/usr/local/opt/nspr/include/nspr \ - --with-libnspr-libraries=/usr/local/opt/nspr/lib ${ARGS} - fi - - if [[ "${EXIT_CODE}" ]]; then - exit "${EXIT_CODE}" - fi - - # Linux container builds have 2 cores, make use of them. - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - j="-j 2" - fi - make ${j} - - # Like "make check", but fail on first error. We redirect the output - # so Travis doesn't fail the build with a too much output error. - if [[ "${NO_UNITTESTS}" != "yes" ]]; then - mkdir -p ./qa/log - ./src/suricata -u -l ./qa/log --fatal-unittests > unittests.log 2>&1 - if [[ $? -ne 0 ]]; then - echo "Unit tests failed, last 500 lines of output are:" - tail -n 500 unittests.log - exit 1 - fi - fi - - (cd qa/coccinelle && make check) - - if [[ "$DO_DISTCHECK" == "yes" ]]; then - make distcheck DISTCHECK_CONFIGURE_FLAGS="${ARGS}" - fi - - if [[ "$DO_CHECK_SETUP_SCRIPTS" == "yes" ]]; then - (cd scripts && ./check-setup.sh) - fi - - git clone https://github.com/OISF/suricata-verify.git verify - python ./verify/run.py +script: ./qa/travis.sh before_install: - export PATH=$HOME/.cargo/bin:$PATH diff --git a/qa/travis.sh b/qa/travis.sh new file mode 100755 index 0000000000..b2c46f1251 --- /dev/null +++ b/qa/travis.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -ev + +./autogen.sh + +if [[ "${NO_UNITTESTS}" != "yes" ]]; then + ARGS="${ARGS} --enable-unittests" +fi + +if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" + if ! ./configure --enable-nfqueue --enable-hiredis ${ARGS}; then + if [[ "${CONFIGURE_SHOULD_FAIL}" = "yes" ]]; then + EXIT_CODE=0 + else + EXIT_CODE=1 + fi + fi +elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export CFLAGS="${CFLAGS} ${EXTRA_CFLAGS}" + ./configure --enable-hiredis --enable-ipfw \ + --enable-lua --with-libpcre-includes=/usr/local/include \ + --with-libpcre-includes=/usr/local/include \ + --with-libpcre-libraries=/usr/local/lib \ + --with-libnss-includes=/usr/local/opt/nss/include/nss \ + --with-libnss-libraries=/usr/local/opt/nss/lib \ + --with-libnspr-includes=/usr/local/opt/nspr/include/nspr \ + --with-libnspr-libraries=/usr/local/opt/nspr/lib ${ARGS} +fi + +if [[ "${EXIT_CODE}" ]]; then + exit "${EXIT_CODE}" +fi + +# Linux container builds have 2 cores, make use of them. +if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + j="-j 2" +fi +make ${j} + +# Like "make check", but fail on first error. We redirect the output +# so Travis doesn't fail the build with a too much output error. +if [[ "${NO_UNITTESTS}" != "yes" ]]; then + set +e # disable + mkdir -p ./qa/log + ./src/suricata -u -l ./qa/log --fatal-unittests > unittests.log 2>&1 + if [[ $? -ne 0 ]]; then + echo "Unit tests failed, last 500 lines of output are:" + tail -n 500 unittests.log + exit 1 + fi + set -e +fi + +(cd qa/coccinelle && make check) + +if [[ "$DO_DISTCHECK" == "yes" ]]; then + make distcheck DISTCHECK_CONFIGURE_FLAGS="${ARGS}" +fi + +if [[ "$DO_CHECK_SETUP_SCRIPTS" == "yes" ]]; then + (cd scripts && ./check-setup.sh) +fi + +git clone https://github.com/OISF/suricata-verify.git verify +python ./verify/run.py