From cd41412b14f32d03a58fe9a1ea7ef8f60776a0b8 Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 14:25:54 +0100 Subject: [PATCH 1/7] Add workflow to run testsuite of extension when the label "run-extension-tests" or when a pull request review is edited --- .github/workflows/tests_extension.yml | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/tests_extension.yml diff --git a/.github/workflows/tests_extension.yml b/.github/workflows/tests_extension.yml new file mode 100644 index 0000000000..ef6e6afe1e --- /dev/null +++ b/.github/workflows/tests_extension.yml @@ -0,0 +1,78 @@ +name: Integration tests + +on: + workflow_dispatch: + workflow: "*" + label: + types: [created] + pull_request_review: + types: [edited] + +jobs: + integration_test: + if: ${{ 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 --no-deps + pip install https://github.com/pyxem/kikuchipy/archive/main.zip --no-deps + pip install https://github.com/pyxem/pyxem/archive/master.zip --no-deps + + - 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 From 8f0614eec96c062d4c80ac41a35e5f4be671846f Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 14:52:18 +0100 Subject: [PATCH 2/7] Add doc to the dev guide on running extension test suite from PR --- doc/dev_guide/testing.rst | 2 ++ doc/dev_guide/writing_extensions.rst | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/dev_guide/testing.rst b/doc/dev_guide/testing.rst index e959367363..cf620da234 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 diff --git a/doc/dev_guide/writing_extensions.rst b/doc/dev_guide/writing_extensions.rst index e9ba0fd366..81ed588816 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 `_ when the label +``run-extension-tests`` is added to a PR or when a PR review is edited. + From 7c14dbc58df51c30d104a07c4b6900baafff5442 Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 15:34:05 +0100 Subject: [PATCH 3/7] Add atomap to the workflow but doesn't enable it until atomap test suite can headless --- .github/workflows/tests_extension.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests_extension.yml b/.github/workflows/tests_extension.yml index ef6e6afe1e..0d2ca16368 100644 --- a/.github/workflows/tests_extension.yml +++ b/.github/workflows/tests_extension.yml @@ -58,9 +58,10 @@ jobs: - name: Install Extension Dev if: contains(matrix.EXTENSION_VERSION, 'dev') run: | - pip install https://github.com/lumispy/lumispy/archive/main.zip --no-deps - pip install https://github.com/pyxem/kikuchipy/archive/main.zip --no-deps - pip install https://github.com/pyxem/pyxem/archive/master.zip --no-deps + pip install https://github.com/lumispy/lumispy/archive/main.zip + pip install https://github.com/pyxem/kikuchipy/archive/main.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() }} @@ -76,3 +77,9 @@ jobs: 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 From 8a906c3b68616be9986da856518bde30138019bc Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 15:09:44 +0100 Subject: [PATCH 4/7] Add changelog entry --- doc/dev_guide/testing.rst | 2 +- upcoming_changes/2824.enhancements.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 upcoming_changes/2824.enhancements.rst diff --git a/doc/dev_guide/testing.rst b/doc/dev_guide/testing.rst index cf620da234..23fec2bfce 100644 --- a/doc/dev_guide/testing.rst +++ b/doc/dev_guide/testing.rst @@ -222,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/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. From 0427f95efd6647a4f00e2a4eb414390aaad71d3e Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 17:13:20 +0100 Subject: [PATCH 5/7] Use kikuchipy develop branch and add missing word in dev guide --- .github/workflows/tests_extension.yml | 2 +- doc/dev_guide/writing_extensions.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_extension.yml b/.github/workflows/tests_extension.yml index 0d2ca16368..a03754055c 100644 --- a/.github/workflows/tests_extension.yml +++ b/.github/workflows/tests_extension.yml @@ -59,7 +59,7 @@ jobs: 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/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 diff --git a/doc/dev_guide/writing_extensions.rst b/doc/dev_guide/writing_extensions.rst index 81ed588816..79082b00a9 100644 --- a/doc/dev_guide/writing_extensions.rst +++ b/doc/dev_guide/writing_extensions.rst @@ -423,6 +423,6 @@ 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 `_ when the label +`hyperspy `_ repository when the label ``run-extension-tests`` is added to a PR or when a PR review is edited. From 6d5b0aa3f421c4219ff8596b1d10ce8b1b2ea8d2 Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 17:31:32 +0100 Subject: [PATCH 6/7] Tweak condition triggering workflow --- .github/workflows/tests_extension.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_extension.yml b/.github/workflows/tests_extension.yml index a03754055c..b85fec7604 100644 --- a/.github/workflows/tests_extension.yml +++ b/.github/workflows/tests_extension.yml @@ -6,11 +6,11 @@ on: label: types: [created] pull_request_review: - types: [edited] + types: [submitted, edited] jobs: integration_test: - if: ${{ github.event.label.name == 'run-extension-tests' }} + if: ${{ github.event.review || github.event.label.name == 'run-extension-tests' }} name: Extension_${{ matrix.EXTENSION_VERSION }} runs-on: ubuntu-latest strategy: From 5f416de07a0049128dd9805a32d2f256a8d201b8 Mon Sep 17 00:00:00 2001 From: Eric Prestat Date: Thu, 9 Sep 2021 17:36:41 +0100 Subject: [PATCH 7/7] Update workflow link in dev guide --- doc/dev_guide/writing_extensions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dev_guide/writing_extensions.rst b/doc/dev_guide/writing_extensions.rst index 79082b00a9..a5e23c6138 100644 --- a/doc/dev_guide/writing_extensions.rst +++ b/doc/dev_guide/writing_extensions.rst @@ -421,7 +421,7 @@ 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 `__ +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.