Skip to content

Commit

Permalink
Cleaned up .travis.yml and created travis-scripts folder
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@cfengine.com>
  • Loading branch information
olehermanse committed Mar 29, 2017
1 parent 19de827 commit dfc40ca
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 81 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ cscope.*
/core.includes
*.autosave

# Mac Finder
# Mac
.DS_Store
*.dSYM
95 changes: 17 additions & 78 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: c
sudo: required

addons:
artifacts:
Expand All @@ -8,6 +7,7 @@ addons:

env:
global:
- CI_NODE_TOTAL=6
# Quickest to build, fast performing, debugable builds.
- CFLAGS="-g1 -O1"
# upload log files, tarballs etc artifacts from the build.
Expand All @@ -20,104 +20,43 @@ env:
# https://docs.travis-ci.com/user/multi-os/
matrix:
include:
- env: JOB_TYPE=compile_and_unit_test
- env: JOB_TYPE=acceptance_tests_common
- os: linux
sudo: required
env: JOB_TYPE=compile_and_unit_test
- os: linux
sudo: required
env: JOB_TYPE=acceptance_tests_common
# The unsafe acceptance tests don't work with SIMFS which is the default
# filesystem in Travis; so change OS to Trusty, which uses ext4.
- env: JOB_TYPE=acceptance_tests_unsafe_serial_network_etc

- os: linux
sudo: required
env: JOB_TYPE=acceptance_tests_unsafe_serial_network_etc

before_install:
- sudo apt-get -qq update
# Needed to build
- sudo apt-get install -y libssl-dev libpam0g-dev libtokyocabinet-dev
# Optional
- sudo apt-get install -y libxml2-dev libacl1-dev

