Skip to content

Merge pull request #27653 from jorenham/typing/ndarray-array-api #18

Merge pull request #27653 from jorenham/typing/ndarray-array-api

Merge pull request #27653 from jorenham/typing/ndarray-array-api #18

Workflow file for this run

name: Linux tests
# This file is meant for testing across supported Python versions, build types
# and interpreters (PyPy, python-dbg, a pre-release Python in summer time),
# build-via-sdist, run benchmarks, measure code coverage, and other build
# options.
on:
push:
branches:
# coverage comparison in the "full" step needs to run on main after merges
- main
pull_request:
branches:
- main
- maintenance/**
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
lint:
# To enable this job and subsequent jobs on a fork, comment out:
if: github.repository == 'numpy/numpy' && github.event_name != 'push'
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
- name: Install linter requirements
run:
python -m pip install -r requirements/linter_requirements.txt
- name: Run linter on PR diff
run:
python tools/linter.py --branch origin/${{ github.base_ref }}
smoke_test:
# To enable this job on a fork, comment out:
if: github.repository == 'numpy/numpy'
runs-on: ubuntu-latest
env:
MESON_ARGS: "-Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none"
strategy:
matrix:
version: ["3.10", "3.11", "3.12", "3.13-dev"]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ matrix.version }}
- uses: ./.github/meson_actions
pypy:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 'pypy3.10-v7.3.17'
- name: Setup using scipy-openblas
run: |
python -m pip install -r requirements/ci_requirements.txt
spin config-openblas --with-scipy-openblas=32
- uses: ./.github/meson_actions
debug:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- name: Install debug Python
run: |
sudo apt-get update
sudo apt-get install python3-dbg ninja-build
- name: Build NumPy and install into venv
run: |
python3-dbg -m venv venv
source venv/bin/activate
pip install -U pip
pip install . -v -Csetup-args=-Dbuildtype=debug -Csetup-args=-Dallow-noblas=true
- name: Install test dependencies
run: |
source venv/bin/activate
pip install -r requirements/test_requirements.txt
- name: Run test suite
run: |
source venv/bin/activate
cd tools
pytest --pyargs numpy -m "not slow"
full:
# Install as editable, then run the full test suite with code coverage
needs: [smoke_test]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
- name: Install build and test dependencies from PyPI
run: |
pip install -r requirements/build_requirements.txt
pip install -r requirements/test_requirements.txt
- name: Install gfortran and setup OpenBLAS (MacPython build)
run: |
set -xe
sudo apt update
sudo apt install gfortran libgfortran5
python -m pip install -r requirements/ci32_requirements.txt
mkdir -p ./.openblas
python -c"import scipy_openblas32 as ob32; print(ob32.get_pkg_config())" > ./.openblas/scipy-openblas.pc
- name: Install as editable
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
run: |
pip install -e . --no-build-isolation
- name: Run full test suite
run: |
pytest numpy --cov-report=html:build/coverage
# TODO: gcov
benchmark:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.10'
- name: Install build and benchmarking dependencies
run: |
sudo apt-get update
sudo apt-get install libopenblas-dev ninja-build
pip install asv virtualenv packaging -r requirements/build_requirements.txt
- name: Install NumPy
run: |
spin build -- -Dcpu-dispatch=none
# Ensure to keep the below steps as single-line bash commands (it's a
# workaround for asv#1333, and it may have side-effects on multi-line commands)
- name: Appease asv's need for machine info
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
asv machine --yes --config benchmarks/asv.conf.json
- name: Run benchmarks
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
spin bench --quick
- name: Check docstests
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
run: |
pip install scipy-doctest hypothesis matplotlib scipy pytz pandas
spin check-docs -v
spin check-tutorials -v
sdist:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.11'
- name: Install gfortran and setup OpenBLAS (sdist build)
run: |
set -xe
python -m pip install -r requirements/ci_requirements.txt
mkdir -p ./.openblas
python -c"import scipy_openblas64 as ob64; print(ob64.get_pkg_config())" > ./.openblas/scipy-openblas.pc
- name: Build a wheel via an sdist
env:
PKG_CONFIG_PATH: ${{ github.workspace }}/.openblas
run: |
pip install build
python -m build
pip install dist/numpy*.whl
- name: Install test dependencies
run: |
pip install -r requirements/test_requirements.txt
- name: Run test suite
run: |
cd tools
pytest --pyargs numpy -m "not slow"
array_api_tests:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- name: Checkout NumPy
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- name: Checkout array-api-tests
uses: actions/checkout@v4
with:
repository: data-apis/array-api-tests
ref: '827edd804bcace9d64176b8115138d29ae3e8dec' # Latest commit as of 2024-07-30
submodules: 'true'
path: 'array-api-tests'
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.11'
- name: Install build and test dependencies from PyPI
run: |
python -m pip install -r requirements/build_requirements.txt
python -m pip install -r requirements/test_requirements.txt
python -m pip install -r array-api-tests/requirements.txt
- name: Build and install NumPy
run: |
python -m pip install . -v -Csetup-args=-Dallow-noblas=true -Csetup-args=-Dcpu-baseline=none -Csetup-args=-Dcpu-dispatch=none
- name: Run the test suite
env:
ARRAY_API_TESTS_MODULE: numpy
PYTHONWARNINGS: 'ignore::UserWarning::,ignore::DeprecationWarning::,ignore::RuntimeWarning::'
run: |
cd ${GITHUB_WORKSPACE}/array-api-tests
pytest array_api_tests -v -c pytest.ini --ci --max-examples=100 --derandomize --disable-deadline --xfails-file ${GITHUB_WORKSPACE}/tools/ci/array-api-xfails.txt
custom_checks:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.11'
- name: Install build and test dependencies from PyPI
run: |
pip install -r requirements/build_requirements.txt
pip install -r requirements/test_requirements.txt
pip install vulture
- name: Build and install NumPy
run: |
# Install using the fastest way to build (no BLAS, no SIMD)
spin build -j2 -- -Dallow-noblas=true -Dcpu-baseline=none -Dcpu-dispatch=none
- name: Check build-internal dependencies
run: |
ninja -C build -t missingdeps
- name: Check installed test and stub files
run: |
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy')
- name: Check for unreachable code paths in Python modules
run: |
# Need the explicit `bash -c` here because `grep` returns exit code 1 for no matches
bash -c "! vulture . --min-confidence 100 --exclude doc/,numpy/distutils/,vendored-meson/ | grep 'unreachable'"
- name: Check usage of install_tag
run: |
rm -rf build-install
./vendored-meson/meson/meson.py install -C build --destdir ../build-install --tags=runtime,python-runtime,devel
python tools/check_installed_files.py $(find ./build-install -path '*/site-packages/numpy') --no-tests
free-threaded:
needs: [smoke_test]
runs-on: ubuntu-latest
if: github.event_name != 'push'
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive
fetch-tags: true
# TODO: replace with setup-python when there is support
- uses: deadsnakes/action@e640ac8743173a67cca4d7d77cd837e514bf98e8 # v3.2.0
with:
python-version: '3.13-dev'
nogil: true
# TODO: remove cython nightly install when cython does a release
- name: Install nightly Cython
run: |
pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple cython
- uses: ./.github/meson_actions