Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

dockerise travis ci script

edgarriba3c0a0049ac7c
diff --git a/.travis.yml b/.travis.yml
index 98a96ff3a..0b6918772 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,39 +1,26 @@
-language: python
+sudo: true
+dist: trusty
notifications:
email: false
-matrix:
- include:
- - env: LINT_CHECK
- python: "3.6"
- install: pip install flake8
- script: flake8
- - env: MYPY_TYPE_CHECK
- python: "3.6"
- install: pip install mypy mypy-extensions
- script: mypy @mypy_files.txt --ignore-missing-imports
- - python: "3.6"
+services:
+ - docker
install:
- - sudo apt-get update
- - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- - bash miniconda.sh -b -p $HOME/miniconda
- - export PATH="$HOME/miniconda/bin:$PATH"
- - hash -r
- - conda config --set always_yes yes --set changeps1 no
- - conda update -q conda
- # Useful for debugging any issues with conda
- - conda info -a
+ - cd docker; ./build.sh
+ - docker images
+
+matrix:
+ include:
+ - env: lint check
+ script: docker run arraiy/torchgeometry /bin/bash -c "source path.bash.inc && python verify.py --check lint"
- - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pytorch scipy -c pytorch
- - source activate test-environment
- - python setup.py install
- - pip install --upgrade pytest
- - pip install codecov
+ - env: static check
+ script: docker run arraiy/torchgeometry /bin/bash -c "source path.bash.inc && python verify.py --check mypy"
-script:
- - pytest test/
+ - env: docs
+ script: docker run arraiy/torchgeometry /bin/bash -c "source path.bash.inc && python verify.py --check build-docs"
-after_success:
- - codecov
+ - env: test
+ script: docker run arraiy/torchgeometry /bin/bash -c "source path.bash.inc && pytest test/"
diff --git a/docker/Dockerfile.travis b/docker/Dockerfile.travis
new file mode 100644
index 000000000..78018b220
--- /dev/null
+++ b/docker/Dockerfile.travis
@@ -0,0 +1,13 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ curl \
+ bzip2 \
+ build-essential \
+ ca-certificates &&\
+rm -rf /var/lib/apt/lists/*
+
+COPY . /torchgeometry
+WORKDIR /torchgeometry
+
+RUN ./setup_travis_env.sh
diff --git a/docker/build.sh b/docker/build.sh
index a98e91e4a..7bf418d04 100755
--- a/docker/build.sh
+++ b/docker/build.sh
@@ -9,4 +9,5 @@ fi
sdk_dir="$( command cd -P "$apparent_sdk_dir/../" > /dev/null && pwd -P )"
# This builds the docker file, from the root of the workspace
-docker build -t arraiy/torchgeometry -f Dockerfile $sdk_dir
+# docker build -t arraiy/torchgeometry -f Dockerfile $sdk_dir
+docker build -t arraiy/torchgeometry -f Dockerfile.travis $sdk_dir
diff --git a/docs/requirements.txt b/docs/requirements.txt
index e96021224..72bc43a34 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -1,3 +1,3 @@
-sphinx==1.6.6
-sphinx_rtd_theme==0.2.4
+sphinx
+sphinx_rtd_theme
nbsphinx
diff --git a/setup_dev_env.sh b/setup_dev_env.sh
index 4a6485bc6..5d6da0016 100755
--- a/setup_dev_env.sh
+++ b/setup_dev_env.sh
@@ -18,6 +18,7 @@ if [ ! -e $sdk_dir/.dev_env/bin/conda ]; then
fi
$sdk_dir/.dev_env/bin/conda install -y \
+ pip \
ipython \
jupyter \
matplotlib \
@@ -25,10 +26,14 @@ $sdk_dir/.dev_env/bin/conda install -y \
pytorch \
torchvision \
opencv \
- sphinx \
- sphinx_rtd_theme \
- nbsphinx \
- mypy \
-c pytorch
-$sdk_dir/.dev_env/bin/conda clean -ya
+$sdk_dir/.dev_env/bin/conda install -y \
+ pytest \
+ flake8 \
+ mypy \
+ mypy_extensions \
+ --file docs/requirements.txt \
+ -c conda-forge
+
+$sdk_dir/.dev_env/bin/conda clean -ya
diff --git a/setup_travis_env.sh b/setup_travis_env.sh
new file mode 100755
index 000000000..f46f8bd71
--- /dev/null
+++ b/setup_travis_env.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -ex
+script_link="$( readlink "$BASH_SOURCE" )" || script_link="$BASH_SOURCE"
+apparent_sdk_dir="${script_link%/*}"
+if [ "$apparent_sdk_dir" == "$script_link" ]; then
+ apparent_sdk_dir=.
+fi
+sdk_dir="$( command cd -P "$apparent_sdk_dir" > /dev/null && pwd -P )"
+
+mkdir -p $sdk_dir/.dev_env
+
+if [ ! -e $sdk_dir/.dev_env/miniconda.sh ]; then
+ curl -o $sdk_dir/.dev_env/miniconda.sh \
+ -O https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
+ chmod +x $sdk_dir/.dev_env/miniconda.sh
+fi
+if [ ! -e $sdk_dir/.dev_env/bin/conda ]; then
+ $sdk_dir/.dev_env/miniconda.sh -b -u -p $sdk_dir/.dev_env
+fi
+
+# Install CPU-PyTorch
+$sdk_dir/.dev_env/bin/conda install -y \
+ pytorch-cpu \
+ -c pytorch
+
+# Tests dependencies
+$sdk_dir/.dev_env/bin/conda install -y \
+ pytest \
+ flake8 \
+ mypy \
+ mypy_extensions \
+ --file docs/requirements.txt \
+ -c conda-forge
+
+$sdk_dir/.dev_env/bin/conda clean -ya
diff --git a/verify.py b/verify.py
index 11b205a64..e9248ee55 100644
--- a/verify.py
+++ b/verify.py
@@ -1,20 +1,54 @@
#! /usr/bin/env python
-from subprocess import run, CalledProcessError
-import sys
+"""Script that runs all verification steps.
+"""
+
+import argparse
+
+import os
+import shutil
+from subprocess import run
+from subprocess import CalledProcessError
+import sys
-def main():
+def main(checks):
try:
- print("Typechecker (mypy)", flush=True)
- files_to_analyse = ['./torchgeometry/image/gaussian.py']
- for file_to_analyse in files_to_analyse:
- run("mypy " + file_to_analyse + " --ignore-missing-imports",
- shell=True,
+ print("Verifying with " + str(checks))
+ if "lint" in checks:
+ print("Linter (flake8):", flush=True)
+ run("flake8 torchgeometry test examples", shell=True, check=True)
+ print("lint checks passed")
+
+ if "mypy" in checks:
+ print("Typechecker (mypy)", flush=True)
+ run("mypy @mypy_files.txt --ignore-missing-imports", shell=True,
check=True)
- print("mypy checks passed")
+ print("mypy checks passed")
+
+ if "build-docs" in checks:
+ print("Documentation (build):", flush=True)
+ run("cd docs; make clean html", shell=True, check=True)
+
+ if "check-docs" in checks:
+ print("Documentation (check):", flush=True)
+ run("./scripts/check_docs.py", shell=True, check=True)
+ print("check docs passed")
+
except CalledProcessError:
+ # squelch the exception stacktrace
sys.exit(1)
+if __name__ == "__main__":
+ checks = ['lint', 'mypy', 'build-docs', 'check-docs',]
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--checks', type=str, required=False, nargs='+', choices=checks)
+
+ args = parser.parse_args()
+
+ if args.checks:
+ run_checks = args.checks
+ else:
+ run_checks = checks
-if __name__ == '__main__':
- main()
+main(run_checks)