Repository navigation
321 lines (293 loc) · 10.5 KB
/
Copy pathtest.yml
File metadata and controls
321 lines (293 loc) · 10.5 KB
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
---
# .github/workflows/test.yml
#
# PR validation: lint (pre-commit), then three jobs gated on it, so
# expensive CI minutes are spent only on green code. The Python axis
# lists the interpreter versions this plugin supports. The NetBox axis
# covers the pinned NetBox ref plus the moving feature branch as a
# canary for the next minor, which reports without blocking
# (continue-on-error). The internals job below is the one blocking
# check on that branch: it resolves the NetBox symbols the plugin
# depends on and nothing else.
#
# Test config:
# The plugin's testing/configuration.py, or configuration_branching.py
# for the branching job, is loaded via NETBOX_CONFIGURATION +
# PYTHONPATH, per the convention documented in CONTRIBUTING.md's
# Running tests section. The plugin is installed editable into
# NetBox's checkout so its source path is on sys.path.
#
# Coverage:
# Collected on a SINGLE matrix leg (see the matrix `include`) and run as
# separate, individually-gated steps, mirroring NetBox Community's CI:
# coverage run --parallel -> coverage combine -> coverage report. Other
# legs run plain `manage.py test --parallel`.
name: Test
"on":
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
lint:
name: Lint (pre-commit)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- name: Setup Python
# actions/setup-python v7.0.0
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: '3.12'
cache: pip
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always
- name: Check the manifest
# Nothing else guards what the sdist carries.
run: >-
pre-commit run --hook-stage manual check-manifest --all-files
--color=always
test:
name: >-
py${{ matrix.python-version }} / netbox-${{ matrix.netbox-ref }}${{
matrix.coverage && ' (coverage)' || '' }}
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 20
# 'feature' carries the next minor, so a core change reaches it before any
# release this plugin supports. 'main' is what the next patch is cut from.
continue-on-error: >-
${{ matrix.netbox-ref == 'feature' }}
env:
NETBOX_CONFIGURATION: configuration
PYTHONPATH: ${{ github.workspace }}/netbox-scripts/testing
COVERAGE_RCFILE: ${{ github.workspace }}/netbox-scripts/pyproject.toml # yamllint disable-line rule:line-length
# S3 support is a hard platform contract, so CI fails loudly when the
# S3 test stack is missing instead of silently skipping that coverage.
REQUIRE_S3_TESTS: '1'
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
netbox-ref:
- 'v4.7.5'
- 'main'
- 'feature'
include:
- coverage: false
# One leg: line coverage does not vary by Python or core version.
- python-version: '3.14'
netbox-ref: 'main'
coverage: true
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
POSTGRES_USER: netbox
POSTGRES_PASSWORD: netbox
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout plugin
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
path: netbox-scripts
- name: Checkout NetBox
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: netbox-community/netbox
ref: ${{ matrix.netbox-ref }}
path: netbox
- name: Setup Python ${{ matrix.python-version }}
# actions/setup-python v7.0.0
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Install NetBox dependencies
working-directory: netbox
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install plugin (editable, with test extras)
working-directory: netbox-scripts
run: pip install -e '.[test]'
- name: Run tests
if: ${{ ! matrix.coverage }}
working-directory: netbox
run: >-
python netbox/manage.py test
netbox_scripts.tests --parallel
- name: Run tests with coverage
if: ${{ matrix.coverage }}
working-directory: netbox
run: >-
coverage run netbox/manage.py test
netbox_scripts.tests --parallel
- name: Combine coverage data
if: ${{ matrix.coverage }}
working-directory: netbox
run: coverage combine
- name: Show coverage report
if: ${{ matrix.coverage }}
working-directory: netbox
run: coverage report
# A job, not a matrix leg: an `include` whose keys match an existing
# combination is merged into it, so it would have taken over the
# coverage leg rather than adding one.
test-branching:
name: py3.14 / netbox-v4.7.5 / branching-1.2.3
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 20
# Reports without blocking, like the feature leg above.
continue-on-error: true
env:
NETBOX_CONFIGURATION: configuration_branching
PYTHONPATH: ${{ github.workspace }}/netbox-scripts/testing
# Turns a Branching install that did not happen into a failure. Without
# it the provisioned classes are not collected and the job passes
# having run nothing.
NETBOX_SCRIPTS_REQUIRE_BRANCHING: '1'
services:
redis:
image: redis
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
POSTGRES_USER: netbox
POSTGRES_PASSWORD: netbox
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout plugin
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
path: netbox-scripts
- name: Checkout NetBox
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: netbox-community/netbox
ref: v4.7.5
path: netbox
- name: Setup Python 3.14
# actions/setup-python v7.0.0
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: '3.14'
cache: pip
- name: Install NetBox dependencies
working-directory: netbox
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install plugin (editable, with test extras)
working-directory: netbox-scripts
run: pip install -e '.[test]'
# Pinned exactly, so it cannot drift onto a line whose NetBox
# ceiling sits below this plugin's floor.
- name: Install NetBox Branching
run: pip install 'netboxlabs-netbox-branching==1.2.3'
# Provisioning replicates every branch-aware table, once per test.
- name: Tune PostgreSQL for branch provisioning
run: |
sudo apt-get update -q
sudo apt-get install -y -q postgresql-client
PGPASSWORD=netbox psql -h localhost -U netbox \
-c "ALTER SYSTEM SET checkpoint_timeout = '30min'" \
-c "ALTER SYSTEM SET max_wal_size = '2GB'" \
-c "ALTER SYSTEM SET synchronous_commit = off" \
-c "ALTER SYSTEM SET lock_timeout = '60s'" \
-c "SELECT pg_reload_conf()"
# This module only, and never --parallel: each test provisions and
# drops a schema, which parallel clones would multiply per worker.
- name: Run the provisioned-branch tests
working-directory: netbox
run: >-
python netbox/manage.py test
netbox_scripts.tests.test_branching
netbox_scripts.tests.test_branching_provisioned -v 2
# Blocking, unlike the feature test leg. With no database, services or
# fixtures, what fails here is a crossing, the plugin skipped outside its
# version range, or NetBox settings or setup, each worth a look before a
# merge.
internals:
name: netbox-feature / internals canary
needs: lint
runs-on: ubuntu-latest
timeout-minutes: 10
continue-on-error: false
env:
NETBOX_CONFIGURATION: configuration
PYTHONPATH: ${{ github.workspace }}/netbox-scripts/testing
steps:
- name: Checkout plugin
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
path: netbox-scripts
- name: Checkout NetBox
# actions/checkout v7.0.1
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
repository: netbox-community/netbox
ref: feature
path: netbox
- name: Setup Python 3.12
# actions/setup-python v7.0.0
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97
with:
python-version: '3.12'
cache: pip
- name: Install NetBox dependencies
working-directory: netbox
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install plugin (editable)
working-directory: netbox-scripts
run: pip install -e .
- name: Resolve every listed NetBox internal
working-directory: netbox-scripts
run: >-
python scripts/check_netbox_internals.py
--netbox ${{ github.workspace }}/netbox/netbox