diff --git a/.github/workflows/tests_extension.yml b/.github/workflows/tests_extension.yml new file mode 100644 index 0000000000..b85fec7604 --- /dev/null +++ b/.github/workflows/tests_extension.yml @@ -0,0 +1,85 @@ +name: Integration tests + +on: + workflow_dispatch: + workflow: "*" + label: + types: [created] + pull_request_review: + types: [submitted, edited] + +jobs: + integration_test: + if: ${{ github.event.review || github.event.label.name == 'run-extension-tests' }} + name: Extension_${{ matrix.EXTENSION_VERSION }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + EXTENSION_VERSION: ['release', 'dev'] + + env: + MPLBACKEND: agg + EXTENSION: kikuchipy lumispy pyxem atomap + TEST_DEPS: pytest pytest-xdist pytest-rerunfailures pytest-instafail + defaults: + run: + shell: bash -l {0} + + steps: + - uses: actions/checkout@v2 + + - uses: conda-incubator/setup-miniconda@master + with: + miniforge-variant: Mambaforge + miniforge-version: latest + # use base environment, so that when using pip, this is from the + # mambaforge distribution + auto-activate-base: true + activate-environment: "" + + - name: Conda info + run: | + conda info + conda list + + - name: Install extensions and Test dependencies + run: | + mamba install hyperspy-base ${{ env.EXTENSION }} ${{ env.TEST_DEPS }} + + - name: Conda list + run: | + conda list + + - name: Install HyperSpy + run: | + pip install . + + - name: Install Extension Dev + if: contains(matrix.EXTENSION_VERSION, 'dev') + run: | + pip install https://github.com/lumispy/lumispy/archive/main.zip + pip install https://github.com/pyxem/kikuchipy/archive/develop.zip + pip install https://github.com/pyxem/pyxem/archive/master.zip + pip install https://https://gitlab.com/atomap/atomap/-/archive/master/atomap-master.zip + + - name: Run Kikuchipy Test Suite + if: ${{ always() }} + run: | + python -m pytest --pyargs kikuchipy + + - name: Run LumiSpy Test Suite + if: ${{ always() }} + run: | + python -m pytest --pyargs lumispy + + - name: Run Pyxem Test Suite + if: ${{ always() }} + run: | + python -m pytest --pyargs pyxem + + # atomap test suite doesn't run headless + #- name: Run atomap Test Suite + # if: ${{ always() }} + # run: | + # python -m pytest --pyargs atomap diff --git a/doc/dev_guide/testing.rst b/doc/dev_guide/testing.rst index e959367363..23fec2bfce 100644 --- a/doc/dev_guide/testing.rst +++ b/doc/dev_guide/testing.rst @@ -179,6 +179,8 @@ The testing matrix is as follows: all dependencies are installed from `Anaconda Cloud `_ using the `"conda-forge" `_ channel. See ``azure-pipelines.yml`` in the HyperSpy repository for further details. +- The testing of **HyperSpy extensions** is described in the + :ref:`integration test suite ` section. This testing matrix has been designed to be simple and easy to maintain, whilst ensuring that packages from PyPI and Anaconda cloud are not mixed in order to @@ -220,7 +222,7 @@ tests. The reference images are located in the folder defined by the argument To run plot tests, you simply need to add the option ``--mpl``: -:: code:: bash +.. code:: bash $ pytest --mpl diff --git a/doc/dev_guide/writing_extensions.rst b/doc/dev_guide/writing_extensions.rst index e9ba0fd366..a5e23c6138 100644 --- a/doc/dev_guide/writing_extensions.rst +++ b/doc/dev_guide/writing_extensions.rst @@ -26,7 +26,7 @@ data. Models can also be provided by external packages, but don't need to be registered. Instead, they are returned by the ``create_model`` method of the relevant :py:class:`hyperspy.signal.BaseSignal` subclass, see for example, -the :py:meth:`hyperspy._signals.eds_tem.EDSTEM_mixin.create_model` of the +the :py:meth:`~._signals.eds_tem.EDSTEMSpectrum.create_model` of the :py:class:`~._signals.eds_tem.EDSTEMSpectrum`. It is good practice to add all packages that extend HyperSpy @@ -421,3 +421,8 @@ at the time of writing. The pre-release packages are obtained from `pypi `_ and these will be used for any dependency which provides a pre-release package on pypi. +A similar `Integration test `__ +workflow can run from pull requests (PR) to the +`hyperspy `_ repository when the label +``run-extension-tests`` is added to a PR or when a PR review is edited. + diff --git a/upcoming_changes/2824.enhancements.rst b/upcoming_changes/2824.enhancements.rst new file mode 100644 index 0000000000..d33ecca984 --- /dev/null +++ b/upcoming_changes/2824.enhancements.rst @@ -0,0 +1 @@ +Add Github workflow to run test suite of extension from a pull request.