Skip to content

Commit

Permalink
Merge pull request #2824 from ericpre/add_extension_CI_on_label
Browse files Browse the repository at this point in the history
Run extension test suite from PR
  • Loading branch information
ericpre committed Sep 9, 2021
2 parents 8c74de8 + 5f416de commit a030666
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 2 deletions.
85 changes: 85 additions & 0 deletions .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
4 changes: 3 additions & 1 deletion doc/dev_guide/testing.rst
Expand Up @@ -179,6 +179,8 @@ The testing matrix is as follows:
all dependencies are installed from `Anaconda Cloud <https://anaconda.org/>`_
using the `"conda-forge" <https://anaconda.org/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 <integration_test_suite-label>` 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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion doc/dev_guide/writing_extensions.rst
Expand Up @@ -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
Expand Down Expand Up @@ -421,3 +421,8 @@ at the time of writing.
The pre-release packages are obtained from `pypi <https://pypi.org>`_ and these
will be used for any dependency which provides a pre-release package on pypi.
A similar `Integration test <https://github.com/hyperspy/hyperspy/actions/workflows/tests_extension.yml>`__
workflow can run from pull requests (PR) to the
`hyperspy <https://github.com/hyperspy/hyperspy>`_ repository when the label
``run-extension-tests`` is added to a PR or when a PR review is edited.
1 change: 1 addition & 0 deletions upcoming_changes/2824.enhancements.rst
@@ -0,0 +1 @@
Add Github workflow to run test suite of extension from a pull request.

0 comments on commit a030666

Please sign in to comment.