@@ -27,15 +27,16 @@ jobs:
27
27
- docker-compose pull
28
28
- docker-compose up -d
29
29
- cd ..
30
- - pip install -U pip
30
+ # setuptools <46.1.3 has issues with ansible-test executables https://github.com/ansible/ansible/issues/68963
31
+ - pip install -U pip "setuptools>=46.1.3"
31
32
# coverage 5.0 is not compatible with ansible-test https://github.com/ansible/ansible/issues/65907
32
33
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
33
- - pip install pynetbox cryptography codecov jmespath ansible
34
+ - pip install pynetbox cryptography codecov jmespath jsondiff pycodestyle ansible
34
35
35
- # Latest release of Netbox and Ansible
36
36
- name : " Python 3.6 - Netbox 2.7 - Latest PyPi Ansible"
37
37
python : 3.6
38
- env : PYTHON_VER=3.6 VERSION=v2.7
38
+ env :
39
+ - PYTHON_VER=3.6 VERSION=v2.7
39
40
install :
40
41
- cd ..
41
42
# Setup netbox container for integration testing
@@ -44,16 +45,32 @@ jobs:
44
45
- docker-compose pull
45
46
- docker-compose up -d
46
47
- cd ..
47
- - pip install -U pip
48
+ - pip install -U pip "setuptools>=46.1.3"
48
49
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
49
- - pip install pynetbox cryptography codecov jmespath ansible
50
+ - pip install pynetbox cryptography codecov jmespath jsondiff pycodestyle ansible
51
+
52
+ - name : " Python 3.8 - Netbox 2.8 - Latest PyPi Ansible"
53
+ python : 3.8
54
+ env :
55
+ - PYTHON_VER=3.8 VERSION=v2.8
56
+ install :
57
+ - cd ..
58
+ # Setup netbox container for integration testing
59
+ - git clone https://github.com/netbox-community/netbox-docker.git
60
+ - cd netbox-docker
61
+ - docker-compose pull
62
+ - docker-compose up -d
63
+ - cd ..
64
+ - pip install -U pip "setuptools>=46.1.3"
65
+ - pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
66
+ - pip install pynetbox cryptography codecov jmespath jsondiff pycodestyle ansible
50
67
51
68
# Latest development versions of Netbox and Ansible, newest Python
52
69
# This may be broken sometimes by changes in the netbox & ansible projects
53
70
# Failures will be allowed in this build
54
- - name : " Python 3.8 - Netbox develop-2.8 - Ansible Devel"
71
+ - name : " Python 3.8 - Netbox develop branch (snapshot) - Ansible Devel"
55
72
python : 3.8
56
- env : PYTHON_VER=3.8 VERSION=develop-2.8
73
+ env : PYTHON_VER=3.8 VERSION=snapshot
57
74
install :
58
75
- cd ..
59
76
# Setup netbox container for integration testing
@@ -62,16 +79,16 @@ jobs:
62
79
- docker-compose pull
63
80
- docker-compose up -d
64
81
- cd ..
65
- - pip install -U pip
82
+ - pip install -U pip "setuptools>=46.1.3"
66
83
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0 "coverage<5"
67
- - pip install pynetbox cryptography jmespath
84
+ - pip install pynetbox cryptography jmespath jsondiff pycodestyle
68
85
- git clone https://github.com/ansible/ansible.git
69
86
- cd ansible
70
87
- source hacking/env-setup
71
88
- cd ..
72
89
allow_failures :
73
90
# When testing against dev netbox and dev ansible, allow failures
74
- - env : PYTHON_VER=3.8 VERSION=develop-2.8
91
+ - env : PYTHON_VER=3.8 VERSION=snapshot
75
92
76
93
before_script :
77
94
- mkdir -p ~/ansible_collections/$COLLECTION_NAMESPACE
@@ -80,28 +97,44 @@ before_script:
80
97
- ansible-galaxy collection build .
81
98
- ansible-galaxy collection install $COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz -p /home/travis/.ansible/collections
82
99
100
+ # Run all further tests from within the installed directory
101
+ # Required to resolve imports of other collections
102
+ - cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
103
+
104
+ # Set runme.sh execute permissions stripped by ansible-galaxy. Should be fixed in Ansible 2.10
105
+ # https://github.com/ansible/ansible/issues/68415
106
+ - chmod +x tests/integration/targets/inventory/runme.sh
107
+ - chmod +x tests/integration/targets/inventory/compare_inventory_json.py
108
+
83
109
script :
84
- # Perform unit tests on collection from within the installed directory, not the source directory
85
- # Required for imports of other collections (ie. ansible.netcommon) to work correctly
86
- - (cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME && ansible-test units --coverage --python $PYTHON_VER -v)
87
110
88
111
# Check python syntax
89
112
- black . --check --diff
90
113
114
+ # Sanity tests
115
+ - ansible-test sanity -v --python $PYTHON_VER
116
+
117
+ # Unit tests, with code coverage
118
+ - ansible-test units -vvvv --coverage --python $PYTHON_VER
119
+
91
120
# Wait for Netbox containers to be running
92
121
- 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
93
122
94
123
# Prepare data in Netbox
95
124
- python tests/integration/netbox-deploy.py
96
125
97
126
# Run regression and integration tests
127
+
128
+ # Run the inventory test first, in case any of the other tests modify the data.
129
+ # -vvvv is too much for integration tests
130
+ # Only run on Netbox > 2.6 - test data is different with API 2.6, haven't yet worked out a difference
131
+ - if [ "$VERSION" != "v2.6" ] ; then ansible-test integration -vv --coverage --python $PYTHON_VER inventory; fi
132
+
98
133
- ansible-playbook tests/integration/regression-tests.yml -vvvv
99
134
- ansible-playbook tests/integration/$VERSION/main.yml -vvvv
100
- - ansible-inventory -vvvv -i tests/integration/test-inventory.yml --list
101
- - ansible-inventory -vvvv -i tests/integration/test-inventory-plurals.yml --list
102
135
103
136
# Report code coverage
104
- - (cd /home/travis/. ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME && ansible -test coverage report)
137
+ - ansible-test coverage report
105
138
106
139
deploy :
107
140
provider : script
0 commit comments