Skip to content

Commit 60724d0

Browse files
committed
Generate text-based coverage report on CI.
1 parent 382cf4c commit 60724d0

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

.github/workflows/linux-gpu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
# Checkout of the full history is required for running benchmarks on old commits but not current
2626
fetch-depth: 1
2727

28-
- name: Run unit tests
28+
- name: Run unit tests with coverage report
2929
if: github.event_name == 'pull_request'
3030
run: |
3131
SLURM_JOB_NAME="$(uuidgen)_$(date +%Y%m%d_%H%M%S)"
@@ -46,7 +46,7 @@ jobs:
4646
--job-name=${SLURM_JOB_NAME} \
4747
bash -c "
4848
pip install -e '.[dev,render]' && \
49-
pytest -v --forked ./tests
49+
pytest -v --forked --cov --cov-report=term-missing:skip-covered ./tests
5050
"
5151
5252
- name: Run benchmarks

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ addopts = [
9393
"--max-worker-restart=0",
9494
"--durations=0",
9595
"--durations-min=40.0",
96+
"--no-cov-on-fail",
9697
"-m not benchmarks",
9798
]
9899
filterwarnings = [
@@ -105,6 +106,16 @@ markers = [
105106
]
106107
log_cli_level = "WARNING"
107108

109+
[tool.coverage.run]
110+
branch = true
111+
source = ["genesis"]
112+
# parallel = true
113+
# sigterm = true
114+
# concurrency = ["thread", "multiprocessing"]
115+
omit = [
116+
"genesis/ext/*", # Ignore bundled external dependencies
117+
]
118+
108119
[project.scripts]
109120
gs = "genesis._main:main"
110121

@@ -116,6 +127,7 @@ dev = [
116127
"pytest-forked",
117128
"pytest-random-order",
118129
"pytest-print",
130+
"pytest-cov",
119131
"huggingface_hub",
120132
"wandb",
121133
]

tests/test_rigid_physics.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import mujoco
1313
import genesis as gs
14+
from genesis.utils.mesh import get_assets_dir
1415

1516
from .utils import (
1617
assert_allclose,
@@ -1935,27 +1936,25 @@ def must_cast(value):
19351936

19361937
@pytest.mark.parametrize("backend", [gs.cpu])
19371938
def test_mesh_to_heightfield(show_viewer):
1938-
########################## create a scene ##########################
1939+
horizontal_scale = 2.0
1940+
path_terrain = os.path.join(get_assets_dir(), "meshes", "terrain_45.obj")
1941+
1942+
hf_terrain, xs, ys = gs.utils.terrain.mesh_to_heightfield(path_terrain, spacing=horizontal_scale, oversample=1)
1943+
1944+
# default heightfield starts at 0, 0, 0
1945+
# translate to the center of the mesh
1946+
translation = np.array([np.nanmin(xs), np.nanmin(ys), 0])
1947+
19391948
scene = gs.Scene(
1940-
show_viewer=show_viewer,
19411949
sim_options=gs.options.SimOptions(
19421950
gravity=(2, 0, -2),
19431951
),
19441952
viewer_options=gs.options.ViewerOptions(
19451953
camera_pos=(0, -50, 0),
19461954
camera_lookat=(0, 0, 0),
19471955
),
1956+
show_viewer=show_viewer,
19481957
)
1949-
1950-
horizontal_scale = 2.0
1951-
gs_root = os.path.dirname(os.path.abspath(gs.__file__))
1952-
path_terrain = os.path.join(gs_root, "assets", "meshes", "terrain_45.obj")
1953-
hf_terrain, xs, ys = gs.utils.terrain.mesh_to_heightfield(path_terrain, spacing=horizontal_scale, oversample=1)
1954-
1955-
# default heightfield starts at 0, 0, 0
1956-
# translate to the center of the mesh
1957-
translation = np.array([np.nanmin(xs), np.nanmin(ys), 0])
1958-
19591958
terrain_heightfield = scene.add_entity(
19601959
morph=gs.morphs.Terrain(
19611960
horizontal_scale=horizontal_scale,
@@ -1965,15 +1964,13 @@ def test_mesh_to_heightfield(show_viewer):
19651964
),
19661965
vis_mode="collision",
19671966
)
1968-
19691967
ball = scene.add_entity(
19701968
gs.morphs.Sphere(
19711969
pos=(10, 15, 10),
19721970
radius=1,
19731971
),
19741972
vis_mode="collision",
19751973
)
1976-
19771974
scene.build()
19781975

19791976
for i in range(1000):

0 commit comments

Comments
 (0)