diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..8f310b1 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,72 @@ +name: Run Tests + +on: + pull_request: + schedule: + - cron: '0 6 * * 1' # Every Monday at 06:00 UTC + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ['3.10', '3.11', '3.12', '3.13'] + include: + # Windows builds require mingw/gcc (MSVC cannot compile the AVX intrinsics). + # Use conda + m2w64-toolchain to match the wheel build workflow. + - os: windows-latest + python-version: '3.10' + - os: windows-latest + python-version: '3.11' + - os: windows-latest + python-version: '3.12' + - os: windows-latest + python-version: '3.13' + + steps: + - uses: actions/checkout@v4 + + # --- Linux / macOS: plain pip install --- + - name: Set up Python ${{ matrix.python-version }} (non-Windows) + if: runner.os != 'Windows' + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install build dependencies (non-Windows) + if: runner.os != 'Windows' + run: pip install meson-python meson ninja numpy cython pytest + + - name: Build and install (non-Windows) + if: runner.os != 'Windows' + run: pip install . --no-build-isolation + + # --- Windows: conda + mingw so gcc is used instead of MSVC --- + - name: Set up conda + Python ${{ matrix.python-version }} (Windows) + if: runner.os == 'Windows' + uses: conda-incubator/setup-miniconda@v3 + with: + python-version: ${{ matrix.python-version }} + auto-activate-base: false + activate-environment: test + + - name: Install build dependencies (Windows) + if: runner.os == 'Windows' + shell: bash -el {0} + run: | + conda install -y numpy cython libpython m2w64-toolchain + pip install meson-python meson ninja pytest + + - name: Build and install (Windows) + if: runner.os == 'Windows' + shell: bash -el {0} + run: | + pip install . --no-build-isolation \ + -Csetup-args="--native-file=${{ github.workspace }}/mingw_native.ini" + + # --- Run tests --- + - name: Run tests + shell: bash -el {0} + run: pytest test_pymecompress.py -v diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index ae821c3..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Python Package using Conda - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v3 - with: - python-version: 3.8 - - name: Add conda to system path - run: | - # $CONDA is an environment variable pointing to the root of the miniconda directory - echo $CONDA/bin >> $GITHUB_PATH - - name: Install dependencies - run: | - #conda env update --file environment.yml --name base - conda install numpy cython - - name: Lint with flake8 - run: | - conda install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Build extensions - run: | - python setup.py build_ext -i - - name: Test with pytest - run: | - conda install pytest - pytest diff --git a/README.md b/README.md index 6137325..d5b2b36 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # PYMECompress -![testing](https://github.com/python-microscocopy/pymecompress/actions/workflows/test.yml/badge.svg) +![testing](https://github.com/python-microscopy/pymecompress/actions/workflows/pytest.yml/badge.svg) ![conda](https://img.shields.io/conda/v/david_baddeley/pymecompress) ![pypi](https://img.shields.io/pypi/v/pymecompress) ![pyversions](https://img.shields.io/pypi/pyversions/pymecompress) diff --git a/pyproject.toml b/pyproject.toml index 37648f2..f0eb4c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,3 +21,6 @@ classifiers = [ [project.urls] "Homepage" = "https://github.com/python-microscopy/pymecompress" + +[tool.pytest.ini_options] +addopts = "--import-mode=importlib"