-
Notifications
You must be signed in to change notification settings - Fork 61
272 lines (262 loc) · 10.1 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
---
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@v2
- uses: dorny/paths-filter@v2
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/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'
- '.github/workflows/*'
python:
- 'ansible_collections/arista/cvp/plugins/**/*.py'
- '.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/[email protected]
- uses: actions/checkout@v2
with:
fetch-depth: 0
- 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 ]
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
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'
strategy:
fail-fast: true
matrix:
python_version: [ 3.9 ]
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
- name: Install requirements
run: |
pip install -r ansible_collections/arista/cvp/requirements-dev.txt
pip install -r ansible_collections/arista/cvp/requirements.txt
- name: 'Execute pytest validation'
run: |
cd tests/
make test
- uses: actions/upload-artifact@v2
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.11.3', 'ansible-core>=2.11.3']
avd_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@v2
- name: Run molecule action
uses: arista-netdevops-community/[email protected]
with:
molecule_parentdir: 'ansible_collections/arista/cvp'
molecule_command: 'test'
molecule_args: '--scenario-name ${{ matrix.avd_scenario }}'
pip_file: ansible_collections/arista/cvp/requirements.txt
ansible: "${{ matrix.ansible_version }}"
check_git: true
check_git_enforced: false
- uses: actions/upload-artifact@v2
with:
name: molecule-${{ matrix.avd_scenario }}-artifacts
path: ansible_collections/arista/cvp/molecule/${{ matrix.avd_scenario }}
molecule_dhcp:
name: Validate Roles for DHCP management
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ansible_version: ['ansible-core==2.11.3', 'ansible-core>=2.11.3']
avd_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@v2
- name: Run molecule action
uses: arista-netdevops-community/[email protected]
with:
molecule_parentdir: 'ansible_collections/arista/cvp'
molecule_command: 'test'
molecule_args: '--scenario-name ${{ matrix.avd_scenario }}'
pip_file: ansible_collections/arista/cvp/requirements.txt
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'
steps:
- uses: actions/checkout@v2
- name: 'start docker-compose stack'
run: |
cp development/docker-compose.yml .
sed -i 's/cd\sansible-cvp\/\s\&\&//g' docker-compose.yml
docker-compose -f docker-compose.yml up -d webdoc_cvp
docker-compose -f docker-compose.yml ps
- name: 'test connectivity to mkdoc server'
run: |
sleep 30
until docker exec webdoc_cvp curl -s -I http://localhost:8000/ ; do sleep 2; done
- name: check links for 404
run: |
docker run --network container:webdoc_cvp raviqqe/muffet:2.6.1 http://127.0.0.1:8000 \
-e ".*fonts.googleapis.com.*" \
-e ".*fonts.gstatic.com.*" \
-e ".*edit.*" \
-e ".*aristanetworks.force.com.*" \
-e ".*https://s3.amazonaws.com/onelogin-sourcemaps/.*" \
-e "twitter.com" \
-f --buffer-size=8192 \
--color=always \
--skip-tls-verification \
--timeout=30
- name: 'stop docker-compose stack'
run: |
docker-compose -f 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.9 ]
steps:
- name: 'set environment variables'
run: |
echo "PY_COLORS=1" >> $GITHUB_ENV
echo "ANSIBLE_FORCE_COLOR=1" >> $GITHUB_ENV
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
- name: 'Install Python requirements'
run: make install-requirements
- name: 'ansible-test linting'
run: |
cd ansible_collections/arista/cvp/
rm -rf molecule/
ansible-test sanity -v --requirements --docker --python ${{ matrix.python_version }}
rm -rf tests/output/