forked from netbox-community/ansible_modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
139 lines (120 loc) · 6.29 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
---
language: python
services:
- docker
os: linux
dist: bionic
env:
global:
- COLLECTION_NAMESPACE: "netbox"
- COLLECTION_NAME: "netbox"
- COLLECTION_VERSION: "1.1.0"
- secure: "tE6GtwrRU+Kjobx/94xqR2MqM20pHCnrLcHgPzIHA3npdwuA+GjCBiBLTkEEQM4fUWIfzUTyjSr9bZErm1PTI1GcIRdniTgJ3ZzSSkE7tgeYALB/7xsusB57SlmbBQm2SGwU558uWZ3NHEsi0WTgD8GKZo77OpGX72FZKsVXOz6k2wve51sOtoSVjgCsvWTmZHx4ynGdiA5wFkZfaEcjXECahKtunW+MlB5kpJzkVeLRUEXFMhWlsIYiA5nj8OI/X3Nk9ugh1ribENX9LrjpgrqQ9YariZ8G6py1ONuKZIn2g7xs5kNQ3qL6HL6N7SoUxiwH16CfSyugFaYiMfaxQ4NUVGGRHS4vSGbNIf+gLHcYvP40miI1f/+pntCzqygZMhW73FX2o+KH2OGv09khOl8k1nDg2/XvW0kCc/FU6l+Jp5wCC8H9X2uiULtQpRqts5TzIonlPEzGIpfGFgJ5m54Emhv9gjG1Z5OOyL/qae1Wr+L/uhiFafcglZYh8NHEMWCUCkeqFqR2kDmUMtdgYLD7Q7NdwlL/PSVVs1l7UPiQHlnecQKEHN7CvR3eKByTEmkCKafRYh/JQ9rBt9sZc7aAPVu+w3wWUwbHS4o4vVnmyXvJb1PeJSiuynF7CBo4Qd6qj4YwX8gLK6PylGyaMOp169u6xw1mo5/CX0pJ3x4="
jobs:
include:
- name: "Python 3.6 - Netbox 2.8 - Latest PyPi Ansible"
python: 3.6
env:
- PYTHON_VER=3.6 VERSION=v2.8 INTEGRATION_TESTS=v2.8
install:
- cd ..
# Setup netbox container for integration testing
- git clone https://github.com/netbox-community/netbox-docker.git
- cd netbox-docker
- sed -i 's/SKIP_STARTUP_SCRIPTS=false/SKIP_STARTUP_SCRIPTS=true/' env/netbox.env
- docker-compose pull
- docker-compose up -d
- cd ..
- pip install -U pip
- pip install -U pytest
- pip install -U pip "setuptools>=46.1.3"
- pip install pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
- pip install pynetbox cryptography codecov jmespath jsondiff ansible
# Stick to python 3.7 instead of 3.8, as ansible-test sanity is not compatible with 3.7
# https://github.com/ansible/ansible/issues/67118
- name: "Python 3.7 - Netbox 2.9 - Latest PyPi Ansible"
python: 3.7
env:
- PYTHON_VER=3.7 VERSION=v2.9 INTEGRATION_TESTS=latest
install:
- cd ..
# Setup netbox container for integration testing
- git clone https://github.com/netbox-community/netbox-docker.git
- cd netbox-docker
- docker-compose pull
- docker-compose up -d
- cd ..
- pip install -U pip
- pip install -U pytest
- pip install -U pip "setuptools>=46.1.3"
- pip install pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
- pip install pynetbox cryptography codecov jmespath jsondiff ansible
# Latest development versions of Netbox and Ansible, newest Python
# This may be broken sometimes by changes in the netbox & ansible projects
# Failures will be allowed in this build
- name: "Python 3.6 - Netbox develop branch (snapshot) - Ansible Develop"
python: 3.6
env: PYTHON_VER=3.6 VERSION=snapshot INTEGRATION_TESTS=latest
install:
- cd ..
# Setup netbox container for integration testing
- git clone https://github.com/netbox-community/netbox-docker.git
- cd netbox-docker
- docker-compose pull
- docker-compose up -d
- cd ..
- pip install -U pip
- pip install -U pytest
- pip install -U pip "setuptools>=46.1.3"
- pip install pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
- pip install pynetbox cryptography jmespath jsondiff
- git clone https://github.com/ansible/ansible.git
- cd ansible
- source hacking/env-setup
- cd ..
allow_failures:
# When testing against dev netbox and dev ansible, allow failures
- env: PYTHON_VER=3.6 VERSION=snapshot INTEGRATION_TESTS=latest
before_script:
- mkdir -p ~/ansible_collections/$COLLECTION_NAMESPACE
- cp -R ansible_modules ~/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- cd ~/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- ansible-galaxy collection build .
- ansible-galaxy collection install $COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz -p /home/travis/.ansible/collections
# Run all further tests from within the installed directory
# Required to resolve imports of other collections
- cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
# Set runme.sh execute permissions stripped by ansible-galaxy. Should be fixed in Ansible 2.10
# https://github.com/ansible/ansible/issues/68415
- chmod +x tests/integration/targets/inventory-$INTEGRATION_TESTS/runme.sh
- chmod +x tests/integration/targets/inventory-$INTEGRATION_TESTS/compare_inventory_json.py
- chmod +x tests/integration/render_config.sh
# Run render_config.sh to pass environment variables to integration tests
# https://www.ansible.com/blog/adding-integration-tests-to-ansible-content-collections
- tests/integration/render_config.sh tests/integration/targets/inventory/runme_config.template > tests/integration/targets/inventory-$INTEGRATION_TESTS/runme_config
script:
# Check python syntax
- black . --check --diff
# Sanity tests
# --requirements - install pip packages as necessary
# Skip pep8 as we use black instead
- ansible-test sanity -v --requirements --python $PYTHON_VER --skip-test pep8 plugins/
# Unit tests, with code coverage
- ansible-test units -v --coverage --python $PYTHON_VER
# Wait for Netbox containers to be running
- timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32768)" != "200" ]]; do echo "waiting for Netbox"; sleep 5; done' || false
# Prepare data in Netbox
- ./tests/integration/netbox-deploy.py
# Run regression and integration tests
# Run the inventory test first, in case any of the other tests modify the data.
- ansible-test integration -v --coverage --python $PYTHON_VER inventory-$INTEGRATION_TESTS
- ansible-test integration -v --coverage --python $PYTHON_VER regression-$INTEGRATION_TESTS
- ansible-test integration -v --coverage --python $PYTHON_VER $INTEGRATION_TESTS
# Report code coverage
- ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
deploy:
provider: script
skip_cleanup: true
script: ansible-galaxy collection publish ~/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME/$COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz --api-key="$GALAXY_API_TOKEN"
on:
tags: true