- chmod ug+x ./travis-scripts/*
- source ./travis-scripts/before_install.sh

script:
- INSTDIR=$HOME/cf_install
- cd $TRAVIS_BUILD_DIR

# - if [ "$JOB_TYPE" = style_check ];
# then
# # sh tests/misc/style_check.sh;
# exit 0;
# fi

# Fetch the tags from upstream, even if we are running on a foreign clone;
# Needed for determine-version.py to work
- git remote add upstream https://github.com/cfengine/core.git &&
git fetch -q upstream 'refs/tags/*:refs/tags/*'

- NO_CONFIGURE=1 ./autogen.sh
- ./configure --enable-debug --with-tokyocabinet --prefix=$INSTDIR --with-init-script

- make dist
- export DIST_TARBALL=`echo cfengine-*.tar.gz`

- if [ "$JOB_TYPE" = compile_and_unit_test ];
then
make CFLAGS=-Werror &&
make -C tests/unit check;
return;
else
make;
fi

- cd tests/acceptance
- chmod -R go-w .

- if [ "$JOB_TYPE" = acceptance_tests_common ];
then
./testall --tests=common;
return;
fi

# WARNING: the following job runs the selected tests as root!
- if [ "$JOB_TYPE" = acceptance_tests_unsafe_serial_network_etc ];
then
./testall --gainroot=sudo --tests=timed,errorexit,libxml2,libcurl,serial,network,unsafe;
return;
fi

- source ./travis-scripts/script.sh

before_deploy:

# A tag ending with "number.number" is not a prerelease
- if echo $DIST_TARBALL | grep -E -q '[0-9]{1,2}\.[0-9]{1,2}\.tar\.gz';
then
IS_PRERELEASE=false;
else
IS_PRERELEASE=true;
fi;
export IS_PRERELEASE

- source ./travis-scripts/before_deploy.sh

# We deploy when setting tags only, which basically never happens
# on master branch. Cherry-pick this part and alter it properly into
# the release branches.

deploy:
skip_cleanup: true
provider: releases
# Remember to set it as private variable in Travis-CI settings
api_key: $GITHUB_RELEASE_TOKEN
# Does not work, I get the error that "true" is not a boolean
# prerelease: $IS_PRERELEASE
file:
- "$DIST_TARBALL"
prerelease: $IS_PRERELEASE
file: "$DIST_TARBALL"
on:
tags: true
# Avoid upload from all the multiple parallel matrix jobs
condition: "$CF_VERSION = latest"


after_script:
- cd $TRAVIS_BUILD_DIR
- mkdir artifacts
- test "x$DIST_TARBALL" != x && cp --verbose "$DIST_TARBALL" artifacts/
- gzip config.log && mv config.log.gz artifacts/
- gzip tests/acceptance/summary.log && mv tests/acceptance/summary.log.gz artifacts/acceptance_summary.log.gz
- gzip tests/acceptance/test.log && mv tests/acceptance/test.log.gz artifacts/acceptance.log.gz
- zip -r artifacts/acceptance_workdir.zip tests/acceptance/workdir
- source ./travis-scripts/after_script.sh
9 changes: 7 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ dnl exist in automake 1.11 and earlier, so we need to do this complicated logic
dnl to determine whether we can disable it or not. If it doesn't exist as an
dnl option, then serial tests are already the default.
AC_MSG_CHECKING([automake version])
m4_define(AUTOMAKE_VERSION, m4_normalize(m4_esyscmd([automake --version 2>&1 | sed -ne '/^automake/{s/^automake.* \([^ ][^ ]*\)$/\1/; p}'])))
m4_define(AUTOMAKE_VERSION, m4_normalize(m4_esyscmd([automake --version 2>&1 | sed -ne '/^automake/{s/^automake.* \([^ ][^ ]*\)$/\1/; p;}'])))
m4_define(SERIAL_TESTS, m4_bmatch(AUTOMAKE_VERSION, [^1\.\([0-9]\|1[0-1]\)\(\.\|$\)], [], [serial-tests]))
AC_MSG_RESULT(AUTOMAKE_VERSION)

Expand Down Expand Up @@ -683,7 +683,12 @@ AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_CHECK_TYPES(clockid_t)
AC_CHECK_TYPES(clockid_t, [], [], [[
#ifdef HAVE_TIME_H
# include <time.h>
#endif
]])

AC_CHECK_TYPES(socklen_t, [], [], [[
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ XFAIL_TESTS = evalfunction_test # Redmine 6318
XFAIL_TESTS += set_domainname_test # Redmine 6317
endif

if MACOSX
XFAIL_TESTS = set_domainname_test
XFAIL_TESTS += evalfunction_test
XFAIL_TESTS += process_test
XFAIL_TESTS += mon_processes_test
endif

if HPUX
XFAIL_TESTS = mon_load_test # Redmine #3569
endif
Expand Down
7 changes: 7 additions & 0 deletions travis-scripts/after_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cd $TRAVIS_BUILD_DIR
mkdir artifacts
test "x$DIST_TARBALL" != x && cp --verbose "$DIST_TARBALL" artifacts/
gzip config.log && mv config.log.gz artifacts/
gzip tests/acceptance/summary.log && mv tests/acceptance/summary.log.gz artifacts/acceptance_summary.log.gz
gzip tests/acceptance/test.log && mv tests/acceptance/test.log.gz artifacts/acceptance.log.gz
zip -r artifacts/acceptance_workdir.zip tests/acceptance/workdir
8 changes: 8 additions & 0 deletions travis-scripts/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# A tag ending with "number.number" is not a prerelease
if echo $DIST_TARBALL | grep -E -q '[0-9]{1,2}\.[0-9]{1,2}\.tar\.gz';
then
IS_PRERELEASE=false;
else
IS_PRERELEASE=true;
fi;
export IS_PRERELEASE
5 changes: 5 additions & 0 deletions travis-scripts/before_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sudo apt-get -qq update
# Needed to build
sudo apt-get install -y libssl-dev libpam0g-dev libtokyocabinet-dev
# Optional
sudo apt-get install -y libxml2-dev libacl1-dev
49 changes: 49 additions & 0 deletions travis-scripts/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
INSTDIR=$HOME/cf_install
cd $TRAVIS_BUILD_DIR

# if [ "$JOB_TYPE" = style_check ];
# then
# # sh tests/misc/style_check.sh;
# exit 0;
# fi

# Fetch the tags from upstream, even if we are running on a foreign clone;
# Needed for determine-version.py to work
git remote add upstream https://github.com/cfengine/core.git && git fetch -q upstream 'refs/tags/*:refs/tags/*'

if [[ ${TRAVIS_OS_NAME} = osx ]]; then
# On osx the default gcc is actually LLVM
export CC=gcc-6
NO_CONFIGURE=1 ./autogen.sh
./configure --enable-debug --prefix=$INSTDIR --with-init-script --with-lmdb=/usr/local/Cellar/lmdb/ --with-openssl=/usr/local/opt/openssl
else
NO_CONFIGURE=1 ./autogen.sh
./configure --enable-debug --with-tokyocabinet --prefix=$INSTDIR --with-init-script
fi

make dist
export DIST_TARBALL=`echo cfengine-*.tar.gz`

if [ "$JOB_TYPE" = compile_and_unit_test ];
then
make CFLAGS=-Werror &&
make -C tests/unit check;
return;
else
make;
fi

cd tests/acceptance
chmod -R go-w .

if [ "$JOB_TYPE" = acceptance_tests_common ];
then
./testall --tests=common;
return;
fi

# WARNING: the following job runs the selected tests as root!
if [ "$JOB_TYPE" = acceptance_tests_unsafe_serial_network_etc ]; then
./testall --gainroot=sudo --tests=timed,errorexit,libxml2,libcurl,serial,network,unsafe;
return;
fi

0 comments on commit dfc40ca

Please sign in to comment.