Skip to content

Commit

Permalink
test: enable tests in ci (#16)
Browse files Browse the repository at this point in the history
Co-authored-by: Xuehai Pan <XuehaiPan@outlook.com>
Co-authored-by: Xuehai Pan <XuehaiPan@pku.edu.cn>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 24, 2023
1 parent c1c598e commit 0be3cae
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 5 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Tests

on:
push:
branches:
- main
pull_request:
paths:
- setup.py
- pyproject.toml
- MANIFEST.in
- tests/**
- safety_gymnasium/**
- .github/workflows/tests.yml
# Allow to trigger the workflow manually
workflow_dispatch:

permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test-ubuntu:
name: Test for Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# TODO: add Python 3.11 to test matrix
python-version: ["3.8", "3.9", "3.10"]
fail-fast: false
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
update-environment: true

- name: Upgrade pip
run: |
python -m pip install --upgrade pip setuptools wheel
- name: Install rendering dependencies
run: |
sudo apt-get update
sudo apt-get install libosmesa6-dev
sudo apt-get install python3-opengl
- name: Set MUJOCO_GL
run: |
echo "MUJOCO_GL=osmesa" >> "${GITHUB_ENV}"
echo "PYOPENGL_PLATFORM=osmesa" >> "${GITHUB_ENV}"
- name: Install Safety-Gymnasium
run: |
python -m pip install -vvv --editable '.[test]'
- name: Test with pytest
run: |
make pytest
4 changes: 2 additions & 2 deletions safety_gymnasium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def __combine(tasks, agents, max_episode_steps):
if MAKE_DEBUG_ENVIRONMENTS and robot_name in ['Point', 'Car', 'Racecar']:
# Keyboard inputs for debugging
debug_env_name = f'{PREFIX}{robot_name}{task_name}Debug-{VERSION}'
debug_config = copy.deepcopy(combined_config)
debug_config.update({'debug': True})
debug_config = {'debug': True}
debug_config.update(combined_config)
__register_helper(
env_id=debug_env_name,
entry_point='safety_gymnasium.builder:Builder',
Expand Down
1 change: 0 additions & 1 deletion safety_gymnasium/bases/underlying.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ def render(
if mode in {'rgb_array', 'depth_array'}:
# Extract depth part of the read_pixels() tuple
data = self._get_viewer(mode).render(render_mode=mode, camera_id=camera_id)
# original image is upside-down, so flip it
self.viewer._markers[:] = [] # pylint: disable=protected-access
self.viewer._overlays.clear() # pylint: disable=protected-access
return data
Expand Down
2 changes: 1 addition & 1 deletion safety_gymnasium/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# ==============================================================================
"""Safety-Gymnasium."""

__version__ = '0.2.0'
__version__ = '0.3.0'
__license__ = 'Apache License, Version 2.0'
__author__ = 'Safety-Gymnasium Contributors'
__release__ = False
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytes
pytest
pytest-cov
pytest-xdist

0 comments on commit 0be3cae

Please sign in to comment.