Skip to content

Commit

Permalink
Added Coverage (#391)
Browse files Browse the repository at this point in the history
* coverage

* coverage

* coverage

* update requirements

* coverage xml

* merged

* install cov

* fixed tests

* fixed tests

* fix pip install for PR action

---------

Co-authored-by: Patrick Huck <phuck@lbl.gov>
  • Loading branch information
jmmshn and tschaume authored Sep 4, 2024
1 parent 852d682 commit 7dfbe60
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/pyproject.toml'
cache: "pip"
cache-dependency-path: "**/pyproject.toml"
- name: Install webdriver
run: sudo apt-get update && sudo apt-get install chromium-chromedriver
- name: Install dependencies
Expand All @@ -38,10 +38,15 @@ jobs:
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
python${{ matrix.python-version }} -m pip install --upgrade pip
python${{ matrix.python-version }} -m pip install --no-deps .[server]
python${{ matrix.python-version }} -m pip install --no-deps .[server,test]
- name: Test modules
run: python${{ matrix.python-version }} -m pytest tests
run: python${{ matrix.python-version }} -m pytest --cov=crystal_toolkit --cov-report=xml tests
- name: Test example apps
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
run: python${{ matrix.python-version }} -m pytest --color=yes --webdriver Chrome --headless crystal_toolkit/apps/examples/tests/
run: python${{ matrix.python-version }} -m pytest --cov=crystal_toolkit --cov-report=xml --color=yes --webdriver Chrome --headless crystal_toolkit/apps/examples/tests/
- uses: codecov/codecov-action@v1
if: matrix.python-version == 3.10
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
2 changes: 1 addition & 1 deletion crystal_toolkit/apps/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def test_main_app_startup(dash_duo: DashDuo):
dash_duo.take_snapshot("main_app_startup-layout")

logs = dash_duo.get_logs()
assert logs is None, f"Unexpected browser {logs=}"
assert not logs, f"Unexpected browser {logs=}"
25 changes: 25 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ server = ["dash-extensions", "gunicorn[gevent]", "habanero", "hiphive", "redis"]
robocrys = ["robocrys"]
temdiff = ["py4DSTEM>=0.13.11"]
fermi = ["ifermi", "pyfftw"]
phonon = ["phonopy"]
vtk = ["dash-vtk"]
localenv = ["dscribe"]
figures = ["kaleido"]
Expand Down Expand Up @@ -135,3 +136,27 @@ no_implicit_optional = false
[tool.versioningit.vcs]
default-tag = "0.0.1"
method = "git"

[tool.coverage.run]
branch = true
include = ["crystal_toolkit/*"]
omit = ["crystal_toolkit/apps/*",]

[tool.coverage.paths]
source = ["crystal_toolkit/"]

[tool.coverage.report]
show_missing = true
skip_covered = true
exclude_also = [
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements/ubuntu-latest_py3.10.txt pyproject.toml
# pip-compile --output-file=./requirements/ubuntu-latest_py3.10.txt pyproject.toml
#
aiofiles==22.1.0
# via ypy-websocket
Expand Down
7 changes: 6 additions & 1 deletion requirements/ubuntu-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --all-extras --output-file=requirements/ubuntu-latest_py3.10_extras.txt pyproject.toml
# pip-compile --all-extras --output-file=./requirements/ubuntu-latest_py3.10_extras.txt pyproject.toml
#
aiofiles==22.1.0
# via ypy-websocket
Expand Down Expand Up @@ -284,6 +284,7 @@ h5py==3.11.0
# hdf5plugin
# hiphive
# ncempy
# phonopy
# py4dstem
habanero==1.2.6
# via crystal_toolkit (pyproject.toml)
Expand Down Expand Up @@ -448,6 +449,7 @@ matplotlib==3.9.2
# boltztrap2
# ifermi
# ncempy
# phonopy
# py4dstem
# pymatgen
# vtk
Expand Down Expand Up @@ -563,6 +565,7 @@ numpy==1.26.4
# numba
# numpy-stl
# pandas
# phonopy
# py4dstem
# pyfftw
# pylops
Expand Down Expand Up @@ -775,6 +778,7 @@ pyyaml==6.0.2
# dask
# distributed
# jupyter-events
# phonopy
# pre-commit
# pyaml
# pybtex
Expand Down Expand Up @@ -914,6 +918,7 @@ spglib==2.5.0
# boltztrap2
# hiphive
# ifermi
# phonopy
# pymatgen
# robocrys
sphinx==7.4.7
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements/ubuntu-latest_py3.11.txt pyproject.toml
# pip-compile --output-file=./requirements/ubuntu-latest_py3.11.txt pyproject.toml
#
aiofiles==22.1.0
# via ypy-websocket
Expand Down
5 changes: 5 additions & 0 deletions requirements/ubuntu-latest_py3.11_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ h5py==3.11.0
# hdf5plugin
# hiphive
# ncempy
# phonopy
# py4dstem
habanero==1.2.6
# via crystal_toolkit (pyproject.toml)
Expand Down Expand Up @@ -437,6 +438,7 @@ matplotlib==3.9.2
# boltztrap2
# ifermi
# ncempy
# phonopy
# py4dstem
# pymatgen
# vtk
Expand Down Expand Up @@ -552,6 +554,7 @@ numpy==1.26.4
# numba
# numpy-stl
# pandas
# phonopy
# py4dstem
# pyfftw
# pylops
Expand Down Expand Up @@ -764,6 +767,7 @@ pyyaml==6.0.2
# dask
# distributed
# jupyter-events
# phonopy
# pre-commit
# pyaml
# pybtex
Expand Down Expand Up @@ -903,6 +907,7 @@ spglib==2.5.0
# boltztrap2
# hiphive
# ifermi
# phonopy
# pymatgen
# robocrys
sphinx==7.4.7
Expand Down

0 comments on commit 7dfbe60

Please sign in to comment.