-
Notifications
You must be signed in to change notification settings - Fork 32
266 lines (221 loc) · 9.41 KB
/
ansible-test.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: CI
on:
push:
branches: [master]
pull_request:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 7 * * *'
env:
python_version: '3.10'
jobs:
build:
name: Build collection
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible: [v2.15.11, v2.16.6, stable-2.16, stable-2.17]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Build a collection tarball
run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs"
- name: Store migrated collection artifacts
uses: actions/upload-artifact@v4
with:
name: collection-${{ matrix.ansible }}
path: .cache/collection-tarballs
black-formating:
name: Using Black to check formating
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
experimental: [true]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Run black against code
uses: psf/black@stable
with:
options: "--check --diff --color -l 159"
importer:
name: Galaxy-importer check
needs:
- build
- black-formating
runs-on: ubuntu-latest
strategy:
matrix:
ansible: [stable-2.17]
steps:
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Download migrated collection artifacts
uses: actions/download-artifact@v4
with:
name: collection-${{ matrix.ansible }}
path: .cache/collection-tarballs
- name: Install the collection tarball
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
- name: Install galaxy-importer
run: pip install galaxy-importer
- name: Create galaxy-importer directory
run: sudo mkdir -p /etc/galaxy-importer
- name: Create galaxy-importer.cfg
run: |
sudo cp \
/home/runner/.ansible/collections/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg \
/etc/galaxy-importer/galaxy-importer.cfg
- name: Run galaxy-importer check
run: |
python -m galaxy_importer.main .cache/collection-tarballs/cisco-*.tar.gz \
| tee .cache/collection-tarballs/log.txt \
&& sudo cp ./importer_result.json .cache/collection-tarballs/importer_result.json
- name: Check warnings and errors
run: if grep -E 'WARNING|ERROR' .cache/collection-tarballs/log.txt; then exit 1; else exit 0; fi
- name: Store galaxy_importer check log file
uses: actions/upload-artifact@v4
with:
name: galaxy-importer-log
path: .cache/collection-tarballs/importer_result.json
sanity:
name: Sanity in ubuntu-latest
needs:
- importer
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible: [v2.15.11, v2.16.6, stable-2.16, stable-2.17]
steps:
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Install coverage (v4.5.4)
run: pip install coverage==4.5.4
- name: Download migrated collection artifacts
uses: actions/download-artifact@v4
with:
name: collection-${{ matrix.ansible }}
path: .cache/collection-tarballs
- name: Install the collection tarball
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
- name: Install the ND collection (NDO dependency)
run: ansible-galaxy collection install cisco.nd
- name: Run sanity tests
run: ansible-test sanity --docker -v --color --truncate 0 --coverage
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Generate coverage report
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Push coverate report to codecov.io
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F sanity
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
units:
name: Units in ubuntu-latest
if: false # No unit tests yet
needs:
- importer
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ansible: [v2.15.11, v2.16.6, stable-2.16, stable-2.17]
steps:
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Install coverage (v4.5.4)
run: pip install coverage==4.5.4
- name: Download migrated collection artifacts
uses: actions/download-artifact@v4
with:
name: collection-${{ matrix.ansible }}
path: .cache/collection-tarballs
- name: Install the collection tarball
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
- name: Run unit tests
run: ansible-test units --docker -v --color --truncate 0 --python ${{ env.python_version }} --coverage
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Generate coverage report
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Push coverate report to codecov.io
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F unit
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
integration:
name: Integration in ubuntu-latest
needs:
# - units
- sanity
runs-on: ubuntu-latest
strategy:
matrix:
ansible: [stable-2.17]
env:
MUTEX_URL: https://8v7s765ibh.execute-api.us-west-1.amazonaws.com
steps:
- name: Set up Python ${{ env.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Install coverage (v4.5.4)
run: pip install coverage==4.5.4
- name: Download migrated collection artifacts
uses: actions/download-artifact@v4
with:
name: collection-${{ matrix.ansible }}
path: .cache/collection-tarballs
- name: Install the collection tarball
run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
- name: Install the ND collection (NDO dependency)
run: ansible-galaxy collection install cisco.nd
- name: Install the ACI collection (test case dependency)
run: ansible-galaxy collection install cisco.aci
- name: Requesting integration mutex
uses: nev7n/wait_for_response@v1
with:
url: ${{ format('{0}/v1/ansible-mso?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }}
responseCode: 200
timeout: 2000000
interval: 5000
- name: Run integration tests on Python ${{ env.python_version }}
run: |
ansible-test network-integration --docker -v --color --retry-on-error --python ${{ env.python_version }} \
--truncate 0 --continue-on-error --coverage
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Releasing integration mutex
uses: nev7n/wait_for_response@v1
if: always()
with:
url: ${{ format('{0}/v1/ansible-mso/release?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }}
responseCode: 200
- name: Generate coverage report
if: always()
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
- name: Push coverate report to codecov.io
if: always()
run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F integration
working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso