Skip to content

Merge pull request #457 from InsightSoftwareConsortium/blowekamp-patch-1 #190

Merge pull request #457 from InsightSoftwareConsortium/blowekamp-patch-1

Merge pull request #457 from InsightSoftwareConsortium/blowekamp-patch-1 #190

Workflow file for this run

name: Main Testing
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- master
paths-ignore:
- '**.md'
concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install and run black for notebooks
run: |
python -m pip install --upgrade pip
python -m pip install black[jupyter]
black --check --diff --verbose Python
test:
needs: lint
strategy:
matrix: #using macos-13 because pyenchant doesn't work on macos-latest (macos 14, arm64 architecture)
os: [macos-13, windows-latest, ubuntu-latest]
python-version: ['3.8', '3.11']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history for all branches, required for the changed-files action
- uses: actions/cache@v4
id: cache
with:
path: |
Data
key: notebook-data-${{ hashFiles('Data/manifest.json') }}
restore-keys: |
notebook-data-${{ hashFiles('Data/manifest.json') }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# on windows, the pyenchant package includes enchant
- name: Install enchant on non windows systems
shell: bash
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install enchant-2
elif [ "$RUNNER_OS" == "macOS" ]; then
brew update-reset
brew install enchant
fi
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
- name: Download data
if: steps.cache.outputs.cache-hit != 'true'
run: python Utilities/downloaddata.py Data/ Data/manifest.json
- name: Get list of Python notebooks to test
id: nbl
uses: tj-actions/changed-files@v45
with:
files: Python/*.ipynb
- name: Run the notebooks test
shell: bash
if: steps.nbl.outputs.any_changed == 'true'
env:
SIMPLE_ITK_MEMORY_CONSTRAINED_ENVIRONMENT: 1
run: |
test_files="${{ steps.nbl.outputs.all_changed_files }}"
# on windows the paths use backslashes, so replace with forward slashes
if [ "$RUNNER_OS" == "Windows" ]; then
test_files="${test_files//\\//}"
fi
for nb_file in ${test_files}; do
# the substring contains the file paths, extract the basename for usage with pytest
pytest -v --tb=short tests/test_notebooks.py::Test_notebooks::test_python_notebook["${nb_file##*/}"]
done
- name: Run the scripts test
env:
SIMPLE_ITK_MEMORY_CONSTRAINED_ENVIRONMENT: 1
run: |
pytest -v --tb=short tests/test_scripts.py