Skip to content

ci: migrate to Miniforge and restore GPU tests #106

ci: migrate to Miniforge and restore GPU tests

ci: migrate to Miniforge and restore GPU tests #106

name: pypi
permissions:
contents: read
on:
release:
types: [published]
push:
branches: [main]
paths:
- "buildscripts/cibuildwheel/**"
- "buildscripts/modal/**"
- ".github/workflows/build-upload-wheels.yml"
- "src/**"
- setup.py
- MANIFEST.in
- pyproject.toml
pull_request:
paths:
- "buildscripts/cibuildwheel/**"
- "buildscripts/modal/**"
- ".github/workflows/build-upload-wheels.yml"
- "src/**"
- setup.py
- MANIFEST.in
- pyproject.toml
workflow_dispatch:
jobs:
# Always runs: Build wheels for all platforms and upload artifacts.
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# TODO: Add windows.
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
# Checkout the repo with history to get the commit hash for the build
# string.
with:
fetch-depth: 0
# Used to host cibuildwheel.
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==3.3.1
- name: Build wheels {{ matrix.os }}
# Set LLVM_VERSION for the host to forward to the cibuildwheel
# environment.
env:
LLVM_VERSION: "20.1.8"
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 0
- name: Build sdist
env:
LLVM_VERSION: "20.1.8"
run: pipx run build --sdist
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: cibw-sdist
path: dist/*.tar.gz
# Always runs: Test wheels across OS/Python/Numba matrix.
test-wheels:
needs: build-wheels
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
numba-version: ['0.62.0', '0.62.1', '0.63.0', '0.63.1']
exclude:
- python-version: '3.14'
numba-version: '0.62.0'
- python-version: '3.14'
numba-version: '0.62.1'
steps:
- name: Download built wheels
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: ${{ matrix.python-version }}
- name: Install and test wheel
run: |
python -m pip install --upgrade pip
python -m pip install "numba==${{ matrix.numba-version }}" lark cffi setuptools
python -m pip install --pre --no-deps --no-index --find-links dist/ pyomp
# Verify the numba version.
python -c "import numba; assert numba.__version__ == '${{ matrix.numba-version }}'"
# Run host OpenMP tests.
RUN_TARGET=0 python -m numba.runtests -v -- numba.openmp.tests.test_openmp
# Run device (cpu target) OpenMP tests.
OMP_TARGET_OFFLOAD=mandatory TEST_DEVICE=host RUN_TARGET=1 \
python -m numba.runtests -v -- numba.openmp.tests.test_openmp.TestOpenmpTarget
# Test Linux wheels on a real NVIDIA GPU. Fork PRs run after merging to main,
# where Modal credentials are available to trusted code.
test-modal-gpu:
needs: build-wheels
if: >-
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
concurrency:
group: modal-gpu-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Download Linux wheels
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
pattern: cibw-wheels-ubuntu-latest-*
path: dist
merge-multiple: true
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.12"
- name: Validate Modal credentials
shell: bash
run: |
if [[ -z "$MODAL_TOKEN_ID" || -z "$MODAL_TOKEN_SECRET" ]]; then
echo "::error::MODAL_TOKEN_ID and MODAL_TOKEN_SECRET must be configured"
exit 1
fi
- name: Run GPU tests on Modal
run: |
python -m pip install modal==1.5.3
set +e
timeout --signal=TERM --kill-after=30s 20m \
modal run --timestamps buildscripts/modal/test_gpu.py
modal_status=$?
set -e
if [[ $modal_status -eq 124 ]]; then
echo "::error::Modal GPU tests exceeded the 20-minute timeout"
exit 1
fi
exit "$modal_status"
# Only on pre-release: Publish to TestPyPI for testing.
publish-testpypi:
needs: [build-wheels, test-wheels, test-modal-gpu, build-sdist]
if: github.event.release.prerelease
runs-on: ubuntu-latest
environment: testpypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish testpypi
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
# Only on full release: Publish to production PyPI.
publish-pypi:
needs: [build-wheels, test-wheels, test-modal-gpu, build-sdist]
if: github.event_name == 'release' && !github.event.release.prerelease
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
pattern: cibw-*
path: dist
merge-multiple: true
- name: Publish pypi
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
with:
verbose: true