| 1 |
name: macOS tests |
| 2 |
|
| 3 |
on: |
| 4 |
pull_request: |
| 5 |
branches: |
| 6 |
- main |
| 7 |
- maintenance/** |
| 8 |
paths-ignore: |
| 9 |
- '**.pyi' |
| 10 |
- '**.md' |
| 11 |
- '**.rst' |
| 12 |
|
| 13 |
permissions: |
| 14 |
contents: read # to fetch code (actions/checkout) |
| 15 |
|
| 16 |
env: |
| 17 |
CCACHE_DIR: "${{ github.workspace }}/.ccache" |
| 18 |
|
| 19 |
concurrency: |
| 20 |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 21 |
cancel-in-progress: true |
| 22 |
|
| 23 |
jobs: |
| 24 |
x86_conda: |
| 25 |
name: macOS x86-64 conda |
| 26 |
# To enable this workflow on a fork, comment out: |
| 27 |
if: github.repository == 'numpy/numpy' |
| 28 |
runs-on: macos-15-intel |
| 29 |
strategy: |
| 30 |
fail-fast: false |
| 31 |
matrix: |
| 32 |
python-version: ["3.12"] |
| 33 |
|
| 34 |
steps: |
| 35 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 36 |
with: |
| 37 |
submodules: recursive |
| 38 |
fetch-tags: true |
| 39 |
persist-credentials: false |
| 40 |
|
| 41 |
- name: Prepare cache dirs and timestamps |
| 42 |
id: prep-ccache |
| 43 |
shell: bash -l {0} |
| 44 |
run: | |
| 45 |
mkdir -p "${CCACHE_DIR}" |
| 46 |
echo "dir=$CCACHE_DIR" >> $GITHUB_OUTPUT |
| 47 |
NOW=$(date -u +"%F-%T") |
| 48 |
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT |
| 49 |
echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT |
| 50 |
|
| 51 |
- name: Setup compiler cache |
| 52 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 53 |
id: cache-ccache |
| 54 |
with: |
| 55 |
path: ${{ steps.prep-ccache.outputs.dir }} |
| 56 |
key: ${{ github.workflow }}-${{ matrix.python-version }}-ccache-macos-${{ steps.prep-ccache.outputs.timestamp }} |
| 57 |
restore-keys: | |
| 58 |
${{ github.workflow }}-${{ matrix.python-version }}-ccache-macos- |
| 59 |
|
| 60 |
- name: Setup Miniforge |
| 61 |
uses: conda-incubator/setup-miniconda@835234971496cad1653abb28a638a281cf32541f # v3.2.0 |
| 62 |
with: |
| 63 |
python-version: ${{ matrix.python-version }} |
| 64 |
channels: conda-forge |
| 65 |
channel-priority: true |
| 66 |
activate-environment: numpy-dev |
| 67 |
use-only-tar-bz2: false |
| 68 |
miniforge-variant: Miniforge3 |
| 69 |
miniforge-version: latest |
| 70 |
use-mamba: true |
| 71 |
|
| 72 |
# Updates if `environment.yml` or the date changes. The latter is needed to |
| 73 |
# ensure we re-solve once a day (since we don't lock versions). Could be |
| 74 |
# replaced by a conda-lock based approach in the future. |
| 75 |
- name: Cache conda environment |
| 76 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 77 |
env: |
| 78 |
# Increase this value to reset cache if environment.yml has not changed |
| 79 |
CACHE_NUMBER: 1 |
| 80 |
with: |
| 81 |
path: ${{ env.CONDA }}/envs/numpy-dev |
| 82 |
key: |
| 83 |
${{ runner.os }}--${{ steps.prep-ccache.outputs.today }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} |
| 84 |
id: envcache |
| 85 |
|
| 86 |
- name: Update Conda Environment |
| 87 |
run: mamba env update -n numpy-dev -f environment.yml |
| 88 |
if: steps.envcache.outputs.cache-hit != 'true' |
| 89 |
|
| 90 |
- name: Build and Install NumPy |
| 91 |
shell: bash -l {0} |
| 92 |
run: | |
| 93 |
conda activate numpy-dev |
| 94 |
CC="ccache $CC" spin build -j2 -- -Dallow-noblas=false |
| 95 |
|
| 96 |
- name: Run test suite (full) |
| 97 |
shell: bash -l {0} |
| 98 |
run: | |
| 99 |
conda activate numpy-dev |
| 100 |
export OMP_NUM_THREADS=2 |
| 101 |
spin test -j2 -m full |
| 102 |
|
| 103 |
- name: Ccache statistics |
| 104 |
shell: bash -l {0} |
| 105 |
run: | |
| 106 |
conda activate numpy-dev |
| 107 |
ccache -s |
| 108 |
|
| 109 |
|
| 110 |
accelerate: |
| 111 |
name: Accelerate - ${{ matrix.build_runner[1] }} - ${{ matrix.version }} |
| 112 |
# To enable this workflow on a fork, comment out: |
| 113 |
if: github.repository == 'numpy/numpy' |
| 114 |
runs-on: ${{ matrix.build_runner[0] }} |
| 115 |
strategy: |
| 116 |
fail-fast: false |
| 117 |
matrix: |
| 118 |
build_runner: |
| 119 |
- [ macos-15-intel, "macos_x86_64" ] |
| 120 |
- [ macos-14, "macos_arm64" ] |
| 121 |
version: ["3.11", "3.14t"] |
| 122 |
|
| 123 |
steps: |
| 124 |
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 125 |
with: |
| 126 |
submodules: recursive |
| 127 |
fetch-tags: true |
| 128 |
persist-credentials: false |
| 129 |
|
| 130 |
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 |
| 131 |
with: |
| 132 |
python-version: ${{ matrix.version }} |
| 133 |
|
| 134 |
- name: Install dependencies |
| 135 |
run: | |
| 136 |
pip install -r requirements/build_requirements.txt -r requirements/test_requirements.txt |
| 137 |
|
| 138 |
- name: Build against Accelerate (LP64) |
| 139 |
run: spin build -- -Ddisable-optimization=true -Dallow-noblas=false |
| 140 |
|
| 141 |
- name: Test (linalg only) |
| 142 |
run: spin test -j2 -- numpy/linalg --timeout=600 --durations=10 |
| 143 |
|
| 144 |
- name: Build NumPy against Accelerate (ILP64) |
| 145 |
run: | |
| 146 |
rm -r build build-install |
| 147 |
spin build -- -Duse-ilp64=true -Ddisable-optimization=true -Dallow-noblas=false |
| 148 |
|
| 149 |
- name: Test (fast tests) |
| 150 |
if: ${{ matrix.version != '3.14t' || matrix.build_runner[0] != 'macos-14' }} |
| 151 |
run: spin test -j2 -- --timeout=600 --durations=10 |
| 152 |
|
| 153 |
- name: Test in multiple threads |
| 154 |
if: ${{ matrix.version == '3.14t' && matrix.build_runner[0] == 'macos-14' }} |
| 155 |
run: | |
| 156 |
pip install pytest-run-parallel==0.7.0 |
| 157 |
spin test -p 4 -- --timeout=600 --durations=10 |