From b064313d20e075638cbb4de9161e667105876eca Mon Sep 17 00:00:00 2001 From: Zain Patel Date: Wed, 28 Jul 2021 04:32:32 +0100 Subject: [PATCH] Fix CI: add tests to GitHub actions (#2262) * Initial CI fixes --- .dockerignore | 1 - .github/workflows/build.yml | 18 ++++++++++++++++++ .github/workflows/lint_python.yml | 2 +- .travis.yml | 24 ------------------------ py.Dockerfile | 26 +++++++++----------------- test_requirements.txt | 3 +++ 6 files changed, 31 insertions(+), 43 deletions(-) delete mode 100644 .dockerignore create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml create mode 100644 test_requirements.txt diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 172bf5786d1..00000000000 --- a/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -.tox diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..bc02ae78d25 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,18 @@ +name: build +on: [pull_request, push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2 + - run: | + docker build -f py.Dockerfile \ + --build-arg MUJOCO_KEY=$MUJOCO_KEY \ + --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --tag gym-docker . + - name: Run tests + run: docker run gym-docker pytest --forked diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 2857808b883..1b92a28fb83 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -13,7 +13,7 @@ jobs: - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88 --show-source --statistics - run: isort --check-only --profile black . || true - - run: pip install -e .[all] + - run: pip install -e .[nomujoco] - run: mypy --install-types --non-interactive . || true - run: pytest . || true - run: pytest --doctest-modules . || true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 39414a29140..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -dist: focal -language: python -python: - - "3.7" -services: - - docker -env: - - PY_VER=3.6.13 - - PY_VER=3.7.10 - - PY_VER=3.8.9 - - PY_VER=3.9.4 - -install: "" # so travis doesn't do pip install requirements.txt -script: - - docker build -f py.Dockerfile --build-arg MUJOCO_KEY=$MUJOCO_KEY --build-arg PYTHON_VER=$PY_VER -t gym-test . - - docker run gym-test - -deploy: - provider: pypi - username: $TWINE_USERNAME - password: $TWINE_PASSWORD - on: - tags: true - condition: $PY_VER = 3.8.9 diff --git a/py.Dockerfile b/py.Dockerfile index fb0900bb51d..2f014f82664 100644 --- a/py.Dockerfile +++ b/py.Dockerfile @@ -1,28 +1,20 @@ # A Dockerfile that sets up a full Gym install with test dependencies -ARG PYTHON_VER -FROM python:$PYTHON_VER +ARG PYTHON_VERSION +FROM python:$PYTHON_VERSION RUN apt-get -y update && apt-get install -y unzip libglu1-mesa-dev libgl1-mesa-dev libosmesa6-dev xvfb patchelf ffmpeg cmake swig -RUN \ + # Download mujoco - mkdir /root/.mujoco && \ +RUN mkdir /root/.mujoco && \ cd /root/.mujoco && \ - curl -O https://www.roboti.us/download/mjpro150_linux.zip && \ - unzip mjpro150_linux.zip - -ARG PYTHON_VER -ARG MUJOCO_KEY -ENV MUJOCO_KEY=$MUJOCO_KEY + curl -O https://www.roboti.us/download/mjpro150_linux.zip && \ + unzip mjpro150_linux.zip && \ + echo DUMMY_KEY > /root/.mujoco/mjkey.txt ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/.mujoco/mjpro150/bin -RUN echo $MUJOCO_KEY | base64 --decode > /root/.mujoco/mjkey.txt -RUN pip install pytest pytest-forked lz4 COPY . /usr/local/gym/ WORKDIR /usr/local/gym/ -# install all extras for python 3.6 and 3.7, and skip mujoco add-ons for 3.8 and 3.9 -# as mujoco 1.50 does not seem to work with 3.8 and 3.9 -# RUN bash -c "[[ $PYTHON_VER =~ 3\.[6-7]\.[0-9] ]] && pip install -e .[all] || pip install -e .[nomujoco]" -RUN pip install -e .[nomujoco] + +RUN pip install -e .[nomujoco] && pip install -r test_requirements.txt ENTRYPOINT ["/usr/local/gym/bin/docker_entrypoint"] -CMD ["pytest","--forked"] diff --git a/test_requirements.txt b/test_requirements.txt new file mode 100644 index 00000000000..7f59ce32d86 --- /dev/null +++ b/test_requirements.txt @@ -0,0 +1,3 @@ +lz4~=3.1 +pytest~=6.2 +pytest-forked~=1.3