From 6484176963648d82b21f1bdc744d80ffa6c88178 Mon Sep 17 00:00:00 2001 From: Simon Billinge Date: Fri, 26 Jul 2024 07:50:29 +0200 Subject: [PATCH] test tests (#131) * pin numpy to 1.x for now * add environment.yml * test tests * trigger * try again with requirements * try again with requirements * now update test reqs * try and handle xwindow display issue * try using xfvb action * refactor xvfb action commands * source activate? * different tack, generate error and work on test? * again * again * chatgpt method * supress running qc of meta.yaml in conda-forge by renaming * try new pyproject.toml * again2 * forgot to install diffpy.pdfgui! * back to setup.py --- .github/workflows/main.yml | 51 +++++++++---------- conda-recipe/{run_test.py => dont_run.py} | 0 .../{meta.yaml => meta.suppress_yaml} | 2 +- environment.yml | 6 +++ requirements/run.txt | 2 +- requirements/test.txt | 2 + run_tests.py | 5 ++ src/diffpy/pdfgui/gui/aboutdialog.py | 4 +- src/diffpy/pdfgui/gui/adddatapanel.py | 1 + 9 files changed, 44 insertions(+), 29 deletions(-) rename conda-recipe/{run_test.py => dont_run.py} (100%) rename conda-recipe/{meta.yaml => meta.suppress_yaml} (96%) create mode 100644 environment.yml create mode 100644 run_tests.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 80bbfb71..e3ade008 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,32 +23,31 @@ jobs: path: . fetch-depth: 0 # avoid shallow clone with no tags - - name: initialize miniconda - # this uses a marketplace action that sets up miniconda in a way that makes - # it easier to use. I tried setting it up without this and it was a pain - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: test - # environment.yml file is needed by this action. Because I don't want - # maintain this but rather maintain the requirements files it just has - # basic things in it like conda and pip - environment-file: ./environment.yml - python-version: 3 - auto-activate-base: false + - name: Install Mamba + run: | + wget "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh" -O mambaforge.sh + bash mambaforge.sh -b -p $HOME/mambaforge + echo "$HOME/mambaforge/bin" >> $GITHUB_PATH + source $HOME/mambaforge/etc/profile.d/conda.sh + conda init bash - - name: install diffpy.pdfgui requirements - shell: bash -l {0} + - name: Create conda environment run: | - conda config --set always_yes yes --set changeps1 no - conda config --add channels conda-forge - conda activate test - conda install --file requirements/run.txt - conda install --file requirements/test.txt - pip install . - - name: Validate diffpy.pdfgui - shell: bash -l {0} + source $HOME/mambaforge/etc/profile.d/conda.sh + conda create -n test_env python=3.12 xonsh regolith -c conda-forge -y + conda activate test_env + pip install case_insensitive_dict + + - name: Install dependencies run: | - conda activate test - coverage run -m pytest -vv -s - coverage report -m - codecov + source $HOME/mambaforge/etc/profile.d/conda.sh + conda activate test_env + mamba install --file requirements/run.txt + mamba install --file requirements/test.txt + pip install -e . + + - name: Use Xvfb Action + uses: GabrielBB/xvfb-action@v1 + with: + run: | + bash -c "source $HOME/mambaforge/etc/profile.d/conda.sh && conda activate test_env && python -m run_tests.py" diff --git a/conda-recipe/run_test.py b/conda-recipe/dont_run.py similarity index 100% rename from conda-recipe/run_test.py rename to conda-recipe/dont_run.py diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.suppress_yaml similarity index 96% rename from conda-recipe/meta.yaml rename to conda-recipe/meta.suppress_yaml index 2eeff68a..568d0c7d 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.suppress_yaml @@ -54,7 +54,7 @@ test: # entry points work. - # You can also put a file called run_test.py in the recipe that will be run + # You can also put a file called dont_run.py in the recipe that will be run # at test time. # requires: diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..a3904941 --- /dev/null +++ b/environment.yml @@ -0,0 +1,6 @@ +name: diffpy.pdfgui +channels: + - conda-forge +dependencies: + - python=3 + - pip diff --git a/requirements/run.txt b/requirements/run.txt index 10e45f83..40bce3f0 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,4 +1,4 @@ -numpy +numpy==1.26 wxpython diffpy.pdffit2 diffpy.utils diff --git a/requirements/test.txt b/requirements/test.txt index 7167f602..628a048a 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,2 +1,4 @@ pytest freezegun +coverage +codecov diff --git a/run_tests.py b/run_tests.py new file mode 100644 index 00000000..a2a69494 --- /dev/null +++ b/run_tests.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python + +import diffpy.pdfgui.tests + +assert diffpy.pdfgui.tests.testdeps().wasSuccessful() diff --git a/src/diffpy/pdfgui/gui/aboutdialog.py b/src/diffpy/pdfgui/gui/aboutdialog.py index 37bd30c7..c71c45b3 100644 --- a/src/diffpy/pdfgui/gui/aboutdialog.py +++ b/src/diffpy/pdfgui/gui/aboutdialog.py @@ -4,6 +4,8 @@ # PDFgui by DANSE Diffraction group # Simon J. L. Billinge # (c) 2006 trustees of the Michigan State University. +# (c) 2024 trustees of the Columbia University in the City +# of New York # All rights reserved. # # File coded by: Dmitriy Bryndin @@ -233,7 +235,7 @@ def onColumbiaLogo(self, event): # wxGlade: DialogAbout. # end of class DialogAbout -##### testing code ########################################################### +# #### testing code ########################################################### if __name__ == "__main__": app = wx.App() diff --git a/src/diffpy/pdfgui/gui/adddatapanel.py b/src/diffpy/pdfgui/gui/adddatapanel.py index 7f5f1407..15cb48ca 100644 --- a/src/diffpy/pdfgui/gui/adddatapanel.py +++ b/src/diffpy/pdfgui/gui/adddatapanel.py @@ -5,6 +5,7 @@ # PDFgui by DANSE Diffraction group # Simon J. L. Billinge # (c) 2006 trustees of the Michigan State University. +# (c) 2024 trustees of the Columbia University in the City # All rights reserved. # # File coded by: Chris Farrow