From 6fbc0f9fafb004ff331044abf95f629d49d943c4 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 7 Jun 2016 21:51:01 -0400 Subject: [PATCH 1/3] Fix Vagrantfile to handle multiple env variables. Environment variables are now passed as a list, instead of a string. --- .travis.yml | 3 ++- Vagrantfile | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf56c951..b2510867 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,8 @@ matrix: language: python python: 3.5 # Not a Salt node, runs test suite instead - - env: SALT_NODE_ID=test + - env: + - SALT_NODE_ID=test os: linux sudo: required dist: trusty diff --git a/Vagrantfile b/Vagrantfile index 923f14da..260a8d85 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,7 @@ require 'yaml' def extract_id(env) - id = env.split.map do |env_var| + id = env.map do |env_var| env_var[/^SALT_NODE_ID=(?.+)$/, "node_id"] end.compact id[0] @@ -37,7 +37,7 @@ Vagrant.configure(2) do |config| elsif node_config[:id] != 'test' node_config end - end.compact.each do |node| + end.compact.uniq.each do |node| config.vm.define node[:id] do |machine| machine.vm.box = node[:box] machine.vm.provider :virtualbox do |vbox| From f06c6b57b685db309308a4d1f0e49db6b28b0877 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 3 May 2016 20:40:58 -0400 Subject: [PATCH 2/3] Switch from sh to bash to match Servo style guide Originally, I restricted these scripts to pure sh to avoid too many compatibility issues between Linux and OS X, but I've changed my mind and now prefer using bash to gain a few nice features. --- .travis/dispatch.sh | 7 ++++--- .travis/install_salt.sh | 13 +++++++------ .travis/setup_salt_roots.sh | 3 ++- tests/lint/shebang.py | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.travis/dispatch.sh b/.travis/dispatch.sh index 1b28d0a5..7a6111a5 100755 --- a/.travis/dispatch.sh +++ b/.travis/dispatch.sh @@ -1,7 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail travis_fold_start () { printf "travis_fold:start:$1\n" @@ -31,7 +32,7 @@ run_salt () { } -if [ "${SALT_NODE_ID}" = "test" ]; then +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" @@ -51,7 +52,7 @@ else # Only run tests against the new configuration # TODO: don't hard-code this - if [ "${SALT_NODE_ID}" = "servo-master1" ]; then + if [[ "${SALT_NODE_ID}" == "servo-master1" ]]; then ./test.py sls.buildbot.master sls.homu sls.nginx fi fi diff --git a/.travis/install_salt.sh b/.travis/install_salt.sh index 3bd73aad..870e85a5 100755 --- a/.travis/install_salt.sh +++ b/.travis/install_salt.sh @@ -1,11 +1,12 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail install_salt () { # Ensure that pinned versions match as closely as possible - if [ "${OS_NAME}" = "linux" ]; then + if [[ "${OS_NAME}" == "linux" ]]; then printf "$0: installing salt for Linux\n" # Use Trusty (Ubuntu 14.04) on Travis # Don't autostart services @@ -14,7 +15,7 @@ install_salt () { printf 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/archive/2015.5.8 trusty main\n' | sudo tee /etc/apt/sources.list.d/saltstack.list >/dev/null sudo apt-get -y update sudo apt-get -y install salt-minion=2015.5.8+ds-1 - elif [ "${OS_NAME}" = "osx" ]; then + elif [[ "${OS_NAME}" == "osx" ]]; then printf "$0: installing salt for Mac OS X\n" brew update brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/3461c9c74b2f3aba9a6fbd7165823c81dc2b4792/Formula/saltstack.rb @@ -63,16 +64,16 @@ while true; do esac done -if [ "$#" -lt 1 ]; then +if [[ "$#" -lt 1 ]]; then printf >&2 "usage: $0 [-c [-F]] [--] os_name\n" exit 1 fi OS_NAME="$1" -if [ -z "${CONFIGURE_ONLY}" ]; then +if [[ -z "${CONFIGURE_ONLY}" ]]; then install_salt fi -if [ -n "${TEMPORARY_CONFIG_DIR}" ]; then +if [[ -n "${TEMPORARY_CONFIG_DIR}" ]]; then configure_salt fi diff --git a/.travis/setup_salt_roots.sh b/.travis/setup_salt_roots.sh index a58c2e03..dac0082b 100755 --- a/.travis/setup_salt_roots.sh +++ b/.travis/setup_salt_roots.sh @@ -1,7 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail setup_salt_roots () { sudo rm -rf /srv/salt diff --git a/tests/lint/shebang.py b/tests/lint/shebang.py index 6746eaa0..de03b937 100644 --- a/tests/lint/shebang.py +++ b/tests/lint/shebang.py @@ -11,7 +11,7 @@ INTERPRETERS = { 'py': 'python3', - 'sh': 'sh' + 'sh': 'bash' } From 1a1eeb24dd7c2563279ae3ca2983f40d716b384f Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Sun, 26 Jun 2016 00:00:36 -0400 Subject: [PATCH 3/3] Handle paths more portably in Vagrantfile --- Vagrantfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 260a8d85..007f5e28 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -16,11 +16,12 @@ Vagrant.configure(2) do |config| end dir = File.dirname(__FILE__) - minion_config = YAML.load_file(File.join(dir, '.travis/minion')) + minion_config_path = File.join(dir, '.travis', 'minion') + minion_config = YAML.load_file(minion_config_path) state_root = minion_config['file_roots']['base'][0] pillar_root = minion_config['pillar_roots']['base'][0] - YAML.load_file(File.join(dir,'.travis.yml'))['matrix']['include'].map do |node| + YAML.load_file(File.join(dir, '.travis.yml'))['matrix']['include'].map do |node| node_config = case node['os'] when 'linux' case node['dist'] @@ -46,12 +47,12 @@ Vagrant.configure(2) do |config| vbox.linked_clone = true end machine.vm.synced_folder dir, state_root - machine.vm.synced_folder File.join(dir, ".travis/test_pillars"), pillar_root + machine.vm.synced_folder File.join(dir, '.travis', 'test_pillars'), pillar_root machine.vm.provision :salt do |salt| - salt.bootstrap_script = '.travis/install_salt.sh' + salt.bootstrap_script = File.join(dir, '.travis', 'install_salt.sh') salt.install_args = node[:os] # Pass OS type to bootstrap script salt.masterless = true - salt.minion_config = '.travis/minion' + salt.minion_config = minion_config_path # hack to provide additional options to salt-call salt.minion_id = node[:id] + ' --retcode-passthrough' salt.run_highstate = true