Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enforce requirements in sync #114

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/LiquidsReflectometer.git@v2.0.13#egg=lr_reduction
lr_reduction@git+https://github.com/neutrons/LiquidsReflectometer.git@v2.0.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)
Loading