Repository navigation
224 lines (212 loc) · 8.76 KB
/
Copy pathpython.yml
File metadata and controls
224 lines (212 loc) · 8.76 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
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University
name: python
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
workflow_dispatch:
concurrency:
group: python-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# One thread per process: the suite is numerically heavy and runs on one pytest-xdist
# worker per core, so a worker must not start threads of its own.
OMP_NUM_THREADS: "1"
MKL_NUM_THREADS: "1"
OPENBLAS_NUM_THREADS: "1"
NUMBA_NUM_THREADS: "1"
MPLBACKEND: Agg
PYTHONUTF8: "1"
jobs:
lint:
name: Lint, type check and release metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the package and development tools
run: python -m pip install --upgrade pip ".[dev,fast,contact]"
- name: Ruff
run: |
python -m ruff check src tests examples validation release doc
python -m ruff format --check src tests examples validation release doc
- name: Mypy (strict)
run: python -m mypy
- name: Check release metadata
run: python release/check_release_metadata.py
- name: Audit the tracked tree
run: python release/audit_release_tree.py --tree .
test:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.11', '3.12']
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the package and test dependencies
run: python -m pip install --upgrade pip ".[dev,fast,contact]"
- name: Run the test suite
run: python -m pytest -q -p no:cacheprovider -n auto --dist worksteal --durations=25
reference-path:
name: Tests without the compiled kernels
runs-on: ubuntu-latest
timeout-minutes: 120
env:
CABLEXSEC_DISABLE_NUMBA: "1"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the package without numba
run: python -m pip install --upgrade pip ".[dev,contact]"
- name: Run the test suite on the NumPy reference path
run: python -m pytest -q -p no:cacheprovider -n auto --dist worksteal --durations=25
coverage-suite:
# Not a required check itself: the required check "Coverage and validation report"
# passes only if this job and validation-report both pass.
name: Coverage of the whole suite
runs-on: ubuntu-latest
timeout-minutes: 150
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the package and test dependencies
run: python -m pip install --upgrade pip ".[dev,fast,contact]"
- name: Run the whole suite with line and branch coverage, kernels traced
# Functions compiled by numba run outside the coverage tracer, so the kernel
# tests run a second time with NUMBA_DISABLE_JIT=1 and are appended.
run: python release/check_coverage.py --fail-under 95 --numprocesses auto
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: cablexsec-coverage
path: coverage.xml
if-no-files-found: ignore
validation-report:
# Not a required check itself; see coverage-suite.
name: Validation report is current
runs-on: ubuntu-latest
timeout-minutes: 150
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.11'
cache: pip
cache-dependency-path: pyproject.toml
- name: Install the package and test dependencies
run: python -m pip install --upgrade pip ".[dev,fast,contact]"
- name: The committed validation report is current
# The script exits non-zero while registered benchmark rows fail; the step
# fails only if the committed report differs from the live calculation.
# --jobs=auto evaluates the independent row groups and the taxonomy groups
# concurrently; the rows and the report are those of the serial run.
shell: bash
run: |
set +e
python validation/scripts/run_validation.py --check --jobs=auto 2>&1 | tee validation-check.txt
status=${PIPESTATUS[0]}
if grep -q "validation artefacts are stale" validation-check.txt; then exit 1; fi
echo "run_validation exit status ${status} (registered FAIL rows are expected)"
coverage:
# The required check. The coverage run and the validation report check run side by
# side in the two jobs above; this job fails unless both succeeded, and it also
# runs (and fails) when either of them failed, was cancelled or was skipped.
name: Coverage and validation report
needs: [coverage-suite, validation-report]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: The coverage gate and the validation report check passed
shell: bash
env:
COVERAGE_RESULT: ${{ needs.coverage-suite.result }}
VALIDATION_RESULT: ${{ needs.validation-report.result }}
run: |
echo "Coverage of the whole suite: ${COVERAGE_RESULT}"
echo "Validation report is current: ${VALIDATION_RESULT}"
test "${COVERAGE_RESULT}" = success
test "${VALIDATION_RESULT}" = success
distribution:
name: Build Python distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- run: python -m pip install --upgrade pip build twine
- name: Build reproducible distributions
shell: bash
run: |
export SOURCE_DATE_EPOCH="$(git log -1 --format=%ct)"
python -m build --outdir dist
- run: python -m twine check dist/*
- name: Install and smoke-test the wheel in a clean environment
shell: bash
run: |
python -m venv wheel-test
wheel-test/bin/python -m pip install dist/*.whl
version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])')"
PATH="$PWD/wheel-test/bin:$PATH" wheel-test/bin/python release/smoke_test_wheel.py --version "$version"
wheel-test/bin/cablexsec-batch --help
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cablexsec-python-distributions
path: dist/*
if-no-files-found: error
documentation:
name: Sphinx documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: |
doc/requirements.txt
pyproject.toml
- name: Install documentation dependencies and the package (for the API pages)
run: python -m pip install --upgrade pip -r doc/requirements.txt .
- name: Build documentation with warnings as errors
run: sphinx-build -W --keep-going -b html doc doc/_build/html