diff --git a/.travis.yml b/.travis.yml index 3731eee9..1828eb4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,44 @@ -language: python -python: -- '2.7' +# Python is not supported on OS X yet +# But a system python is installed for all workers +language: cpp + +# NOTE: Make sure the matrix covers all node types in top.sls +matrix: + include: + - os: linux + env: SALT_NODE_ID=servo-master + - os: linux + env: SALT_NODE_ID=servo-linux1 + - os: osx + env: SALT_NODE_ID=servo-mac1 + - os: osx + env: SALT_NODE_ID=servo-macpro1 + - os: linux + env: SALT_NODE_ID=linux1 + - os: linux + env: SALT_NODE_ID=servo-linux-android1 + - os: linux + env: SALT_NODE_ID=servo-head before_install: - - sudo add-apt-repository -y ppa:saltstack/salt - - sudo apt-get update - - sudo apt-get install salt-master salt-minion - - sudo mkdir -p /srv/salt/states - - sudo cp .travis/minion /etc/salt/minion + - .travis/install_salt install: - # Copy the states - - sudo cp -r . /srv/salt/states + - sudo mkdir -p /etc/salt - sudo cp .travis/minion /etc/salt/minion - - sudo service salt-minion restart + - sudo mkdir -p /srv/salt/states + - sudo cp -r . /srv/salt/states - # Additional debug help. May fail if run before Salt finishes restarting. - # - sudo cat /var/log/salt/* - - # For additional debugging, see what's in grains on a travis box - - sudo salt-call grains.items --local + # For debugging, check the grains reported by the Travis builder + - sudo salt-call --id="${SALT_NODE_ID}" grains.items script: + # Use test pillars on Travis # Minimally validate YAML and Jinja at a basic level - - sudo salt-call state.show_highstate --local --retcode-passthrough + - sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough --pillar-root=.travis/test_pillars state.show_highstate # Full on installation test - - sudo salt-call state.highstate --local + - sudo salt-call --id="${SALT_NODE_ID}" --retcode-passthrough --pillar-root=.travis/test_pillars state.highstate notifications: webhooks: http://build.servo.org:54856/travis diff --git a/.travis/install_salt b/.travis/install_salt new file mode 100755 index 00000000..9f5bcda6 --- /dev/null +++ b/.travis/install_salt @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# Ensure that pinned versions match as closely as possible + +if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + printf "$0: installing salt for Linux\n" + # Travis uses Ubuntu 12.04 (Precise Pangolin) + wget -O - https://repo.saltstack.com/apt/ubuntu/ubuntu12/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add - + printf 'deb http://repo.saltstack.com/apt/ubuntu/ubuntu12/2015.5 precise main\n' | sudo tee -a /etc/apt/sources.list >/dev/null + sudo apt-get -y update + sudo apt-get -y install salt-minion=2015.5.6+ds-1 +elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + printf "$0: installing salt for Mac OS X\n" + brew update + brew install https://raw.githubusercontent.com/Homebrew/homebrew/86efec6695b019762505be440798c46d50ebd738/Library/Formula/saltstack.rb +else + printf >&2 "$0: environment variable TRAVIS_OS_NAME not set or set to unknown value\n" + exit 1 +fi diff --git a/.travis/test_pillars/buildbot/common.sls b/.travis/test_pillars/buildbot/common.sls new file mode 100644 index 00000000..6a044dc6 --- /dev/null +++ b/.travis/test_pillars/buildbot/common.sls @@ -0,0 +1,3 @@ +buildbot: + credentials: + 'slave-pass': 'TEST_BUILDBOT_SLAVE_PASS' diff --git a/.travis/test_pillars/buildbot/master.sls b/.travis/test_pillars/buildbot/master.sls new file mode 100644 index 00000000..4d88b689 --- /dev/null +++ b/.travis/test_pillars/buildbot/master.sls @@ -0,0 +1,13 @@ +buildbot: + credentials: + 'http-user': 'TEST_BUILDBOT_HTTP_USER' + 'http-pass': 'TEST_BUILDBOT_HTTP_PASS' + 'change-pass': 'TEST_BUILDBOT_CHANGE_PASS' + 'gh-doc-token': 'TEST_BUILDBOT_GH_DOC_TOKEN' + 'gh-status-token': 'TEST_BUILDBOT_GH_STATUS_TOKEN' + 'gh-hook-secret': 'TEST_BUILDBOT_GH_HOOK_SECRET' + 'homu-secret': 'TEST_BUILDBOT_HOMU_SECRET' + 'aws-access-key': 'TEST_BUILDBOT_AWS_ACCESS_KEY' + 'aws-secret-key': 'TEST_BUILDBOT_AWS_SECRET_KEY' + 'minion-public-key': 'TEST_BUILDBOT_MINION_PUBLIC_KEY' + 'minion-private-key': 'TEST_BUILDBOT_MINION_PRIVATE_KEY' diff --git a/.travis/test_pillars/buildbot/slave.sls b/.travis/test_pillars/buildbot/slave.sls new file mode 100644 index 00000000..446eb141 --- /dev/null +++ b/.travis/test_pillars/buildbot/slave.sls @@ -0,0 +1,2 @@ +buildbot: + master: 'TEST_BUILDBOT_MASTER' diff --git a/.travis/test_pillars/homu.sls b/.travis/test_pillars/homu.sls new file mode 100644 index 00000000..04aa53f5 --- /dev/null +++ b/.travis/test_pillars/homu.sls @@ -0,0 +1,9 @@ +homu: + 'gh-access-token': 'TEST_HOMU_GH_ACCESS_TOKEN' + 'gh-webhook-secret': 'TEST_HOMU_GH_WEBHOOK_SECRET' + 'app-client-id': 'TEST_HOMU_APP_CLIENT_ID' + 'app-client-secret': 'TEST_HOMU_APP_CLIENT_SECRET' + 'buildbot-secret': 'TEST_HOMU_BUILDBOT_SECRET' + 'buildbot-http-user': 'TEST_HOMU_BUILDBOT_HTTP_USER' + 'buildbot-http-pass': 'TEST_HOMU_BUILDBOT_HTTP_PASS' + 'travis-ci-token': 'TEST_HOMU_TRAVIS_CI_TOKEN' diff --git a/.travis/test_pillars/top.sls b/.travis/test_pillars/top.sls new file mode 100644 index 00000000..eb0299d8 --- /dev/null +++ b/.travis/test_pillars/top.sls @@ -0,0 +1,23 @@ +base: + '*': + - travis + - buildbot.common + + 'servo-master': + - buildbot.master + - homu + + 'servo-(linux|mac|macpro)\d+': + - match: pcre + - buildbot.slave + + 'linux\d+': + - match: pcre + - buildbot.slave + + 'servo-linux-android\d+': + - match: pcre + - buildbot.slave + + 'servo-head': + - buildbot.slave diff --git a/.travis/test_pillars/travis.sls b/.travis/test_pillars/travis.sls new file mode 100644 index 00000000..baff72f9 --- /dev/null +++ b/.travis/test_pillars/travis.sls @@ -0,0 +1 @@ +travis: True diff --git a/README.md b/README.md index e606d283..2cd7ae5c 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,9 @@ started. There are guides for some tasks available on [the wiki](https://github.com/servo/saltfs/wiki). If you see a way that these -configurations could be improved, or try to set up your own intsance and run +configurations could be improved, or try to set up your own instance and run into trouble, file [an issue](https://github.com/servo/saltfs/issues/new)! ## Travis -TravisCI is set up to test these configurations as described -[here](https://lambdaops.com/automation/travis/travis%20ci/configuration%20management/continuous%20integration/salt/chef/saltstack/salt%20stack/2014/01/29/travis-for-salt-states/). +TravisCI is set up to test all configurations. diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md new file mode 100644 index 00000000..b1009d2d --- /dev/null +++ b/STYLE_GUIDE.md @@ -0,0 +1,34 @@ +# Style Guide + +Style guide for Salt states (and other code) in this repo. Unfortunately, +no linter exists yet for Salt states, so there is no automated way to +check for compliance with this guide. + +## Package Installation + +### Use pkgs instead of name + +pkg.installed, pip.installed, and any other states which install packages +should use the ```pkgs``` option instead of the ```name``` option to specify +which package(s) to install, even if there is only one package. This prevents +problems when adding another package, as in #132 (fixed in #97). Adding another +name option will cause the earlier option to be silently swallowed, which can +be hard to debug. Using pkgs from the beginning ensures correct behavior +regardless of the number of packages. + +*Unsafe*: + +```salt +buildbot-dependencies: + pip.installed: + - name: buildbot == 0.8.12 +``` + +*Better*: + +```salt +buildbot-dependencies: + pip.installed: + - pkgs: + - buildbot == 0.8.12 +``` diff --git a/android-dependencies.sls b/android-dependencies.sls index ab907e4f..bf7035d6 100644 --- a/android-dependencies.sls +++ b/android-dependencies.sls @@ -1,3 +1,6 @@ +# Android is flaky on Travis +{% if not salt['pillar.get']('travis', False) %} + android-dependencies: pkg.installed: - pkgs: @@ -17,7 +20,7 @@ android-dependencies: - libstdc++6 - libgl1-mesa-dev pip.installed: - - s3cmd + - name: s3cmd android-sdk-download: file.managed: @@ -66,7 +69,8 @@ android-ndk-download: android-ndk-install: cmd.wait: - - name: /home/servo/android-ndk-r10c-linux-x86_64.bin + # Need to filter log output to avoid hitting log limits on Travis CI + - name: /home/servo/android-ndk-r10c-linux-x86_64.bin | grep -v Extracting - user: servo - watch: - file: android-ndk-download @@ -84,3 +88,5 @@ android-ndk-toolset-configuration: - user: servo - group: servo - mode: 0644 + +{% endif %} diff --git a/buildbot/master.sls b/buildbot/master.sls index d4fc1c5c..481bc37c 100644 --- a/buildbot/master.sls +++ b/buildbot/master.sls @@ -1,7 +1,8 @@ buildbot: pip.installed: - - name: buildbot == 0.8.12 - - name: service_identity == 14.0.0 + - pkgs: + - buildbot == 0.8.12 + - service_identity == 14.0.0 txgithub: pip.installed @@ -12,6 +13,8 @@ boto: buildbot-master: service.running: - enable: True + - require: + - pip: buildbot /home/servo/buildbot/master: file.recurse: diff --git a/buildbot/slave.sls b/buildbot/slave.sls index 05b52220..83a6e9f2 100644 --- a/buildbot/slave.sls +++ b/buildbot/slave.sls @@ -2,7 +2,8 @@ buildbot-slave.pip: pip.installed: - - name: buildbot-slave == 0.8.12 + - pkgs: + - buildbot-slave == 0.8.12 {{ common.servo_home }}/buildbot/slave: file.recurse: diff --git a/common/init.sls b/common/init.sls index 1447ca14..7aa3d317 100644 --- a/common/init.sls +++ b/common/init.sls @@ -24,6 +24,6 @@ host-{{ hostname }}: {% for ssh_user in config.ssh_users %} sshkey-{{ ssh_user }}: ssh_auth.present: - - user: {{ config.root_user }} + - user: root - source: salt://{{ tpldir }}/ssh/{{ ssh_user }}.pub {% endfor %} diff --git a/common/map.jinja b/common/map.jinja index 6413f834..025e472a 100644 --- a/common/map.jinja +++ b/common/map.jinja @@ -2,7 +2,6 @@ set config = salt['grains.filter_by']({ 'defaults': { 'servo_home': '/home/servo', - 'root_user': 'root', 'hosts': { 'servo-master': '96.126.125.232', 'servo-linux1': '66.228.48.56', @@ -28,8 +27,7 @@ ] }, 'Darwin': { - 'servo_home': '/Users/servo', - 'root_user': 'administrator' + 'servo_home': '/Users/servo' } }, base='defaults', diff --git a/servo-dependencies.sls b/servo-dependencies.sls index dd5e6344..f296edd3 100644 --- a/servo-dependencies.sls +++ b/servo-dependencies.sls @@ -18,6 +18,19 @@ ttf-mscorefonts-installer: - debconf: ttf-mscorefonts-installer {% endif %} +{% if grains['kernel'] == 'Darwin' %} +# Workaround for https://github.com/saltstack/salt/issues/26414 +servo-darwin-homebrew-versions-dependencies: + module.run: + - name: pkg.install + - pkgs: + - autoconf213 + - taps: + - homebrew/versions + - require_in: + - pkg: servo-dependencies +{% endif %} + servo-dependencies: pkg.installed: - pkgs: @@ -25,7 +38,6 @@ servo-dependencies: - git {% if grains['kernel'] == 'Darwin' %} - pkg-config - - homebrew/versions/autoconf213 {% else %} - libglib2.0-dev - libgl1-mesa-dri diff --git a/top.sls b/top.sls index 8c135be3..c173fdc9 100644 --- a/top.sls +++ b/top.sls @@ -1,3 +1,5 @@ +# NOTE: Ensure all node types are covered in .travis.yml + base: '*': - common @@ -28,6 +30,5 @@ base: - gonk-dependencies 'servo-head': - - match: pcre - buildbot.slave - android-dependencies