-
Notifications
You must be signed in to change notification settings - Fork 61
348 lines (336 loc) · 13.5 KB
/
pull-request-management.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
---
name: "Collection code testing"
on:
pull_request:
branches-ignore:
- releases/**
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
file-changes:
runs-on: ubuntu-latest
outputs:
code_v1: ${{ steps.filter.outputs.code_v1 }}
code_v3: ${{ steps.filter.outputs.code_v3 }}
dhcp_module: ${{ steps.filter.outputs.dhcp_module }}
docs: ${{ steps.filter.outputs.docs }}
python: ${{ steps.filter.outputs.python }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code_v1:
- 'ansible_collections/arista/cvp/plugins/module_utils/schema_v1.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/tools_inventory.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/tools_tree.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/tools.py'
- 'ansible_collections/arista/cvp/plugins/modules/cv_facts.py'
- 'ansible_collections/arista/cvp/plugins/modules/cv_configlet.py'
- 'ansible_collections/arista/cvp/plugins/modules/cv_container.py'
- 'ansible_collections/arista/cvp/plugins/modules/cv_device.py'
- 'ansible_collections/arista/cvp/plugins/modules/cv_task.py'
- '.github/workflows/*'
- 'ansible_collections/arista/cvp/molecule/*'
- 'ansible_collections/arista/cvp/molecule/**/*'
- '!ansible_collections/arista/cvp/galaxy.yml'
code_v3:
- 'ansible_collections/arista/cvp/plugins/module_utils/configlet_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/container_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/device_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/task_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/fact_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/image_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/tag_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/validate_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/response.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/generic_tools.py'
- 'ansible_collections/arista/cvp/plugins/module_utils/schema_v3.py'
- 'ansible_collections/arista/cvp/plugins/modules/*_v3.py'
- '.github/workflows/*'
- 'tests/**/*'
- 'tests/*'
dhcp_module:
- 'ansible_collections/arista/cvp/roles/dhcp_configuration/*'
- 'ansible_collections/arista/cvp/roles/dhcp_configuration/**/*'
- '.github/workflows/*'
docs:
- 'mkdocs.yml'
- 'ansible_collections/arista/cvp/docs/**'
- 'ansible_collections/arista/cvp/roles/**/README.md'
- 'ansible_collections/arista/cvp/index.md'
- '.github/workflows/*'
python:
- 'ansible_collections/arista/cvp/plugins/**/*.py'
- '.github/workflows/*'
requirements:
- 'development/requirements-dev.txt'
- 'development/requirements.txt'
- 'ansible_collections/arista/cvp/requirements-dev.txt'
- 'ansible_collections/arista/cvp/requirements.txt'
- '.github/workflows/*'
pre_commit:
name: Run pre-commit validation hooks
runs-on: ubuntu-latest
needs: file-changes
if: needs.file-changes.outputs.dhcp_module == 'true' || needs.file-changes.outputs.code_v3 == 'true' || needs.file-changes.outputs.code_v1 == 'true'
steps:
# Removed as gh action is marked as deprecated
# - uses: pre-commit/action@v2.0.2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install requirements
run: |
pip install -r ansible_collections/arista/cvp/requirements-dev.txt --upgrade
pip install -r ansible_collections/arista/cvp/requirements.txt --upgrade
- name: Run pre-commit
run: |
pre-commit run --color always --from-ref origin/devel --to-ref HEAD
python_version_support:
name: Validate code compatibility
runs-on: ubuntu-latest
needs: [file-changes, pre_commit]
if: needs.file-changes.outputs.code_v3 == 'true'
strategy:
fail-fast: true
matrix:
python_version: ['3.9','3.10','3.11']
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Test code compatibility
run: |
cd ansible_collections/arista/cvp/plugins
python3 -m compileall -q module_utils
python3 -m compileall -q modules
pytest:
name: Validate code V3 with Pytest
runs-on: ubuntu-latest
needs: [python_version_support]
if: needs.file-changes.outputs.code_v3 == 'true' || needs.file-changes.outputs.requirements == 'true'
strategy:
fail-fast: true
matrix:
python_version: ['3.9','3.10','3.11','3.12']
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Install requirements
# Removing ansible-lint in requirement-dev-3.9 to allow requirements installation for Python 3.9.
run: |
pip install -r ansible_collections/arista/cvp/requirements-dev-pytest.txt
pip install -r ansible_collections/arista/cvp/requirements.txt
- name: 'Execute pytest validation'
run: |
cd tests/
make unit-tests
- uses: actions/upload-artifact@v3
with:
name: pytest-report
path: |
./tests/report.html
./tests/htmlcov
molecule_cv_modules:
name: Validate code V1 with Molecule
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ansible_version:
- 'ansible-core>=2.15.0,<2.18.0 --upgrade'
cvp_scenario:
- cv_configlet_loose
- cv_configlet_strict
- cv_device
needs: [file-changes, pre_commit]
if: needs.file-changes.outputs.code_v1 == 'true'
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Run molecule action
uses: arista-netdevops-community/action-molecule-avd@v1.8.1
with:
molecule_parentdir: 'ansible_collections/arista/cvp'
molecule_command: 'test'
molecule_args: '--scenario-name ${{ matrix.cvp_scenario }}'
pip_file: ansible_collections/arista/cvp/requirements.txt
galaxy_file: "ansible_collections/arista/cvp/collections.yml"
ansible: "${{ matrix.ansible_version }}"
check_git: true
check_git_enforced: false
- uses: actions/upload-artifact@v3
with:
name: molecule-${{ matrix.cvp_scenario }}-artifacts
path: ansible_collections/arista/cvp/molecule/${{ matrix.cvp_scenario }}
molecule_dhcp:
name: Validate Roles for DHCP management
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ansible_version: ['ansible-core==2.15.0', 'ansible-core<2.18.0']
cvp_scenario:
- dhcp_management_mac
- dhcp_management_offline
- dhcp_system_mac
needs: [file-changes, pre_commit]
if: needs.file-changes.outputs.dhcp_module == 'true'
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Run molecule action
uses: arista-netdevops-community/action-molecule-avd@v1.8.1
with:
molecule_parentdir: 'ansible_collections/arista/cvp'
molecule_command: 'test'
molecule_args: '--scenario-name ${{ matrix.cvp_scenario }}'
pip_file: ansible_collections/arista/cvp/requirements.txt
galaxy_file: "ansible_collections/arista/cvp/collections.yml"
ansible: "${{ matrix.ansible_version }}"
check_git: true
check_git_enforced: false
offline_link_check:
name: 'Validate mkdoc links'
runs-on: ubuntu-latest
needs: [file-changes]
if: needs.file-changes.outputs.docs == 'true'
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: 'start docker compose stack'
run: |
docker compose -f development/docker-compose.yml up -d webdoc_cvp
docker compose -f development/docker-compose.yml ps
- name: 'test connectivity to mkdoc server'
run: |
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' 127.0.0.1:8000)" != "200" ]]; do sleep 5; done'
- name: check links for 404
run: |
docker run --network container:webdoc_cvp raviqqe/muffet:2.10.1 http://127.0.0.1:8000/ -f \
--buffer-size 8192 \
--exclude ".*fonts.googleapis.com.*" \
--exclude ".*fonts.gstatic.com.*" \
--exclude ".*tools.ietf.org.*" \
--exclude ".*edit.*" \
--exclude ".*docs.github.com.*" \
--exclude "twitter.com" \
--exclude "www.docker.com" \
--exclude "hub.docker.com" \
--exclude "tech-library.arista.com" \
--max-connections-per-host 30 \
--max-redirections 3 \
--rate-limit 1 \
--timeout 30
- name: 'stop docker compose stack'
run: |
docker compose -f development/docker-compose.yml down
ansible_test:
name: Run ansible-test validation
runs-on: ubuntu-latest
needs: [molecule_dhcp, molecule_cv_modules, pytest]
if: always()
env:
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
strategy:
fail-fast: true
matrix:
python_version: ['3.10']
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: 'Install Python requirements'
run: make install-requirements
- name: 'ansible-test linting'
run: |
cd ansible_collections/arista/cvp/
ansible-test sanity -v --requirements --docker --python ${{ matrix.python_version }}
ansible_lint:
name: Run ansible-lint test case
runs-on: ubuntu-latest
needs: [ file-changes ]
steps:
- name: 'Set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: |
3.10
- name: 'Install Python & Ansible requirements'
run: |
pip install -r ansible_collections/arista/cvp/requirements.txt -r ansible_collections/arista/cvp/requirements-dev.txt --upgrade
- name: 'Run ansible-test integration test cases'
run: |
cd ansible_collections/arista/cvp/
ansible-lint --force-color --strict -v
# ----------------------------------- #
# Galaxy Importer
# ----------------------------------- #
galaxy_importer:
name: Test galaxy-importer
runs-on: ubuntu-20.04 # Older version to be compatible with old python
env:
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
GALAXY_IMPORTER_CONFIG: galaxy-importer/galaxy-importer.cfg
steps:
- uses: actions/setup-python@v5
with:
python-version: |
3.10
- uses: actions/checkout@v4
- name: 'Install Python & Ansible requirements'
run: |
pip install -r ansible_collections/arista/cvp/requirements.txt -r ansible_collections/arista/cvp/requirements-dev.txt --upgrade
ansible-galaxy collection install -r ansible_collections/arista/cvp/collections.yml
- name: Install galaxy-importer
# Install the specific version of galaxy-importer used on galaxy.ansible.com
# The version conflicts with our requirements,
# so we let the galaxy-importer version resolve remaining requirements.
run: |
pip install "galaxy-importer==0.4.20"
- name: 'Build ansible package'
run: make collection-build
- name: 'Run galaxy-importer checks'
run: python -m galaxy_importer.main *.tar.gz
- uses: actions/upload-artifact@v3
with:
name: importer-logs
path: ./importer_result.json