Skip to content

unit-tests

unit-tests #719

Workflow file for this run

name: gh-ci-checks
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }}
cancel-in-progress: true
on:
pull_request:
push:
branches: [main, maint/0.2, maint/0.3]
tags:
- "v*.*.*"
paths:
- "**.py"
workflow_dispatch:
schedule:
- cron: '0 8 * * 1'
jobs:
style:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[style]
- name: Run flake8
uses: py-actions/flake8@v2
with:
path: "mne_icalabel"
- name: Run isort
uses: isort/isort-action@master
- name: Run black
uses: psf/black@stable
with:
options: "--check --verbose"
- name: Run codespell
uses: codespell-project/actions-codespell@master
with:
check_filenames: true
check_hidden: true
skip: "./.git,./build,./.mypy_cache,./.pytest_cache,./mne_icalabel/iclabel/network/assets"
ignore_words_file: ./.codespellignore
- name: Run pydocstyle
run: pydocstyle .
- name: Run mypy
uses: jpetrucciani/mypy-check@master
with:
path: "./mne_icalabel"
mypy_flags: "--config-file pyproject.toml"
- name: Run bibclean
run: bibclean-check doc/references.bib
build:
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.8, 3.9, "3.10", "3.11"]
name: build ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[build]
- name: Test package install
run: python -c "import mne_icalabel; print(mne_icalabel.__version__)"
- name: Remove package install
run: python -m pip uninstall -yq mne_icalabel
- name: Build package
run: python -m build
- name: Upload package distribution files
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v3
with:
name: package
path: dist
- name: Install sdist
run: pip install ./dist/*.tar.gz
- name: Test sdist install
run: python -c "import mne_icalabel; print(mne_icalabel.__version__)"
- name: Remove sdist install
run: python -m pip uninstall -yq mne_icalabel
- name: Install wheel
run: pip install ./dist/*.whl
- name: Test wheel install
run: python -c "import mne_icalabel; print(mne_icalabel.__version__)"
- name: Remove wheel install
run: python -m pip uninstall -yq mne_icalabel
test:
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.8, "3.11"] # oldest and newest supported versions
mne: [stable, main]
name: pytest ${{ matrix.os }} - py${{ matrix.python-version }} - MNE ${{ matrix.mne }}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: main # clone repository in a sub-directory
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Setup headless display
uses: pyvista/setup-headless-display-action@main
with:
qt: true
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off main/.[test]
# We install both MNE Python and BIDS to be in-line with their latest version
- name: Install MNE (main)
if: "matrix.mne == 'main'"
run: |
python -m pip uninstall -yq mne
python -m pip install git+https://github.com/mne-tools/mne-python
python -m pip install git+https://github.com/mne-tools/mne-bids
- name: Display MNE infos
run: mne sys_info
- name: Retrieve MNE/MNE-ICALabel testing dataset version
run: |
curl https://raw.githubusercontent.com/mne-tools/mne-testing-data/master/version.txt -o mne_testing_data_version.txt
curl https://raw.githubusercontent.com/adam2392/mne-testing-icalabel-data/main/version.txt -o mne_icalabel_testing_data_version.txt
- name: Cache MNE/ICA-Label testing dataset
uses: actions/cache@v3
with:
key: ${{ matrix.os }}-${{ matrix.mne }}-${{ hashFiles('mne_testing_data_version.txt') }}-${{ hashFiles('mne_icalabel_testing_data_version.txt') }}
path: ~/mne_data
- name: Download MNE/MNE-ICALabel testing dataset
run: |
python -c "import mne; mne.datasets.testing.data_path()"
python -c "import mne_icalabel; mne_icalabel.datasets.icalabel.data_path()"
- name: Run pytest
run: pytest main/mne_icalabel --cov=main/mne_icalabel --cov-report=xml --cov-config=main/pyproject.toml
- name: Upload coverage stats to codecov
if: ${{ matrix.os == 'ubuntu' && matrix.python-version == '3.10' && matrix.mne == 'stable' }}
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
# release is ran when a release is made on Github
release:
name: Release
runs-on: ubuntu-latest
needs: [style, build, test]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.9
architecture: "x64"
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[build]
- name: Prepare environment
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download package distribution files
uses: actions/download-artifact@v3
with:
name: package
path: dist
# TODO: refactor scripts to generate release notes from `whats_new.rst` file instead
# - name: Generate release notes
# run: |
# python scripts/release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
- name: Publish package to PyPI
run: |
twine upload -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} dist/*
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, 'rc') }}
files: |
dist/*