diff --git a/.travis.yml b/.travis.yml index a15db459..cf56c951 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,26 +3,62 @@ language: cpp # NOTE: Make sure the matrix covers all node types in top.sls +# NOTE: Make sure each node type is tested both from scratch and as an upgrade # sudo: required and dist: trusty enable usage of Trusty matrix: include: - - env: SALT_NODE_ID=servo-linux-cross1 + # Salt from scratch + - env: + - SALT_NODE_ID=servo-linux-cross1 + - SALT_FROM_SCRATCH=true os: linux sudo: required dist: trusty - - env: SALT_NODE_ID=servo-mac1 + - env: + - SALT_NODE_ID=servo-mac1 + - SALT_FROM_SCRATCH=true os: osx - - env: SALT_NODE_ID=servo-linux1 + - env: + - SALT_NODE_ID=servo-linux1 + - SALT_FROM_SCRATCH=true os: linux sudo: required dist: trusty - - env: SALT_NODE_ID=servo-master1 + - env: + - SALT_NODE_ID=servo-master1 + - SALT_FROM_SCRATCH=true os: linux sudo: required dist: trusty language: python python: 3.5 - - env: SALT_NODE_ID=test # Not a Salt node, runs test suite instead + # Salt from previous configuration + - env: + - SALT_NODE_ID=servo-linux-cross1 + - SALT_FROM_SCRATCH=false + os: linux + sudo: required + dist: trusty + - env: + - SALT_NODE_ID=servo-mac1 + - SALT_FROM_SCRATCH=false + os: osx + - env: + - SALT_NODE_ID=servo-linux1 + - SALT_FROM_SCRATCH=false + os: linux + sudo: required + dist: trusty + - env: + - SALT_NODE_ID=servo-master1 + - SALT_FROM_SCRATCH=false + os: linux + sudo: required + dist: trusty + language: python + python: 3.5 + # Not a Salt node, runs test suite instead + - env: SALT_NODE_ID=test os: linux sudo: required dist: trusty diff --git a/.travis/dispatch.sh b/.travis/dispatch.sh index a3678e32..815c2c64 100755 --- a/.travis/dispatch.sh +++ b/.travis/dispatch.sh @@ -3,24 +3,53 @@ set -o errexit set -o nounset -if [ "${SALT_NODE_ID}" = "test" ]; then - # Using .travis.yml to specify Python 3.5 to be preinstalled, just to check - printf "Using $(python3 --version) at $(which python3)\n" +travis_fold_start () { + printf "travis_fold:start:$1\n" + printf "$2\n" +} - # Run test suite separately for parallelism - ./test.py -else +travis_fold_end () { + printf "travis_fold:end:$1\n" +} + +run_salt () { + travis_fold_start "salt.install.$1" 'Installing and configuring Salt' .travis/install_salt.sh -F -c .travis -- "${TRAVIS_OS_NAME}" .travis/setup_salt_roots.sh + travis_fold_end "salt.install.$1" - # For debugging, check the grains reported by the Travis builder + travis_fold_start "grains.items.$1" 'Printing Salt grains for debugging' sudo salt-call --id="${SALT_NODE_ID}" grains.items + travis_fold_end "grains.items.$1" - # Minimally validate YAML and Jinja at a basic level + travis_fold_start "state.show_highstate.$1" 'Performing basic YAML and Jinja validation' sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough state.show_highstate - # Full on installation test + travis_fold_end "state.show_highstate.$1" + + printf 'Running the full Salt highstate\n' sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough --log-level=warning state.highstate +} + + +if [ "${SALT_NODE_ID}" = "test" ]; then + # Using .travis.yml to specify Python 3.5 to be preinstalled, just to check + printf "Using $(python3 --version) at $(which python3)\n" + + # Run test suite separately for parallelism + ./test.py +else + if [ "${SALT_FROM_SCRATCH}" = "true" ]; then + run_salt 'scratch' + else + git fetch origin master:master + git checkout master + run_salt 'old' + + git checkout "${TRAVIS_COMMIT}" + run_salt 'upgrade' + fi + # Only run tests against the new configuration # TODO: don't hard-code this if [ "${SALT_NODE_ID}" = "servo-master1" ]; then ./test.py sls.buildbot.master sls.nginx diff --git a/.travis/install_salt.sh b/.travis/install_salt.sh index cfeecc75..3bd73aad 100755 --- a/.travis/install_salt.sh +++ b/.travis/install_salt.sh @@ -26,6 +26,7 @@ install_salt () { configure_salt () { printf "$0: copying Salt minion configuration from ${TEMPORARY_CONFIG_DIR}\n" + sudo rm -rf /etc/salt sudo mkdir -p /etc/salt sudo cp "${FORCE_FLAG}" -- "${TEMPORARY_CONFIG_DIR}/minion" /etc/salt/minion } diff --git a/.travis/setup_salt_roots.sh b/.travis/setup_salt_roots.sh index b7f24dc0..a58c2e03 100755 --- a/.travis/setup_salt_roots.sh +++ b/.travis/setup_salt_roots.sh @@ -4,6 +4,7 @@ set -o errexit set -o nounset setup_salt_roots () { + sudo rm -rf /srv/salt sudo mkdir -p /srv/salt sudo cp -r . /srv/salt/states sudo cp -r .travis/test_pillars /srv/salt/pillars