Skip to content

MNT: Resurrect tox config to cover dev workflows and CI checks #60

MNT: Resurrect tox config to cover dev workflows and CI checks

MNT: Resurrect tox config to cover dev workflows and CI checks #60

Workflow file for this run

name: Build and test
# This file tests the claimed support range of NiBabel including
#
# * Operating systems: Linux, Windows (x64 & x86), OSX
# * Dependencies: minimum requirements, optional requirements
# * Installation methods: setup.py, sdist, wheel, archive
on:
push:
branches:
- master
- maint/*
tags:
- "*"
pull_request:
branches:
- master
- maint/*
schedule:
- cron: '0 0 * * 1'
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3
- run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
- name: Build git archive
run: mkdir archive && git archive -v -o archive/nibabel-archive.tgz HEAD
- name: Upload sdist and wheel artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
- name: Upload git archive artifact
uses: actions/upload-artifact@v3
with:
name: archive
path: archive/
test-package:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist', 'archive']
steps:
- name: Download sdist and wheel artifacts
if: matrix.package != 'archive'
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Download git archive artifact
if: matrix.package == 'archive'
uses: actions/download-artifact@v3
with:
name: archive
path: archive/
- uses: actions/setup-python@v4
with:
python-version: 3
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: pip install --upgrade pip
- name: Install wheel
if: matrix.package == 'wheel'
run: pip install dist/nibabel-*.whl
- name: Install sdist
if: matrix.package == 'sdist'
run: pip install dist/nibabel-*.tar.gz
- name: Install archive
if: matrix.package == 'archive'
run: pip install archive/nibabel-archive.tgz
- run: python -c 'import nibabel; print(nibabel.__version__)'
- name: Install minimum test dependencies
run: pip install nibabel[test]
- name: Run tests
run: pytest --doctest-modules --doctest-plus -v --pyargs nibabel -n auto
test:
# Check each OS, all supported Python, minimum versions and latest releases
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.dependencies == 'pre' }}
strategy:
fail-fast: false
matrix:
os: ['windows-latest']
python-version: [3.9, "3.10", "3.11"]
architecture: ['x86']
dependencies: ['full']
env:
DEPENDS: ${{ matrix.dependencies }}
ARCH: ${{ !contains(fromJSON('["none", "min"]'), matrix.dependencies) && matrix.architecture }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
allow-prereleases: true
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Debug hanging dependency installation
run: python -I -m pip install -v --only-binary numpy,scipy,h5py,pillow --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple indexed_gzip>=1.4 matplotlib>=3.4 pillow>=8.1 pydicom>=2.1 pyzstd>=0.14.3 scipy>=1.6
- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Show tox config
run: tox c
- name: Run tox
run: tox -v --exit-and-dump-after 1200
- uses: codecov/codecov-action@v3
if: ${{ always() }}
with:
files: cov.xml
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: test-results.xml
if: ${{ always() }}
publish:
runs-on: ubuntu-latest
environment: "Package deployment"
needs: [test, test-package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}