mac-dev-playbook/.travis.yml

76 lines
2.3 KiB
YAML

---
sudo: required
language: objective-c
env:
global:
- ANSIBLE_FORCE_COLOR=true
# Reference for OS X Versions:
# https://docs.travis-ci.com/user/reference/osx/#macos-version
matrix:
include:
# Catalina (10.15)
- os: osx
osx_image: xcode11.4
# Mojave (10.14)
- os: osx
osx_image: xcode11.3
before_install:
# Install role dependencies. Do this here, using newer OpenSSL version and a
# virtualenv because older macOS versions will fail with the system version of
# OpenSSL and Python if done later.
- brew upgrade openssl || brew install openssl || true
- brew upgrade python3 || brew install python3 || true
- sudo -H pip3 install -U virtualenv
- virtualenv --python=/usr/local/bin/python3 .venv
- source .venv/bin/activate
- pip3 install ansible
- python -c "import ssl; print(ssl.OPENSSL_VERSION)"
- ansible-galaxy install -r requirements.yml -p ./roles
- deactivate
# Uninstall existing Homebrew installation.
- curl -sLO https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh
- chmod +x ./uninstall.sh
- ./uninstall.sh --force
- sudo rm -rf /usr/local/Homebrew
- sudo rm -rf /usr/local/Caskroom
- sudo rm -rf /usr/local/bin/brew
# Install Python 3.
- curl "https://www.python.org/ftp/python/3.7.9/python-3.7.9-macosx10.9.pkg" -o "python3.pkg"
- sudo installer -pkg python3.pkg -target /
- export PATH=/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH
# Install pip3.
- curl https://bootstrap.pypa.io/get-pip.py | sudo python3
install:
# Install Ansible.
- sudo -H pip3 install ansible
# Add a hosts file.
- sudo mkdir -p /etc/ansible
- sudo touch /etc/ansible/hosts
- "echo -e '[local]\nlocalhost ansible_connection=local' | sudo tee -a /etc/ansible/hosts > /dev/null"
script:
# Check the role/playbook's syntax.
- "ansible-playbook main.yml --syntax-check"
# Copy test config.yml into place.
- "cp tests/config.yml config.yml"
# Test the playbook.
- "travis_wait 30 ansible-playbook main.yml"
# Test the playbook's idempotence.
- idempotence=$(mktemp)
- "ansible-playbook main.yml | tee -a ${idempotence}"
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)