diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 4bdfa094..03fcc2bd 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -27,6 +27,8 @@ jobs: run: flake8 --statistics RefRed test scripts - name: mypy type annotations run: mypy RefRed test scripts + - name: dependencies synced + run: python ./scripts/sync_dependencies.py - name: Run Tests run: xvfb-run -a python -m pytest -vv --cov=RefRed --cov-report=xml --cov-report=term test - name: Upload coverage to Codecov diff --git a/requirements.txt b/requirements.txt index e980e850..83e77793 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ numpy PyQt5 qtpy setuptools -lr_reduction@git+https://github.com/neutrons/LiquidsReflectometer.git@v2.0.13#egg=lr_reduction +lr_reduction@git+https://github.com/neutrons/LiquidsReflectometer.git@v2.0.18#egg=lr_reduction diff --git a/scripts/sync_dependencies.py b/scripts/sync_dependencies.py new file mode 100644 index 00000000..e6b057aa --- /dev/null +++ b/scripts/sync_dependencies.py @@ -0,0 +1,30 @@ +# standard imports +import logging +import os +import re +import sys + +script_dir: str = os.path.dirname(os.path.realpath(__file__)) +repo_dir: str = os.path.dirname(script_dir) + + +def check_dependencies_synced(): + r"""Check that the dependencies of environment.yml and requirements.txt are in sync""" + + conda_env = open(os.path.join(repo_dir, "environment.yml"), "r").read() + reqs_env = open(os.path.join(repo_dir, "requirements.txt"), "r").read() + + # check for LiquidsReflectometer versions + lr_conda = re.search(r'LiquidsReflectometer\.git@([^#]+)', conda_env).group(1) + lr_reqs = re.search(r'LiquidsReflectometer\.git@([^#]+)', reqs_env).group(1) + if lr_conda != lr_reqs: + raise RuntimeError("environment.yml and requirements.txt ask different versions of LiquidsReflectometer") + + +if __name__ == "__main__": + try: + check_dependencies_synced() + except RuntimeError as e: + logging.error(f"{e}") + sys.exit(1) + sys.exit(0)