Skip to content

Commit

Permalink
[examples] Drop CI requirement for DISPLAY
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri committed Oct 31, 2024
1 parent e84966b commit a1cd3c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ common --keep_going=yes
build --test_output=errors
build --test_summary=terse

# Inject DISPLAY into test runner environment for tests that use X.
build --test_env=DISPLAY
build --sandbox_add_mount_pair=/tmp/.X11-unix

# Add `bazel test --config=lint` shortcut for linting.
build:lint --test_tag_filters=lint

Expand Down
23 changes: 1 addition & 22 deletions .github/ci_setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,4 @@

set -euxo pipefail

# Downgrade mesa per https://github.com/RobotLocomotion/drake/issues/18726.
sudo apt-get --assume-yes --allow-downgrades install \
xvfb \
libegl1 \
libegl-mesa0=22.0.1-1ubuntu2 \
libgbm1=22.0.1-1ubuntu2 \
libgl1-mesa-dri=22.0.1-1ubuntu2 \
libglapi-mesa=22.0.1-1ubuntu2 \
libglx-mesa0=22.0.1-1ubuntu2

cat << EOF | sudo tee /lib/systemd/system/xvfb.service
[Unit]
After=network.target
[Service]
ExecStart=/usr/bin/Xvfb :99 -screen 0 1280x1024x24 -ac +extension GLX +extension RANDR +render -noreset
[Install]
WantedBy=multi-user.target
EOF

sudo systemctl --now --quiet enable /lib/systemd/system/xvfb.service
sudo apt-get --assume-yes install libegl1
11 changes: 7 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ on:
branches:
- main

env:
# Always use the Xvfb service's display.
DISPLAY: ":99"

jobs:
bazel_test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -76,6 +72,13 @@ jobs:
run: |
ln -s .github/ci.bazelrc user.bazelrc
./bazel test //...
# Save the test outputs to allow for eyeball verification when relevant.
- name: Archive test outputs
uses: actions/upload-artifact@v4
with:
name: test_outputs
path: |
.bazel/testlogs/examples/ball_bin_test/test.outputs/outputs.zip
# Save the updated cache snapshots, so we never do the same work twice.
# By default, actions/cache only saves after a successful workflow, but
# our caches are bags of files where we only ever add new files (not change
Expand Down
6 changes: 4 additions & 2 deletions examples/ball_bin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ cameras:
vtk_camera:
name: vtk_camera
renderer_name: vtk
renderer_class: !RenderEngineVtkParams {}
show_rgb: True # Use a live on-screen preview.
renderer_class: !RenderEngineVtkParams
backend: EGL
# For `show_rgb: True` you must also set the `backend: GLX` on prior line.
show_rgb: False
width: 1024
height: 1024
fps: 8.0
Expand Down
15 changes: 9 additions & 6 deletions examples/test/ball_bin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def setUp(self):
self.tmpdir = Path(os.environ["TEST_TMPDIR"])
self.assertTrue(self.tmpdir.exists(), self.tmpdir)

self.out_dir = Path(os.environ["TEST_UNDECLARED_OUTPUTS_DIR"])
self.assertTrue(self.out_dir.exists(), self.out_dir)

# Find the demo.
demo_path = Path("examples/ball_bin").absolute().resolve()
self.assertTrue(demo_path.exists(), demo_path)
Expand Down Expand Up @@ -71,21 +74,21 @@ def test_still_images(self):
f"--scenario_file={scenario_file}",
]

result = subprocess.run(run_args, cwd=self.tmpdir)
result = subprocess.run(run_args, cwd=self.out_dir)
result.check_returncode()
self.assertTrue((self.tmpdir / "vtk_camera.png").exists())
self.assertTrue((self.tmpdir / "blender_camera.png").exists())
self.assertTrue((self.out_dir / "vtk_camera.png").exists())
self.assertTrue((self.out_dir / "blender_camera.png").exists())

def test_video(self):
"""Checks that the example creates 2x video files."""
scenario_file = self._get_scenario_file(nerf_scenario=True)

run_args = self.default_run_args + [f"--scenario_file={scenario_file}"]

result = subprocess.run(run_args, cwd=self.tmpdir)
result = subprocess.run(run_args, cwd=self.out_dir)
result.check_returncode()
self.assertTrue((self.tmpdir / "vtk_camera.mp4").exists())
self.assertTrue((self.tmpdir / "blender_camera.mp4").exists())
self.assertTrue((self.out_dir / "vtk_camera.mp4").exists())
self.assertTrue((self.out_dir / "blender_camera.mp4").exists())


if __name__ == "__main__":
Expand Down

0 comments on commit a1cd3c4

Please sign in to comment.