Skip to content

Commit

Permalink
enforce requirements in sync (#114)
Browse files Browse the repository at this point in the history
* enforce requirements in sync
* sync LiquidsReflectometer version
  • Loading branch information
jmborr authored Mar 8, 2024
1 parent 7e524e1 commit ca1750b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ numpy
PyQt5
qtpy
setuptools
lr_reduction@git+https://github.com/neutrons/[email protected].13#egg=lr_reduction
lr_reduction@git+https://github.com/neutrons/[email protected].18#egg=lr_reduction

30 changes: 30 additions & 0 deletions scripts/sync_dependencies.py
Original file line number Diff line number Diff line change
@@ -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)

1 comment on commit ca1750b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitLab pipeline for refred-dev has been submitted for this commit: "https://code.ornl.gov/sns-hfir-scse/deployments/conda-legacy-deploy/-/pipelines/536070"

Please sign in to comment.