Skip to content

Commit 7dfbe60

Browse files
jmmshntschaume
andauthored
Added Coverage (materialsproject#391)
* 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 <[email protected]>
1 parent 852d682 commit 7dfbe60

File tree

7 files changed

+49
-9
lines changed

7 files changed

+49
-9
lines changed

.github/workflows/pull-request.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
uses: actions/setup-python@v5
2929
with:
3030
python-version: ${{ matrix.python-version }}
31-
cache: 'pip'
32-
cache-dependency-path: '**/pyproject.toml'
31+
cache: "pip"
32+
cache-dependency-path: "**/pyproject.toml"
3333
- name: Install webdriver
3434
run: sudo apt-get update && sudo apt-get install chromium-chromedriver
3535
- name: Install dependencies
@@ -38,10 +38,15 @@ jobs:
3838
python${{ matrix.python-version }} -m pip install `grep numpy== requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt`
3939
python${{ matrix.python-version }} -m pip install -r requirements/ubuntu-latest_py${{ matrix.python-version }}_extras.txt
4040
python${{ matrix.python-version }} -m pip install --upgrade pip
41-
python${{ matrix.python-version }} -m pip install --no-deps .[server]
41+
python${{ matrix.python-version }} -m pip install --no-deps .[server,test]
4242
- name: Test modules
43-
run: python${{ matrix.python-version }} -m pytest tests
43+
run: python${{ matrix.python-version }} -m pytest --cov=crystal_toolkit --cov-report=xml tests
4444
- name: Test example apps
4545
env:
4646
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
47-
run: python${{ matrix.python-version }} -m pytest --color=yes --webdriver Chrome --headless crystal_toolkit/apps/examples/tests/
47+
run: python${{ matrix.python-version }} -m pytest --cov=crystal_toolkit --cov-report=xml --color=yes --webdriver Chrome --headless crystal_toolkit/apps/examples/tests/
48+
- uses: codecov/codecov-action@v1
49+
if: matrix.python-version == 3.10
50+
with:
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
file: ./coverage.xml

crystal_toolkit/apps/tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def test_main_app_startup(dash_duo: DashDuo):
2020
dash_duo.take_snapshot("main_app_startup-layout")
2121

2222
logs = dash_duo.get_logs()
23-
assert logs is None, f"Unexpected browser {logs=}"
23+
assert not logs, f"Unexpected browser {logs=}"

pyproject.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ server = ["dash-extensions", "gunicorn[gevent]", "habanero", "hiphive", "redis"]
3030
robocrys = ["robocrys"]
3131
temdiff = ["py4DSTEM>=0.13.11"]
3232
fermi = ["ifermi", "pyfftw"]
33+
phonon = ["phonopy"]
3334
vtk = ["dash-vtk"]
3435
localenv = ["dscribe"]
3536
figures = ["kaleido"]
@@ -135,3 +136,27 @@ no_implicit_optional = false
135136
[tool.versioningit.vcs]
136137
default-tag = "0.0.1"
137138
method = "git"
139+
140+
[tool.coverage.run]
141+
branch = true
142+
include = ["crystal_toolkit/*"]
143+
omit = ["crystal_toolkit/apps/*",]
144+
145+
[tool.coverage.paths]
146+
source = ["crystal_toolkit/"]
147+
148+
[tool.coverage.report]
149+
show_missing = true
150+
skip_covered = true
151+
exclude_also = [
152+
"def __repr__",
153+
"if self.debug:",
154+
"if settings.DEBUG",
155+
"raise AssertionError",
156+
"raise NotImplementedError",
157+
"if 0:",
158+
"if __name__ == .__main__.:",
159+
"if TYPE_CHECKING:",
160+
"class .*\\bProtocol\\):",
161+
"@(abc\\.)?abstractmethod",
162+
]

requirements/ubuntu-latest_py3.10.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
5-
# pip-compile --output-file=requirements/ubuntu-latest_py3.10.txt pyproject.toml
5+
# pip-compile --output-file=./requirements/ubuntu-latest_py3.10.txt pyproject.toml
66
#
77
aiofiles==22.1.0
88
# via ypy-websocket

requirements/ubuntu-latest_py3.10_extras.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.10
33
# by the following command:
44
#
5-
# pip-compile --all-extras --output-file=requirements/ubuntu-latest_py3.10_extras.txt pyproject.toml
5+
# pip-compile --all-extras --output-file=./requirements/ubuntu-latest_py3.10_extras.txt pyproject.toml
66
#
77
aiofiles==22.1.0
88
# via ypy-websocket
@@ -284,6 +284,7 @@ h5py==3.11.0
284284
# hdf5plugin
285285
# hiphive
286286
# ncempy
287+
# phonopy
287288
# py4dstem
288289
habanero==1.2.6
289290
# via crystal_toolkit (pyproject.toml)
@@ -448,6 +449,7 @@ matplotlib==3.9.2
448449
# boltztrap2
449450
# ifermi
450451
# ncempy
452+
# phonopy
451453
# py4dstem
452454
# pymatgen
453455
# vtk
@@ -563,6 +565,7 @@ numpy==1.26.4
563565
# numba
564566
# numpy-stl
565567
# pandas
568+
# phonopy
566569
# py4dstem
567570
# pyfftw
568571
# pylops
@@ -775,6 +778,7 @@ pyyaml==6.0.2
775778
# dask
776779
# distributed
777780
# jupyter-events
781+
# phonopy
778782
# pre-commit
779783
# pyaml
780784
# pybtex
@@ -914,6 +918,7 @@ spglib==2.5.0
914918
# boltztrap2
915919
# hiphive
916920
# ifermi
921+
# phonopy
917922
# pymatgen
918923
# robocrys
919924
sphinx==7.4.7

requirements/ubuntu-latest_py3.11.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is autogenerated by pip-compile with Python 3.11
33
# by the following command:
44
#
5-
# pip-compile --output-file=requirements/ubuntu-latest_py3.11.txt pyproject.toml
5+
# pip-compile --output-file=./requirements/ubuntu-latest_py3.11.txt pyproject.toml
66
#
77
aiofiles==22.1.0
88
# via ypy-websocket

requirements/ubuntu-latest_py3.11_extras.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ h5py==3.11.0
273273
# hdf5plugin
274274
# hiphive
275275
# ncempy
276+
# phonopy
276277
# py4dstem
277278
habanero==1.2.6
278279
# via crystal_toolkit (pyproject.toml)
@@ -437,6 +438,7 @@ matplotlib==3.9.2
437438
# boltztrap2
438439
# ifermi
439440
# ncempy
441+
# phonopy
440442
# py4dstem
441443
# pymatgen
442444
# vtk
@@ -552,6 +554,7 @@ numpy==1.26.4
552554
# numba
553555
# numpy-stl
554556
# pandas
557+
# phonopy
555558
# py4dstem
556559
# pyfftw
557560
# pylops
@@ -764,6 +767,7 @@ pyyaml==6.0.2
764767
# dask
765768
# distributed
766769
# jupyter-events
770+
# phonopy
767771
# pre-commit
768772
# pyaml
769773
# pybtex
@@ -903,6 +907,7 @@ spglib==2.5.0
903907
# boltztrap2
904908
# hiphive
905909
# ifermi
910+
# phonopy
906911
# pymatgen
907912
# robocrys
908913
sphinx==7.4.7

0 commit comments

Comments
 (0)