-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
107 lines (85 loc) · 2.94 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
language: python
python: "3.6"
# Use the new container infrastructure
sudo: false
# Install ansible
addons:
apt:
packages:
- python-pip
- curl
cache:
directories:
- $HOME/.rvm/
- $HOME/.bundler/
- $HOME/.cache/pip/
pip: true
matrix:
include:
- env:
- TARGET_SCENARIO=travisci_ubuntu1804
- env:
- TARGET_SCENARIO=travisci_centos7
before_install:
# XXX update RubyGem to fix build in Travis CI. when ruby 2.6.3 or later is
# available in travis environment, this can be removed.
# see details at:
# https://bundler.io/blog/2019/05/14/solutions-for-cant-find-gem-bundler-with-executable-bundle.html
- yes | gem update --system --force
- gem install bundler
install:
# Install ansible
- pip install ansible yamllint molecule docker
# Check versions
- ansible --version
- molecule --version
# Create ansible.cfg with correct roles_path
- mkdir -p extra_roles
- printf '[defaults]\nroles_path=../:extra_roles' >ansible.cfg
script:
# See if the repo is private
- if curl --silent --output /dev/null --dump-header - "https://github.com/${TRAVIS_REPO_SLUG}" | grep "Status:[[:space:]]*404"; then touch .private_repo; fi
# Download depended roles
- if [ -f requirements.yml ]; then ansible-galaxy install -r requirements.yml -p extra_roles; fi
# Basic role syntax check
#
# If it is a private repo, it _usually_ has secret information, or encrypted
# file. As the information security policy does not allow decryption key to
# be transfered to third-party, encrypted files cannot be decrypted in travis
# CI environment. Skip syntax check when it is a private repo.
#
- "if [ ! -f .private_repo ]; then ansible-playbook tests/travisci/tests.yml -i tests/travisci/inventory --syntax-check; fi"
# download the QA scripts
- git clone https://github.com/trombik/qansible.git
# checkout the latest release
- ( cd qansible && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) )
# install it
- ( cd qansible && bundle install --path ${HOME}/.bundler --with "test" && bundle exec rake build && gem install pkg/*.gem )
- rm -rf qansible
# git complains if user and email are not set
- git config --global user.name "Your Name"
- git config --global user.email "you@example.com"
# surpress a warning from `qansible qa
- touch .kitchen.local.yml
# export PATH
- export PATH="${PATH}:`rvm gemdir`/bin"
# bundle up because rubocop is installed via Gemfile
- bundle install --path ${HOME}/.bundler
# run rubocop
- bundle exec rubocop
# run yamllint
- yamllint -c .yamllint.yml .
# run the QA test
- qansible qa
# run molecule
- echo TARGET_SCENARIO=${TARGET_SCENARIO}
- |
if [ -d "tests/molecule/molecule/${TARGET_SCENARIO}" ]; then
cd tests/molecule
if molecule list; then
molecule test -s "${TARGET_SCENARIO}"
fi
fi
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/