Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameterize + dockerize tests #619

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 22 additions & 188 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,156 +70,42 @@ jobs:
fi
printf 'Docstring coverage check successful! We require the docstring coverage to be non-decreasing after PR. You have changed the coverage by: %s%%\n' "$improvement"

test_functionality:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["3.9"]
test: [test_functionality, test_env, test_policy, test_component, test_export_record_scenario, test_sensors, test_examples]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_functionality

test_environment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install gym
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_env

test_policy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_policy

test_component:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_component

test_export_record_scenario:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Blackbox tests
- name: tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_export_record_scenario
export PYTHON_VERSION=${{ matrix.version }}
export TEST="metadrive/tests/${{ matrix.test }}"
./tests/run.sh

test_sensor_pipeline:
test_ipynb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Prepare OpenGL
run: |
sudo apt-get -y install xvfb
sudo /usr/bin/Xvfb :0 -screen 0 1280x1024x24 &
- name: Blackbox tests
- name: tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_sensors/
mkdir ./metadrive/tests/test_ipynb
cp ./metadrive/examples/Basic_MetaDrive_Usages.ipynb ./metadrive/tests/test_ipynb/
export PYTHON_VERSION="3.9"
export TEST="--nbmake -n=auto --nbmake -n=auto ./metadrive/tests/test_ipynb/"
./tests/run.sh

test_examples:
test_doc_code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Prepare OpenGL
- name: tests
run: |
sudo apt-get -y install xvfb
sudo /usr/bin/Xvfb :0 -screen 0 1280x1024x24 &
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install mediapy
conda install ffmpeg
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_examples
export PYTHON_VERSION="3.9"
export TEST="--nbmake -n=auto ./documentation/source/"
./tests/run.sh

test_policy_windows:
runs-on: windows-latest
Expand All @@ -241,58 +127,6 @@ jobs:
cd metadrive/
pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv tests/test_policy

test_ipynb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Prepare OpenGL
run: |
sudo apt-get -y install xvfb
sudo /usr/bin/Xvfb :0 -screen 0 1280x1024x24 &
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
cd metadrive/
pip install nbmake pytest-xdist
mkdir ./tests/test_ipynb
cp ./examples/Basic_MetaDrive_Usages.ipynb ./tests/test_ipynb/
TEST_IPYNB=1 pytest --nbmake -n=auto ./tests/test_ipynb/

test_doc_code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Prepare OpenGL
run: |
sudo apt-get -y install xvfb
sudo /usr/bin/Xvfb :0 -screen 0 1280x1024x24 &
- name: Blackbox tests
run: |
pip install cython
pip install numpy
pip install -e .
pip install -e .[gym]
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
cd documentation
pip install nbmake pytest-xdist
TEST_DOC=1 pytest --nbmake -n=auto ./source

test_ros:
runs-on: ubuntu-22.04
steps:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@
**/**.mp4
/documentation/jupyter_execute/
/documentation/**/**.gif

.coverage
coverage.xml
/documentation/source/img.png
/documentation/source/demo.png
22 changes: 13 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def is_win():

install_requires = [
"requests",
"gymnasium>=0.28",
"numpy>=1.21.6",
"gymnasium",
"numpy",
"matplotlib",
"pandas",
"pygame",
Expand All @@ -48,9 +48,8 @@ def is_win():
"seaborn",
"tqdm",
"progressbar",
# "panda3d==1.10.8",
"panda3d==1.10.13",
"panda3d-gltf==0.13", # 0.14 will bring some problems
"panda3d",
"panda3d-gltf<=0.13",
"pillow",
"pytest",
"opencv-python",
Expand All @@ -65,10 +64,10 @@ def is_win():


cuda_requirement = [
"cuda-python==12.0.0",
"PyOpenGL==3.1.6",
"PyOpenGL-accelerate==3.1.6",
"pyrr==0.10.3",
"cuda-python",
"PyOpenGL",
"PyOpenGL-accelerate",
"pyrr",
"glfw",
]

Expand All @@ -80,6 +79,10 @@ def is_win():
"zmq"
]

remote_requirement = [
"ray"
]

setup(
name="metadrive-simulator",
python_requires='>=3.6, <3.12', # do version check with assert
Expand All @@ -94,6 +97,7 @@ def is_win():
"cuda": cuda_requirement,
"gym": gym_requirement,
"ros": ros_requirement,
"remote": remote_requirement,
},
include_package_data=True,
license="Apache 2.0",
Expand Down
10 changes: 10 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG PYTHON_VERSION=3.9
FROM python:${PYTHON_VERSION}-bullseye

RUN apt update && \
apt install -y --no-install-recommends xvfb ffmpeg && \
rm -rf /var/lib/apt/lists/*

RUN --mount=type=bind,target=/metadrive,rw,source=. \
--mount=type=cache,target=/root/.cache \
/metadrive/tests/setup.sh
8 changes: 8 additions & 0 deletions tests/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -ex

DIR="$(dirname "$0")"

docker buildx build -f tests/Dockerfile -t "metadrive-base:$PYTHON_VERSION" --build-arg PYTHON_VERSION=$PYTHON_VERSION $DIR/..
docker run --rm -e TEST="$TEST" -v $(pwd):/metadrive -w /metadrive -e PYTHONPATH=/metadrive metadrive-base:$PYTHON_VERSION tests/test.sh
8 changes: 8 additions & 0 deletions tests/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e

pip install /metadrive[gym]
python -m metadrive.pull_asset

pip install mediapy nbmake pytest pytest-cov pytest-xdist
9 changes: 9 additions & 0 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -ex

/usr/bin/Xvfb :0 -screen 0 1280x1024x24 &

sleep 2

pytest --cov=./ --cov-config=.coveragerc --cov-report=xml -sv $TEST
Loading