-
Notifications
You must be signed in to change notification settings - Fork 11
644 lines (613 loc) · 24.9 KB
/
doc-lint-test.yaml
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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# Builds an image that contains GeoIPS built with `pip install .[doc,lint,test]`
name: Build Documentation, Lint, and Test
env:
# The registry that will be used to store all images
# Override from repo or org level to use a different registry
DOCKER_REGISTRY: ghcr.io
# The path to the GeoIPS package in DOCLINTTEST images
BASE_GEOIPS_PATH: /packages/geoips
# Allow overriding the doclinttest image tag used for plugin packages
# Allows using a different version of the doc, lint, and test code
PLUGIN_DOCLINTTEST_TAG: doclinttest-stable
defaults:
run:
shell: bash
on:
# Triggers when code is pushed to "main" branch
# This should only happen when PRs are merged
push:
branches:
- main
# Triggers the workflow when pull request created and updated
pull_request:
# Triggers when a new release is created
release:
types:
- published
# Allows run of this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# Set variables that should be accessible to all jobs
set_variables:
runs-on: ${{ vars.RUNNER }}
env:
CURR_REPO: ${{ github.event.repository.name }}
outputs:
# The name of the untagged docker images to be created by this workflow
IMAGE_NAME: ${{ steps.set_image_name.outputs.IMAGE_NAME }}
# The tag to use for the doclinttest images
DOCLINTTEST_TAG: ${{ steps.set_doclinttest_tag.outputs.DOCLINTTEST_TAG }}
# The image to use for doclinttest jobs
DOCLINTTEST_IMAGE: ${{ steps.set_doclinttest_image.outputs.DOCLINTTEST_IMAGE }}
# Flags for enabling/disabling various parts of the workflow
# Default to enabled unless overridden by a repository-level variable
CI_BUILD_SPHINX_HTML: ${{ steps.get_job_flags.outputs.CI_BUILD_SPHINX_HTML }}
CHECK_NEW_RELEASE_NOTE: ${{ steps.get_job_flags.outputs.CHECK_NEW_RELEASE_NOTE }}
CI_BUILD_SPHINX_PDF: ${{ steps.get_job_flags.outputs.CI_BUILD_SPHINX_PDF }}
CI_LINT_BANDIT: ${{ steps.get_job_flags.outputs.CI_LINT_BANDIT }}
CI_LINT_DOC8: ${{ steps.get_job_flags.outputs.CI_LINT_DOC8 }}
CI_LINT_FLAKE8: ${{ steps.get_job_flags.outputs.CI_LINT_FLAKE8 }}
CI_LINT_BLACK: ${{ steps.get_job_flags.outputs.CI_LINT_BLACK }}
CI_TEST_INTERFACES: ${{ steps.get_job_flags.outputs.CI_TEST_INTERFACES }}
CI_TEST_PYTEST_SHORT: ${{ steps.get_job_flags.outputs.CI_TEST_PYTEST_SHORT }}
steps:
- name: Set the image name
id: set_image_name
run: |
# Create an image name using the organiztion and repository names, lowercase
image_name=${DOCKER_REGISTRY}/${GITHUB_REPOSITORY,,}
echo "IMAGE_NAME=${image_name}"
echo "IMAGE_NAME=${image_name}" >> ${GITHUB_ENV}
echo "IMAGE_NAME=${image_name}" >> ${GITHUB_OUTPUT}
- name: Set doclinttest image tag
id: set_doclinttest_tag
run: |
echo "CURR_REPO: ${CURR_REPO}"
# If the current repository is geoips, use the image we're about to build
# for running tests and building docs.
if [[ "${CURR_REPO}" == "geoips" ]]; then
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}"
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}" >> ${GITHUB_ENV}
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}" >> ${GITHUB_OUTPUT}
else
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}"
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}" >> ${GITHUB_ENV}
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}" >> ${GITHUB_OUTPUT}
fi
- name: Set doclinttest image
id: set_doclinttest_image
run: |
owner=${{ github.repository_owner }}
owner=${owner,,}
doclinttest_image_name=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}"
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}" >> ${GITHUB_ENV}
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}" >> ${GITHUB_OUTPUT}
- name: Get job flags
id: get_job_flags
run: |
# Define an array of flags and their corresponding secret values
flags=(CHECK_NEW_RELEASE_NOTE\
CI_BUILD_SPHINX_HTML \
CI_BUILD_SPHINX_PDF \
CI_LINT_BANDIT \
CI_LINT_DOC8 \
CI_LINT_FLAKE8 \
CI_LINT_BLACK \
CI_TEST_INTERFACES \
CI_TEST_PYTEST_SHORT)
for flag in "${flags[@]}"; do
# Dynamically construct the variable name and access the corresponding secret
case $flag in
CHECK_NEW_RELEASE_NOTE) val="${{ vars.CHECK_NEW_RELEASE_NOTE }}" ;;
CI_BUILD_SPHINX_HTML) val="${{ vars.CI_BUILD_SPHINX_HTML }}" ;;
CI_BUILD_SPHINX_PDF) val="${{ vars.CI_BUILD_SPHINX_PDF }}" ;;
CI_LINT_BANDIT) val="${{ vars.CI_LINT_BANDIT }}" ;;
CI_LINT_DOC8) val="${{ vars.CI_LINT_DOC8 }}" ;;
CI_LINT_FLAKE8) val="${{ vars.CI_LINT_FLAKE8 }}" ;;
CI_LINT_BLACK) val="${{ vars.CI_LINT_BLACK }}" ;;
CI_TEST_INTERFACES) val="${{ vars.CI_TEST_INTERFACES }}" ;;
CI_TEST_PYTEST_SHORT) val="${{ vars.CI_TEST_PYTEST_SHORT }}" ;;
esac
# Check if the secret value is "true" and set the environment variable and output
if [ "$val" == "false" ]; then
echo "${flag}=false"
echo "${flag}=false" >> $GITHUB_ENV
echo "${flag}=false" >> $GITHUB_OUTPUT
else
echo "${flag}=true"
echo "${flag}=true" >> $GITHUB_ENV
echo "${flag}=true" >> $GITHUB_OUTPUT
fi
done
print_run_flags:
runs-on: ${{ vars.RUNNER }}
needs: [set_variables]
steps:
- name: Print run flags
run: |
for var in $(echo '${{ toJson(needs.set_variables.outputs) }}' | jq -r 'keys[]'); do
value=$(echo '${{ toJson(needs.set_variables.outputs) }}' | jq -r --arg var "$var" '.[$var]')
echo "$var=$value"
done
# Build the base GeoIPS doclinttest image
# This image is used in all subsequent tests
# It is only built for the main GeoIPS package but is used by all repositories
#
# Within this image, the GeoIPS package is located in /packages/geoips and is
# installed using `pip install .[doc,lint,test]`. Scripts from geoips can be called
# from /packages/geoips.
build_doclinttest_image:
runs-on: ${{ vars.RUNNER }}
needs: set_variables
if: ${{ github.event.repository.name == 'geoips' }}
env:
IMAGE_NAME: ${{ needs.set_variables.outputs.IMAGE_NAME }}
BUILDCACHE_IMAGE: ${{ needs.set_variables.outputs.IMAGE_NAME }}:buildcache
DOCLINTTEST_IMAGE: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
# Can't write to registry without this
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup BuildX
uses: docker/setup-buildx-action@v3
- name: Login to the Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
# This cache allows the second push below when on the main branch
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Create tags
run: |
tags="${DOCLINTTEST_IMAGE},${BUILDCACHE_IMAGE}"
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
tags="${tags},${IMAGE_NAME}:doclinttest-stable"
else
tags="${tags},${IMAGE_NAME}:doclinttest-latest"
fi
echo "PUSH_TAGS=${tags}"
echo "PUSH_TAGS=${tags}" >> $GITHUB_ENV
- name: Build and Push image
uses: docker/build-push-action@v6
with:
context: .
target: doclinttest
push: true
tags: ${{ env.PUSH_TAGS }}
file: "Dockerfile"
cache-from: type=registry,ref=${{ env.BUILDCACHE_IMAGE }}
cache-to: type=registry,ref=ghcr.io/${{ env.BUILDCACHE_IMAGE }},mode=max
#################################################
# OLD Release Note NOT Added
#################################################
check_no_edits_to_rst_release_note:
if: >
always() &&
needs.set_variables.outputs.CHECK_NEW_RELEASE_NOTE == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
env:
CURR_REPO: ${{ github.event.repository.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git safe directory
run: git config --global --add safe.directory $PWD
- name: Detect new and modified release files
run: |
#update_this_file="$(cat update_this_release_note)"
release_notes_dir="$PWD/docs/source/releases" #/$(dirname $update_this_file)"
echo "Checking for no edits to the .rst release note in dir $release_notes_dir"
echo "git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.rst"
ret=$(git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.rst)
for file in ${ret[@]}; do
echo " $file"
done
if [ -z "$ret" ]; then
echo "PASSED"
else
echo "FAILED: Release note changes detected"
echo "Please use brassy to enter change logs in $release_notes_dir"
echo "DO NOT EDIT .RST FILES DIRECTLY :))"
exit 1
fi
#################################################
# Release Note Added
#################################################
check_new_release_note:
if: >
always() &&
github.ref != 'refs/heads/main' &&
needs.set_variables.outputs.CHECK_NEW_RELEASE_NOTE == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
env:
CURR_REPO: ${{ github.event.repository.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git safe directory
run: git config --global --add safe.directory $PWD
- name: Detect new and modified release files
run: |
echo "Checking for new and modified release note files in $PWD"
#update_this_file="$(cat update_this_release_note)"
release_notes_dir="$PWD/docs/source/releases/latest" #/$(dirname $update_this_file)"
ls $release_notes_dir
#current_release_note=`cat update_this_release_note`
echo "git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.yaml"
ret=$(git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.yaml)
echo "Release note files modified this PR:"
for file in ${ret[@]}; do
echo " $file"
done
if [ -z "$ret" ]; then
echo "FAILED: No yaml release note changes detected"
echo "Please use brassy to enter change logs in $release_notes_dir"
exit 1
else
echo "PASSED"
fi
#################################################
# Documentation builds
#################################################
build_sphinx_html:
if: >
always() &&
needs.set_variables.outputs.CI_BUILD_SPHINX_HTML == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
env:
CURR_REPO: ${{ github.event.repository.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Git safe directory
run: git config --global --add safe.directory $PWD
- name: Install package
run: pip install .
- name: Build release notes from yaml files
id: release-note-generator
run: |
# update_this_file="$(cat $BASE_GEOIPS_PATH/update_this_release_note)"
# release_notes_dir="$(dirname $update_this_file)/$(basename $update_this_file .rst)"
release_notes_dir="$PWD/docs/source/releases/latest" #/$(dirname $update_this_file)"
update_this_file="$PWD/docs/source/releases/latest.rst"
#release_version="$(basename $update_this_file .rst)"
release_version="latest"
echo "Running brassy on directory: $release_notes_dir"
brassy --release-version $release_version --no-rich --output-file $update_this_file $release_notes_dir
echo "Done writing!"
echo "release_note_file=$update_this_file" >> $GITHUB_OUTPUT
- name: Pinken release note
run: pink ${{ steps.release-note-generator.outputs.release_note_file }}
- name: Upload release note
uses: actions/upload-artifact@v4
with:
name: Release Note
path: ${{ steps.release-note-generator.outputs.release_note_file }}
if-no-files-found: error
- name: Run build html
id: build-html-docs
run: |
echo "Build html docs"
# Call build_docs.sh from the geoips default branch
# Pass in
# the path to the current plugin repo,
# the name of the current repo,
# "html_only" to indicate producing only html output, and
# the path to the docs template directory in the geoips default branch.
$BASE_GEOIPS_PATH/docs/build_docs.sh . $CURR_REPO html_only $BASE_GEOIPS_PATH/docs
ret=$?
if [[ "${ret##*:}" != *"0"* ]]; then
echo "::error::Building html docs ${ret##*:}"
exit 1
fi
echo "BUILT_DOCS_PATH=$PWD/build/sphinx/html" >> $GITHUB_OUTPUT
- name: Upload HTML Docs
uses: actions/upload-artifact@v4
with:
name: HTML Docs
path: ${{ steps.build-html-docs.outputs.BUILT_DOCS_PATH }}
if-no-files-found: error
# This job does not currently work because latex is not installed in the image. I think
# that to get this job working would only require installing texlive-base but other
# texlive packages might also be required.
#
# Additionally, this job is extremely slow. Building the PDF documentation is time
# consuming and should probably only be run on releases. Building the HTML documentation
# should be enough to catch any problems that crop up.
#
# build_sphinx_pdf:
# if: ${{ needs.set_variables.outputs.CI_DISABLE_BUILD_SPHINX_PDF == 'false' }}
# runs-on: ${{ vars.RUNNER }}
# needs: [build_doclinttest_image, set_variables]
# container:
# image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
# credentials:
# username: ${{ secrets.DOCKER_REGISTRY_USER }}
# password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
# env:
# CURR_REPO: ${{ github.event.repository.name }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
#
# - name: Configure Git safe directory
# run: git config --global --add safe.directory $PWD
#
# - name: Install geoips documentation packages
# run: pip install -e .[doc]
#
# - name: Run build pdf
# run: |
# echo "Build pdf docs"
# # Call build_docs.sh from the geoips default branch
# # Pass in
# # the path to the current plugin repo,
# # the name of the current repo,
# # "pdf_only" to indicate producing only pdf output, and
# # the path to the docs template directory in the geoips default branch.
# ./docs/build_docs.sh . $CURR_REPO pdf_only ./docs
# ret=$?
# if [[ "${ret##*:}" != *"0"* ]]; then
# echo "::error::Building pdf docs ${ret##*:}"
# exit 1
# fi
#################################################
# Linting
#################################################
lint_bandit:
if: >
always() &&
needs.set_variables.outputs.CI_LINT_BANDIT == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run bandit
shell: bash -l {0}
run: |
echo "::group::bandit_analysis"
echo "BANDIT analysis of code"
$BASE_GEOIPS_PATH/tests/utils/check_code.sh bandit ./
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to bandit violations, return code ${ret}"
exit 1
fi
lint_doc8:
if: >
always() &&
needs.set_variables.outputs.CI_LINT_DOC8 == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run doc8
shell: bash -l {0}
run: |
echo "::group::doc8_analysis"
if [ ! -d "./docs/source/new-docs" ]; then
echo "No new-docs directory found in ${CURR_REPO}"
exit 0
fi
echo "Doc8 analysis of code"
doc8 --max-line-length=120 ./docs/source/new-docs/
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to doc8 violations, return code ${ret}"
exit 1
fi
lint_flake8:
if: >
always() &&
needs.set_variables.outputs.CI_LINT_FLAKE8 == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run flake8
shell: bash -l {0}
run: |
echo "::group::flake8_analysis"
echo "FLAKE8 analysis of code"
$BASE_GEOIPS_PATH/tests/utils/check_code.sh flake8 .
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to flake8 violations, return code ${ret}"
exit 1
fi
lint_black:
if: >
always() &&
needs.set_variables.outputs.CI_LINT_BLACK == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run code check script black
shell: bash -l {0}
run: |
echo "::group::black_analysis"
echo "BLACK analysis of code"
black --version
$BASE_GEOIPS_PATH/tests/utils/check_code.sh black ./
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to black violations, return code ${ret}"
exit 1
fi
#################################################
# Code tests
#################################################
test_interfaces:
if: >
always() &&
needs.set_variables.outputs.CI_TEST_INTERFACES == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Git safe directory
run: git config --global --add safe.directory $PWD
- name: Pip install package
run: pip install -v .
- name: create_plugin_registries
run: create_plugin_registries
- name: Run code check script interfaces
run: |
$BASE_GEOIPS_PATH/tests/utils/check_code.sh interfaces geoips
ret=$?
echo "::group::interface_analysis"
echo "INTERFACES analysis of code"
echo "${ret}"
echo "::endgroup::"
if [[ "${ret##*:}" != *"0"* ]]; then
echo "::error::due to interface violations ${ret##*:}"
exit 1
fi
test_pytest_short:
if: >
always() &&
needs.set_variables.outputs.CI_TEST_PYTEST_SHORT == 'true' &&
(needs.build_doclinttest_image.result == 'success' ||
needs.build_doclinttest_image.result == 'skipped')
runs-on: ${{ vars.RUNNER }}
needs: [build_doclinttest_image, set_variables]
container:
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }}
credentials:
username: ${{ secrets.DOCKER_REGISTRY_USER }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
env:
CURR_REPO: ${{ github.event.repository.name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure Git safe directory
run: git config --global --add safe.directory $PWD
- name: Pip install package
run: pip install -v .
- name: create_plugin_registries
run: create_plugin_registries
# Run unit tests for this repo if they exist
- name: Run pytest unit tests
run: |
echo "::group::pytest_unit_test"
echo "Pytest short unit tests of ${CURR_REPO}"
echo "which pytest"
which pytest
if [ ! -d "./tests/unit_tests" ]; then
echo "No unit tests found in ${CURR_REPO}"
exit 0
fi
echo "pytest -q ./tests/unit_tests"
pytest -q ./tests/unit_tests
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to geoips repo pytest errors, return code ${ret}"
exit 1
fi
- name: Run base GeoIPS pytest unit tests
if: ${{ env.CURR_REPO != 'geoips' }}
run: |
echo "::group::pytest_unit_test"
echo "Pytest short unit tests of ${CURR_REPO} using core GeoIPS tests"
echo "which pytest"
which pytest
echo "pytest -q $BASE_GEOIPS_PATH/tests/unit_tests"
pytest -q $BASE_GEOIPS_PATH/tests/unit_tests
ret=$?
echo "Return code: ${ret}"
echo "::endgroup::"
if [[ "${ret}" != *"0"* ]]; then
echo "::error::due to geoips repo pytest errors, return code ${ret}"
exit 1
fi