Debian Codegraph @

ansible_collections/cisco/mso/.github/workflows/ansible-test.yml

raw
1 name: CI
2 on:
3 push:
4 branches: [master]
5 pull_request:
6 schedule:
7 # * is a special character in YAML so you have to quote this string
8 - cron: '0 7 * * *'
9 env:
10 python_version: '3.11'
11 jobs:
12 build:
13 name: Build collection
14 runs-on: ubuntu-latest
15 strategy:
16 fail-fast: false
17 matrix:
18 ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19]
19 steps:
20 - name: Check out code
21 uses: actions/checkout@v4
22
23 - name: Set up Python ${{ env.python_version }}
24 uses: actions/setup-python@v5
25 with:
26 python-version: ${{ env.python_version }}
27
28 - name: Install ansible-base (${{ matrix.ansible }})
29 run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
30
31 - name: Build a collection tarball
32 run: ansible-galaxy collection build --output-path "${GITHUB_WORKSPACE}/.cache/collection-tarballs"
33
34 - name: Store migrated collection artifacts
35 uses: actions/upload-artifact@v4
36 with:
37 name: collection-${{ matrix.ansible }}
38 path: .cache/collection-tarballs
39
40 black-formating:
41 name: Using Black to check formating
42 runs-on: ubuntu-latest
43 continue-on-error: true
44 steps:
45 - name: Check out code
46 uses: actions/checkout@v4
47
48 - name: Run black against code
49 uses: psf/black@stable
50 with:
51 options: "--check --diff --color -l 159"
52
53 importer:
54 name: Galaxy-importer check
55 needs:
56 - build
57 - black-formating
58 runs-on: ubuntu-latest
59 strategy:
60 matrix:
61 ansible: [stable-2.18]
62 steps:
63 - name: Set up Python ${{ env.python_version }}
64 uses: actions/setup-python@v5
65 with:
66 python-version: ${{ env.python_version }}
67
68 - name: Install ansible-base (${{ matrix.ansible }})
69 run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
70
71 - name: Download migrated collection artifacts
72 uses: actions/download-artifact@v4
73 with:
74 name: collection-${{ matrix.ansible }}
75 path: .cache/collection-tarballs
76
77 - name: Install the collection tarball
78 run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
79
80 - name: Install galaxy-importer
81 run: pip install galaxy-importer
82
83 - name: Create galaxy-importer directory
84 run: sudo mkdir -p /etc/galaxy-importer
85
86 - name: Create galaxy-importer.cfg
87 run: |
88 sudo cp \
89 /home/runner/.ansible/collections/ansible_collections/cisco/mso/.github/workflows/galaxy-importer.cfg \
90 /etc/galaxy-importer/galaxy-importer.cfg
91
92 - name: Run galaxy-importer check
93 run: |
94 python -m galaxy_importer.main .cache/collection-tarballs/cisco-*.tar.gz \
95 | tee .cache/collection-tarballs/log.txt \
96 && sudo cp ./importer_result.json .cache/collection-tarballs/importer_result.json
97
98 - name: Check warnings and errors
99 run: if grep -E 'WARNING|ERROR' .cache/collection-tarballs/log.txt; then exit 1; else exit 0; fi
100
101 - name: Store galaxy_importer check log file
102 uses: actions/upload-artifact@v4
103 with:
104 name: galaxy-importer-log
105 path: .cache/collection-tarballs/importer_result.json
106
107 sanity:
108 name: Sanity in ubuntu-latest
109 needs:
110 - importer
111 runs-on: ubuntu-latest
112 strategy:
113 fail-fast: false
114 matrix:
115 ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19]
116 steps:
117 - name: Set up Python ${{ env.python_version }}
118 uses: actions/setup-python@v5
119 with:
120 python-version: ${{ env.python_version }}
121
122 - name: Install ansible-base (${{ matrix.ansible }})
123 run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
124
125 - name: Install coverage (v4.5.4)
126 run: pip install coverage==4.5.4
127
128 - name: Download migrated collection artifacts
129 uses: actions/download-artifact@v4
130 with:
131 name: collection-${{ matrix.ansible }}
132 path: .cache/collection-tarballs
133
134 - name: Install the collection tarball
135 run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
136
137 - name: Install the ND collection (NDO dependency)
138 run: ansible-galaxy collection install cisco.nd
139
140 - name: Run sanity tests
141 run: ansible-test sanity --docker -v --color --truncate 0 --coverage
142 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
143
144 - name: Generate coverage report
145 run: ansible-test coverage xml -v --requirements --group-by command --group-by version
146 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
147
148 - name: Push coverate report to codecov.io
149 run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F sanity
150 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
151
152 units:
153 name: Units in ubuntu-latest
154 if: false # No unit tests yet
155 needs:
156 - importer
157 runs-on: ubuntu-latest
158 strategy:
159 fail-fast: false
160 matrix:
161 ansible: [stable-2.16, stable-2.17, stable-2.18, stable-2.19]
162 steps:
163 - name: Set up Python ${{ env.python_version }}
164 uses: actions/setup-python@v5
165 with:
166 python-version: ${{ env.python_version }}
167
168 - name: Install ansible-base (${{ matrix.ansible }})
169 run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
170
171 - name: Install coverage (v4.5.4)
172 run: pip install coverage==4.5.4
173
174 - name: Download migrated collection artifacts
175 uses: actions/download-artifact@v4
176 with:
177 name: collection-${{ matrix.ansible }}
178 path: .cache/collection-tarballs
179
180 - name: Install the collection tarball
181 run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
182
183 - name: Run unit tests
184 run: ansible-test units --docker -v --color --truncate 0 --python ${{ env.python_version }} --coverage
185 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
186
187 - name: Generate coverage report
188 run: ansible-test coverage xml -v --requirements --group-by command --group-by version
189 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
190
191 - name: Push coverate report to codecov.io
192 run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F unit
193 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
194
195 integration:
196 name: Integration in ubuntu-latest
197 needs:
198 # - units
199 - sanity
200 runs-on: ubuntu-latest
201 strategy:
202 matrix:
203 ansible: [stable-2.19]
204 env:
205 MUTEX_URL: https://8v7s765ibh.execute-api.us-west-1.amazonaws.com
206 steps:
207 - name: Set up Python ${{ env.python_version }}
208 uses: actions/setup-python@v5
209 with:
210 python-version: ${{ env.python_version }}
211
212 - name: Install ansible-base (${{ matrix.ansible }})
213 run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
214
215 - name: Install coverage (v4.5.4)
216 run: pip install coverage==4.5.4
217
218 - name: Download migrated collection artifacts
219 uses: actions/download-artifact@v4
220 with:
221 name: collection-${{ matrix.ansible }}
222 path: .cache/collection-tarballs
223
224 - name: Install the collection tarball
225 run: ansible-galaxy collection install .cache/collection-tarballs/*.tar.gz
226
227 - name: Install the ND collection (NDO dependency)
228 run: ansible-galaxy collection install cisco.nd
229
230 - name: Install the ACI collection (test case dependency)
231 run: ansible-galaxy collection install cisco.aci
232
233 - name: Requesting integration mutex
234 uses: nev7n/wait_for_response@v1
235 with:
236 url: ${{ format('{0}/v1/ansible-mso?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }}
237 responseCode: 200
238 timeout: 2000000
239 interval: 5000
240
241 - name: Run integration tests on Python ${{ env.python_version }}
242 run: |
243 ansible-test network-integration --docker -v --color --retry-on-error --python ${{ env.python_version }} \
244 --truncate 0 --continue-on-error --coverage
245 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
246
247 - name: Releasing integration mutex
248 uses: nev7n/wait_for_response@v1
249 if: always()
250 with:
251 url: ${{ format('{0}/v1/ansible-mso/release?repo={1}&run_id={2}', env.MUTEX_URL, github.repository, github.run_id) }}
252 responseCode: 200
253
254 - name: Generate coverage report
255 if: always()
256 run: ansible-test coverage xml -v --requirements --group-by command --group-by version
257 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso
258
259 - name: Push coverate report to codecov.io
260 if: always()
261 run: bash <(curl -s https://codecov.io/bash) -s 'tests/output/reports/' -F integration
262 working-directory: /home/runner/.ansible/collections/ansible_collections/cisco/mso