Add travis file

This commit is contained in:
Antonin RAFFIN 2020-05-07 17:59:51 +02:00
parent 26981f1247
commit f81fd1ddb6
3 changed files with 82 additions and 0 deletions

49
.travis.yml Normal file
View file

@ -0,0 +1,49 @@
language: python
python:
- "3.6"
env:
global:
- DOCKER_IMAGE=stablebaselines/stable-baselines3-cpu:0.6.0a5
notifications:
email: false
services:
- docker
install:
- docker pull ${DOCKER_IMAGE}
script:
- ./scripts/run_tests_travis.sh "${TEST_GLOB}"
jobs:
include:
# Big test suite. Run in parallel to decrease wall-clock time, and to avoid OOM error from leaks
- stage: Test
name: "Unit Tests a-h"
env: TEST_GLOB="[a-h]*"
- name: "Unit Tests i-l"
env: TEST_GLOB="[i-l]*"
- name: "Unit Tests m-sa"
env: TEST_GLOB="{[m-r]*,sa*}"
- name: "Unit Tests sb-z"
env: TEST_GLOB="{s[b-z]*,[t-z]*}"
- name: "Sphinx Documentation"
script:
- 'docker run -it --rm --mount src=$(pwd),target=/root/code/stable-baselines3,type=bind ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines3/ && pushd docs/ && make clean && make html"'
- name: "Type Checking"
script:
- 'docker run --rm --mount src=$(pwd),target=/root/code/stable-baselines3,type=bind ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines3/ && pytype --version && pytype"'
- stage: Codacy Trigger
if: type != pull_request
script:
# When all test coverage reports have been uploaded, instruct Codacy to start analysis.
- 'docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines3,type=bind --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} bash -c "cd /root/code/stable-baselines3/ && java -jar /root/code/codacy-coverage-reporter.jar final"'

View file

@ -218,4 +218,5 @@ texinfo_documents = [
# kornia's hack to get rtd builder to install latest pytorch
if on_rtd:
os.system('pip install gym')
os.system('pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html')

32
scripts/run_tests_travis.sh Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
DOCKER_CMD="docker run -it --rm --network host --ipc=host --mount src=$(pwd),target=/root/code/stable-baselines3,type=bind"
BASH_CMD="cd /root/code/stable-baselines3/"
if [[ $# -ne 1 ]]; then
echo "usage: $0 <test glob>"
exit 1
fi
if [[ ${DOCKER_IMAGE} = "" ]]; then
echo "Need DOCKER_IMAGE environment variable to be set."
exit 1
fi
TEST_GLOB=$1
set -e # exit immediately on any error
# For pull requests from fork, Codacy token is not available, leading to build failure
if [[ ${CODACY_PROJECT_TOKEN} = "" ]]; then
echo "WARNING: CODACY_PROJECT_TOKEN not set. Skipping Codacy upload."
echo "(This is normal when building in a fork and can be ignored.)"
${DOCKER_CMD} ${DOCKER_IMAGE} \
bash -c "${BASH_CMD} && \
pytest --cov-config .coveragerc --cov-report term --cov=. -v tests/test_${TEST_GLOB}"
else
${DOCKER_CMD} --env CODACY_PROJECT_TOKEN=${CODACY_PROJECT_TOKEN} ${DOCKER_IMAGE} \
bash -c "${BASH_CMD} && \
pytest --cov-config .coveragerc --cov-report term --cov-report xml --cov=. -v tests/test_${TEST_GLOB} && \
java -jar /root/code/codacy-coverage-reporter.jar report -l python -r coverage.xml --partial"
fi