name: Build_Test 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 env: DOWNLOAD_OPENBLAS: 1 PYTHON_VERSION: 3.9 concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true permissions: contents: read # to fetch code (actions/checkout) jobs: lint: if: github.repository == 'numpy/numpy' && github.event_name != 'push' runs-on: ubuntu-latest continue-on-error: true steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install linter requirements run: python -m pip install -r linter_requirements.txt - name: Run linter on PR diff run: python tools/linter.py --branch origin/${{ github.base_ref }} smoke_test: if: "github.repository == 'numpy/numpy'" runs-on: ubuntu-latest env: WITHOUT_SIMD: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions basic: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' strategy: matrix: python-version: ["3.9", "3.10", "3.11", "pypy3.9-v7.3.11"] env: EXPECT_CPU_FEATURES: "SSE SSE2 SSE3 SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL" steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ matrix.python-version }} - uses: ./.github/actions old_gcc: needs: [smoke_test] # provides GCC 7, 8 runs-on: ubuntu-20.04 if: github.event_name != 'push' steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 # comes with python3.6 - name: Install Python3.9 run: | sudo apt update # for add-apt-repository sudo apt install software-properties-common -y sudo add-apt-repository ppa:deadsnakes/ppa -y sudo apt install python3.9-dev -y sudo ln -s /usr/bin/python3.9 /usr/bin/pythonx pythonx -m pip install --upgrade pip setuptools wheel pythonx -m pip install -r test_requirements.txt - name: Install Compilers run: sudo apt install g++-7 g++-8 -y - name: Build gcc-7 run: | export CC=/usr/bin/gcc-7 export CXX=/usr/bin/g++-7 rm -rf build && pythonx setup.py install --user - name: Runtests gcc-7 run: pythonx runtests.py -n - name: Build gcc-8 run: | export CC=/usr/bin/gcc-8 export CXX=/usr/bin/g++-8 rm -rf build && pythonx setup.py install --user - name: Runtests gcc-8 run: pythonx runtests.py -n without_optimizations: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: WITHOUT_OPTIMIZATIONS: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions with_baseline_only: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: CPU_DISPATCH: "none" steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions without_avx512: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: CPU_DISPATCH: "max -xop -fma4 -avx512f -avx512cd -avx512_knl -avx512_knm -avx512_skx -avx512_clx -avx512_cnl -avx512_icl" steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions without_avx512_avx2_fma3: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: CPU_DISPATCH: "SSSE3 SSE41 POPCNT SSE42 AVX F16C" steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions debug: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: USE_DEBUG: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions blas64: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: NPY_USE_BLAS_ILP64: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions full: needs: [smoke_test] runs-on: ubuntu-22.04 env: USE_WHEEL: 1 RUN_FULL_TESTS: 1 RUN_COVERAGE: 1 INSTALL_PICKLE5: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions benchmark: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: PYTHONOPTIMIZE: 2 BLAS: None LAPACK: None ATLAS: None NPY_BLAS_ORDER: mkl,blis,openblas,atlas,blas NPY_LAPACK_ORDER: MKL,OPENBLAS,ATLAS,LAPACK USE_ASV: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions relaxed_strides_debug: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: CHECK_BLAS: 1 NPY_USE_BLAS_ILP64: 1 NPY_RELAXED_STRIDES_DEBUG: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions use_wheel: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: USE_WHEEL: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions numpy2_flag: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: # Test for numpy-2.0 feature-flagged behavior. NPY_NUMPY_2_BEHAVIOR: 1 # Using the future "weak" state doesn't pass tests # currently unfortunately NPY_PROMOTION_STATE: legacy steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions no_openblas: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: BLAS: None LAPACK: None ATLAS: None DOWNLOAD_OPENBLAS: '' steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions sdist: needs: [smoke_test] runs-on: ubuntu-latest if: github.event_name != 'push' env: USE_SDIST: 1 steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - uses: ./.github/actions armv7_simd_test: needs: [smoke_test] # make sure this matches the base docker image below runs-on: ubuntu-22.04 if: github.event_name != 'push' steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - name: Initialize binfmt_misc for qemu-user-static run: | docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - name: Creates new container run: | # use x86_64 cross-compiler to speed up the build sudo apt update sudo apt install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf # Keep the `test_requirements.txt` dependency-subset synced docker run --name the_container --interactive -v /:/host arm32v7/ubuntu:22.04 /bin/bash -c " apt update && apt install -y git python3 python3-dev python3-pip && python3 -m pip install cython==0.29.30 setuptools\<49.2.0 hypothesis==6.23.3 pytest==6.2.5 'typing_extensions>=4.2.0' && ln -s /host/lib64 /lib64 && ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu && ln -s /host/usr/arm-linux-gnueabihf /usr/arm-linux-gnueabihf && rm -rf /usr/lib/gcc/arm-linux-gnueabihf && ln -s /host/usr/lib/gcc-cross/arm-linux-gnueabihf /usr/lib/gcc/arm-linux-gnueabihf && rm -f /usr/bin/arm-linux-gnueabihf-gcc && ln -s /host/usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc && rm -f /usr/bin/arm-linux-gnueabihf-g++ && ln -s /host/usr/bin/arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++ && rm -f /usr/bin/arm-linux-gnueabihf-ar && ln -s /host/usr/bin/arm-linux-gnueabihf-ar /usr/bin/arm-linux-gnueabihf-ar && rm -f /usr/bin/arm-linux-gnueabihf-as && ln -s /host/usr/bin/arm-linux-gnueabihf-as /usr/bin/arm-linux-gnueabihf-as && rm -f /usr/bin/arm-linux-gnueabihf-ld && ln -s /host/usr/bin/arm-linux-gnueabihf-ld /usr/bin/arm-linux-gnueabihf-ld && rm -f /usr/bin/arm-linux-gnueabihf-ld.bfd && ln -s /host/usr/bin/arm-linux-gnueabihf-ld.bfd /usr/bin/arm-linux-gnueabihf-ld.bfd " docker commit the_container the_container - name: Build run: | sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c " uname -a && gcc --version && g++ --version && python3 --version && git config --global --add safe.directory /numpy cd /numpy && python3 setup.py install " docker commit the_build the_build - name: Run SIMD Tests run: | docker run --rm --interactive -v $(pwd):/numpy the_build /bin/bash -c " cd /numpy && python3 runtests.py -n -v -- -k test_simd " sde_simd_avx512_test: # Intel Software Development Emulator (SDE) is used to run a given program # on a specific instruction set architecture and capture various performance details. # see https://www.intel.com/content/www/us/en/developer/articles/tool/software-development-emulator.html needs: [smoke_test] runs-on: ubuntu-latest steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install Intel SDE run: | curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/732268/sde-external-9.7.0-2022-05-09-lin.tar.xz mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/ sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde - name: Install dependencies run: python -m pip install -r test_requirements.txt - name: Build run: python setup.py build --simd-test="\$werror AVX512F AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL" install # KNM implies KNL - name: Run SIMD tests (Xeon PHI) run: sde -knm -- python runtests.py -n -v -- -k test_simd # ICL implies SKX, CLX and CNL - name: Run SIMD tests (Ice Lake) run: sde -icl -- python runtests.py -n -v -- -k test_simd intel_spr_sde_test: needs: [smoke_test] runs-on: ubuntu-latest steps: - uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 with: submodules: recursive fetch-depth: 0 - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 with: python-version: ${{ env.PYTHON_VERSION }} - name: Install Intel SDE run: | curl -o /tmp/sde.tar.xz https://downloadmirror.intel.com/751535/sde-external-9.14.0-2022-10-25-lin.tar.xz mkdir /tmp/sde && tar -xvf /tmp/sde.tar.xz -C /tmp/sde/ sudo mv /tmp/sde/* /opt/sde && sudo ln -s /opt/sde/sde64 /usr/bin/sde - name: Install dependencies run: | python -m pip install -r test_requirements.txt sudo apt install gcc-12 g++-12 - name: Build and install NumPy run: | export CC=/usr/bin/gcc-12 export CXX=/usr/bin/g++-12 python -m pip install -e . # Run only a few tests, running everything in an SDE takes a long time # Using pytest directly, unable to use python runtests.py -n -t ... - name: Run linalg/ufunc/umath tests run: | sde -spr -- python -m pytest numpy/core/tests/test_umath* numpy/core/tests/test_ufunc.py numpy/linalg/tests/test_*