| 1 |
name: Linux tests |
| 2 |
|
| 3 |
# This file is meant for testing across supported Python versions, build types |
| 4 |
# and interpreters (PyPy, python-dbg, a pre-release Python in summer time), |
| 5 |
# build-via-sdist, run benchmarks, measure code coverage, and other build |
| 6 |
# options. |
| 7 |
|
| 8 |
on: |
| 9 |
push: |
| 10 |
branches: |
| 11 |
# coverage comparison in the "full" step needs to run on main after merges |
| 12 |
- main |
| 13 |
pull_request: |
| 14 |
branches: |
| 15 |
- main |
| 16 |
- maintenance/** |
| 17 |
paths-ignore: |
| 18 |
- '**.pyi' |
| 19 |
- '**.md' |
| 20 |
- '**.rst' |
| 21 |
|
| 22 |
defaults: |
| 23 |
run: |
| 24 |
shell: bash |
| 25 |
|
| 26 |
concurrency: |
| 27 |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 28 |
cancel-in-progress: true |
| 29 |
|
| 30 |
permissions: |
| 31 |
contents: read # to fetch code (actions/checkout) |
| 32 |
|
| 33 |
jobs: |
| 34 |
lint: |
| 35 |
# To enable this job and subsequent jobs on a fork, comment out: |
| 36 |
if: github.repository == 'numpy/numpy' && github.event_name != 'push' |
| 37 |
runs-on: ubuntu-latest |
| 38 |
continue-on-error: true |
| 39 |
steps: |
| 40 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 41 |
with: |
| 42 |
submodules: recursive |
| 43 |
fetch-depth: 0 |
| 44 |
persist-credentials: false |
| 45 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 46 |
with: |
| 47 |
python-version: '3.11' |
| 48 |
- name: Install linter requirements |
| 49 |
run: |
| 50 |
python -m pip install -r requirements/linter_requirements.txt |
| 51 |
- name: Run linter on PR |
| 52 |
env: |
| 53 |
BASE_REF: ${{ github.base_ref }} |
| 54 |
run: |
| 55 |
python tools/linter.py |
| 56 |
- name: Check Python.h is first file included |
| 57 |
run: | |
| 58 |
python tools/check_python_h_first.py |
| 59 |
|
| 60 |
|
| 61 |
smoke_test: |
| 62 |
# To enable this job on a fork, comment out: |
| 63 |
if: github.repository == 'numpy/numpy' |
| 64 |
runs-on: ubuntu-latest |
| 65 |
env: |
| 66 |
MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none" |
| 67 |
strategy: |
| 68 |
matrix: |
| 69 |
version: ["3.11", "3.12", "3.13", "3.14", "3.14t"] |
| 70 |
steps: |
| 71 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 72 |
with: |
| 73 |
submodules: recursive |
| 74 |
fetch-tags: true |
| 75 |
persist-credentials: false |
| 76 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 77 |
with: |
| 78 |
python-version: ${{ matrix.version }} |
| 79 |
- uses: ./.github/meson_actions |
| 80 |
|
| 81 |
pypy: |
| 82 |
needs: [smoke_test] |
| 83 |
runs-on: ubuntu-latest |
| 84 |
if: github.event_name != 'push' |
| 85 |
steps: |
| 86 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 87 |
with: |
| 88 |
submodules: recursive |
| 89 |
fetch-tags: true |
| 90 |
persist-credentials: false |
| 91 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 92 |
with: |
| 93 |
python-version: 'pypy3.11-v7.3.20' |
| 94 |
- name: Setup using scipy-openblas |
| 95 |
run: | |
| 96 |
python -m pip install -r requirements/ci_requirements.txt |
| 97 |
spin config-openblas --with-scipy-openblas=32 |
| 98 |
- uses: ./.github/meson_actions |
| 99 |
|
| 100 |
debug: |
| 101 |
needs: [smoke_test] |
| 102 |
runs-on: ubuntu-24.04 |
| 103 |
if: github.event_name != 'push' |
| 104 |
steps: |
| 105 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 106 |
with: |
| 107 |
submodules: recursive |
| 108 |
fetch-tags: true |
| 109 |
persist-credentials: false |
| 110 |
- name: Install debug Python |
| 111 |
run: | |
| 112 |
sudo apt-get update |
| 113 |
sudo apt-get install python3-dbg ninja-build |
| 114 |
- name: Build NumPy and install into venv |
| 115 |
run: | |
| 116 |
python3-dbg -m venv venv |
| 117 |
source venv/bin/activate |
| 118 |
pip install -U pip |
| 119 |
pip install . -v -Csetup-args=-Dbuildtype=debug -Csetup-args=-Dallow-noblas=true |
| 120 |
- name: Install test dependencies |
| 121 |
run: | |
| 122 |
source venv/bin/activate |
| 123 |
pip install -r requirements/test_requirements.txt |
| 124 |
- name: Run test suite |
| 125 |
run: | |
| 126 |
source venv/bin/activate |
| 127 |
cd tools |
| 128 |
pytest --timeout=600 --durations=10 --pyargs numpy -m "not slow" |
| 129 |
|
| 130 |
full: |
| 131 |
# Install as editable, then run the full test suite with code coverage |
| 132 |
needs: [smoke_test] |
| 133 |
runs-on: ubuntu-22.04 |
| 134 |
steps: |
| 135 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 136 |
with: |
| 137 |
submodules: recursive |
| 138 |
fetch-tags: true |
| 139 |
persist-credentials: false |
| 140 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 141 |
with: |
| 142 |
python-version: '3.11' |
| 143 |
- name: Install build and test dependencies from PyPI |
| 144 |
run: | |
| 145 |
pip install -r requirements/build_requirements.txt |
| 146 |
pip install -r requirements/test_requirements.txt |
| 147 |
- name: Install gfortran and setup OpenBLAS (MacPython build) |
| 148 |
run: | |
| 149 |
set -xe |
| 150 |
sudo apt update |
| 151 |
sudo apt install gfortran libgfortran5 |
| 152 |
python -m pip install -r requirements/ci32_requirements.txt |
| 153 |
mkdir -p ./.openblas |
| 154 |
python -c"import scipy_openblas32 as ob32; print(ob32.get_pkg_config())" > ./.openblas/scipy-openblas.pc |
| 155 |
|
| 156 |
- name: Install as editable |
| 157 |
env: |
| 158 |
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas |
| 159 |
run: | |
| 160 |
pip install -e . --no-build-isolation |
| 161 |
- name: Run full test suite |
| 162 |
run: | |
| 163 |
pytest numpy --durations=10 --timeout=600 --cov-report=html:build/coverage |
| 164 |
# TODO: gcov |
| 165 |
env: |
| 166 |
PYTHONOPTIMIZE: 2 |
| 167 |
|
| 168 |
armhf_test: |
| 169 |
# Tests NumPy on 32-bit ARM hard-float (armhf) via compatibility mode |
| 170 |
# running on aarch64 (ARM 64-bit) GitHub runners. |
| 171 |
needs: [smoke_test] |
| 172 |
if: github.repository == 'numpy/numpy' |
| 173 |
runs-on: ubuntu-24.04-arm |
| 174 |
steps: |
| 175 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 176 |
with: |
| 177 |
submodules: recursive |
| 178 |
fetch-tags: true |
| 179 |
persist-credentials: false |
| 180 |
|
| 181 |
- name: Creates new container |
| 182 |
run: | |
| 183 |
docker run --name the_container --interactive \ |
| 184 |
-v $(pwd):/numpy arm32v7/ubuntu:24.04 /bin/linux32 /bin/bash -c " |
| 185 |
apt update && |
| 186 |
apt install -y ninja-build cmake git python3 python-is-python3 python3-dev python3-pip python3-venv |
| 187 |
" |
| 188 |
docker commit the_container the_container |
| 189 |
|
| 190 |
- name: Meson Build |
| 191 |
run: | |
| 192 |
docker run --rm -e "TERM=xterm-256color" \ |
| 193 |
-v $(pwd):/numpy the_container \ |
| 194 |
/bin/script -e -q -c "/bin/linux32 /bin/bash --noprofile --norc -eo pipefail -c ' |
| 195 |
cd /numpy && |
| 196 |
python -m venv venv && |
| 197 |
source venv/bin/activate && |
| 198 |
python -m pip install -r /numpy/requirements/build_requirements.txt && |
| 199 |
python -m pip install -r /numpy/requirements/test_requirements.txt && |
| 200 |
spin build |
| 201 |
'" |
| 202 |
|
| 203 |
- name: Meson Log |
| 204 |
if: always() |
| 205 |
run: 'cat build/meson-logs/meson-log.txt' |
| 206 |
|
| 207 |
- name: Run Tests |
| 208 |
run: | |
| 209 |
docker run --rm -e "TERM=xterm-256color" \ |
| 210 |
-v $(pwd):/numpy the_container \ |
| 211 |
/bin/script -e -q -c "/bin/linux32 /bin/bash --noprofile --norc -eo pipefail -c ' |
| 212 |
cd /numpy && source venv/bin/activate && spin test -m full -- --timeout=600 --durations=10 |
| 213 |
'" |
| 214 |
|
| 215 |
benchmark: |
| 216 |
needs: [smoke_test] |
| 217 |
runs-on: ubuntu-latest |
| 218 |
if: github.event_name != 'push' |
| 219 |
steps: |
| 220 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 221 |
with: |
| 222 |
submodules: recursive |
| 223 |
fetch-tags: true |
| 224 |
persist-credentials: false |
| 225 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 226 |
with: |
| 227 |
python-version: '3.11' |
| 228 |
- name: Install build and benchmarking dependencies |
| 229 |
run: | |
| 230 |
sudo apt-get update |
| 231 |
sudo apt-get install libopenblas-dev ninja-build |
| 232 |
pip install "asv<0.6.5" virtualenv packaging -r requirements/build_requirements.txt |
| 233 |
- name: Install NumPy |
| 234 |
run: | |
| 235 |
spin build -- -Dcpu-dispatch=none |
| 236 |
# Ensure to keep the below steps as single-line bash commands (it's a |
| 237 |
# workaround for asv#1333, and it may have side-effects on multi-line commands) |
| 238 |
- name: Appease asv's need for machine info |
| 239 |
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' |
| 240 |
run: | |
| 241 |
asv machine --yes --config benchmarks/asv.conf.json |
| 242 |
- name: Run benchmarks |
| 243 |
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' |
| 244 |
run: | |
| 245 |
spin bench --quick |
| 246 |
# These are run on CircleCI |
| 247 |
# - name: Check docstests |
| 248 |
# shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"' |
| 249 |
# run: | |
| 250 |
# pip install -r requirements/doc_requirements.txt -r requirements/test_requirements.txt |
| 251 |
# spin check-docs -v |
| 252 |
# spin check-tutorials -v |
| 253 |
|
| 254 |
sdist: |
| 255 |
needs: [smoke_test] |
| 256 |
runs-on: ubuntu-latest |
| 257 |
if: github.event_name != 'push' |
| 258 |
steps: |
| 259 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 260 |
with: |
| 261 |
submodules: recursive |
| 262 |
fetch-tags: true |
| 263 |
persist-credentials: false |
| 264 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 265 |
with: |
| 266 |
python-version: '3.11' |
| 267 |
- name: Install gfortran and setup OpenBLAS (sdist build) |
| 268 |
run: | |
| 269 |
set -xe |
| 270 |
python -m pip install -r requirements/ci_requirements.txt |
| 271 |
mkdir -p ./.openblas |
| 272 |
python -c"import scipy_openblas64 as ob64; print(ob64.get_pkg_config())" > ./.openblas/scipy-openblas.pc |
| 273 |
- name: Build a wheel via an sdist |
| 274 |
env: |
| 275 |
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas |
| 276 |
run: | |
| 277 |
pip install build |
| 278 |
python -m build |
| 279 |
pip install dist/numpy*.whl |
| 280 |
- name: Install test dependencies |
| 281 |
run: | |
| 282 |
pip install -r requirements/test_requirements.txt |
| 283 |
- name: Run test suite |
| 284 |
run: | |
| 285 |
cd tools |
| 286 |
pytest --pyargs numpy -m "not slow" |
| 287 |
- name: Test SWIG binding |
| 288 |
run: | |
| 289 |
sudo apt update |
| 290 |
sudo apt install make swig |
| 291 |
make -C tools/swig/test test |
| 292 |
|
| 293 |
array_api_tests: |
| 294 |
needs: [smoke_test] |
| 295 |
runs-on: ubuntu-latest |
| 296 |
if: github.event_name != 'push' |
| 297 |
steps: |
| 298 |
- name: Checkout NumPy |
| 299 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 300 |
with: |
| 301 |
submodules: recursive |
| 302 |
fetch-tags: true |
| 303 |
persist-credentials: false |
| 304 |
- name: Checkout array-api-tests |
| 305 |
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 306 |
with: |
| 307 |
repository: data-apis/array-api-tests |
| 308 |
ref: '3c273cd34d51c64ed893737306d36adab23a94a1' # v2025.05.23 |
| 309 |
submodules: 'true' |
| 310 |
path: 'array-api-tests' |
| 311 |
persist-credentials: false |
| 312 |
- name: Set up Python |
| 313 |
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 314 |
with: |
| 315 |
python-version: '3.11' |
| 316 |
- name: Install build and test dependencies from PyPI |
| 317 |
run: | |
| 318 |
python -m pip install -r requirements/build_requirements.txt |
| 319 |
python -m pip install -r requirements/test_requirements.txt |
| 320 |
python -m pip install -r array-api-tests/requirements.txt |
| 321 |
- name: Build and install NumPy |
| 322 |
run: | |
| 323 |
python -m pip install . -v -Csetup-args=-Dallow-noblas=true -Csetup-args=-Dcpu-baseline=none -Csetup-args=-Dcpu-dispatch=none |
| 324 |
- name: Run the test suite |
| 325 |
env: |
| 326 |
ARRAY_API_TESTS_MODULE: numpy |
| 327 |
PYTHONWARNINGS: 'ignore::UserWarning::,ignore::DeprecationWarning::,ignore::RuntimeWarning::' |
| 328 |
run: | |
| 329 |
cd ${GITHUB_WORKSPACE}/array-api-tests |
| 330 |
pytest array_api_tests -v -c pytest.ini -n 4 --max-examples=1000 --derandomize --disable-deadline --xfails-file ${GITHUB_WORKSPACE}/tools/ci/array-api-xfails.txt |
| 331 |
|
| 332 |
custom_checks: |
| 333 |
needs: [smoke_test] |
| 334 |
runs-on: ubuntu-latest |
| 335 |
if: github.event_name != 'push' |
| 336 |
steps: |
| 337 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 338 |
with: |
| 339 |
submodules: recursive |
| 340 |
fetch-tags: true |
| 341 |
persist-credentials: false |
| 342 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 343 |
with: |
| 344 |
python-version: '3.11' |
| 345 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 346 |
with: |
| 347 |
repository: numpy/numpy-release |
| 348 |
path: numpy-release |
| 349 |
persist-credentials: false |
| 350 |
- name: Check scipy-openblas version in release pipelines |
| 351 |
run: | |
| 352 |
python tools/check_openblas_version.py --req-files numpy-release/requirements/openblas_requirements.txt |
| 353 |
- name: Install build and test dependencies from PyPI |
| 354 |
run: | |
| 355 |
pip install -r requirements/build_requirements.txt |
| 356 |
pip install -r requirements/test_requirements.txt |
| 357 |
pip install "vulture!=2.15" |
| 358 |
- name: Build and install NumPy |
| 359 |
run: | |
| 360 |
# Install using the fastest way to build (no BLAS, no SIMD) |
| 361 |
spin build -j2 -- -Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none |
| 362 |
- name: Check build-internal dependencies |
| 363 |
run: | |
| 364 |
ninja -C build -t missingdeps |
| 365 |
- name: Check installed test and stub files |
| 366 |
run: | |
| 367 |
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') |
| 368 |
- name: Check for unreachable code paths in Python modules |
| 369 |
run: | |
| 370 |
# Need the explicit `bash -c` here because `grep` returns exit code 1 for no matches |
| 371 |
bash -c "! vulture . --min-confidence 100 --exclude doc/,numpy/distutils/,vendored-meson/ | grep 'unreachable'" |
| 372 |
- name: Check usage of install_tag |
| 373 |
run: | |
| 374 |
rm -rf build-install |
| 375 |
./vendored-meson/meson/meson.py install -C build --destdir ../build-install --tags=runtime,python-runtime,devel |
| 376 |
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') --no-tests |
| 377 |
|
| 378 |
|
| 379 |
Linux_Python_311_32bit_full: |
| 380 |
name: i686, cp311, full |
| 381 |
needs: [smoke_test] |
| 382 |
runs-on: ubuntu-latest |
| 383 |
container: |
| 384 |
# There are few options for i686 images at https://quay.io/organization/pypa, |
| 385 |
# use the glibc2.28 one |
| 386 |
image: quay.io/pypa/manylinux_2_28_i686 |
| 387 |
|
| 388 |
steps: |
| 389 |
- name: Checkout and initialize submodules |
| 390 |
# actions/checkout doesn't work in a container image |
| 391 |
run: | |
| 392 |
git config --global --add safe.directory $PWD |
| 393 |
if [ $GITHUB_EVENT_NAME != pull_request ]; then |
| 394 |
git clone --recursive --branch=$GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE |
| 395 |
git reset --hard $GITHUB_SHA |
| 396 |
else |
| 397 |
git clone --recursive https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE |
| 398 |
git fetch origin $GITHUB_REF:my_ref_name |
| 399 |
git checkout $GITHUB_BASE_REF |
| 400 |
git -c user.email="[email protected]" merge --no-commit my_ref_name |
| 401 |
fi |
| 402 |
git submodule update --init --recursive |
| 403 |
|
| 404 |
- name: build |
| 405 |
run: | |
| 406 |
python3.11 -m venv venv |
| 407 |
source venv/bin/activate |
| 408 |
pip install --upgrade pip |
| 409 |
pip install -r requirements/ci32_requirements.txt |
| 410 |
pip install -r requirements/test_requirements.txt |
| 411 |
|
| 412 |
spin config-openblas --with-scipy-openblas=32 |
| 413 |
export PKG_CONFIG_PATH=$(pwd)/.openblas |
| 414 |
python -m pip install . -v -Csetup-args="-Dallow-noblas=false" |
| 415 |
|
| 416 |
- name: test |
| 417 |
run: | |
| 418 |
source venv/bin/activate |
| 419 |
cd tools |
| 420 |
python -m pytest --pyargs numpy |