variables:
  PYTORCH_IMAGE: registry.sensetime.com/eig-research/pytorch:1.3.1-cuda10.1-cudnn7-devel

stages:
  - linting
  - test
  - deploy

before_script:
  - echo $PATH
  - gcc --version
  - nvcc --version
  - python --version
  - pip --version
  - python -c "import torch; print(torch.__version__)"

linting:
  image: $PYTORCH_IMAGE
  stage: linting
  script:
    - pip install flake8==3.7.9 yapf isort
    - flake8 .
    - isort --check-only --diff mmdet3d/ tools/ tests/
    - yapf -r -d mmdet3d/ tools/ tests/ configs/

.test_template: &test_template_def
  stage: test
  script:
    - echo "Start building..."
    - pip install -q "git+https://github.com/open-mmlab/cocoapi.git#subdirectory=pycocotools"
    - pip install -q git+https://github.com/open-mmlab/mmcv.git@v0.6.2
    - pip install -q git+https://github.com/open-mmlab/mmdetection.git
    - python -c "import mmdet; print(mmdet.__version__)"
    - pip install -e .[all]
    - python -c "import mmdet3d; print(mmdet3d.__version__)"
    - echo "Start testing..."
    - coverage run --branch --source mmdet3d -m pytest tests/
    - coverage report -m
    - interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --exclude mmdet3d/ops --ignore-regex "__repr__" --fail-under 80 mmdet3d

test:pytorch1.3-cuda10:
  image: $PYTORCH_IMAGE
  <<: *test_template_def

pages:
  image: $PYTORCH_IMAGE
  stage: deploy
  script:
    - pip install numba==0.48.0
    - pip install sphinx sphinx_rtd_theme recommonmark sphinx_markdown_tables m2r
    - cd docs
    - make html
    - cd ..
    - mkdir -p ./public
    - cp -r docs/_build/html/* ./public
    - ls ./public
  artifacts:
    paths:
      - public
  only:
    - master
