image: artefact.skatelescope.org/ska-tango-images/tango-itango:9.3.3.7
variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
  # The PBR dependency requires a set version, not actually used
  PBR_VERSION: "0.1"
cache:
  paths:
    - .cache/pip
    - devices/.tox
stages:
  - building
  - linting
  - unit-tests
building:
  stage: building
  image: ubuntu:20.04
  variables:
    CHECKOUT_DIR: "$CI_PROJECT_DIR/../"
    TANGO_SKA_LOCAL_DIR: "${CHECKOUT_DIR}"
    TANGO_SKA_CONTAINER_DIR: "/opt/lofar2.0/ska-docker/"
    TANGO_SKA_CONTAINER_MOUNT: "${TANGO_SKA_LOCAL_DIR}:${TANGO_SKA_CONTAINER_DIR_DIR}:ro"
    TANGO_LOFAR_LOCAL_DIR: "${CHECKOUT_DIR}/tango/"
    TANGO_LOFAR_CONTAINER_DIR: "/opt/lofar2.0/tango/"
    TANGO_LOFAR_CONTAINER_MOUNT: "${TANGO_LOFAR_LOCAL_DIR}:${TANGO_LOFAR_CONTAINER_DIR}:rw"
    TANGO_CONTAINER_ENV: "-e TANGO_SKA_CONTAINER_DIR=${TANGO_SKA_CONTAINER_DIR} -e TANGO_LOFAR_CONTAINER_DIR=${TANGO_LOFAR_CONTAINER_DIR}"
    NETWORK_MODE: "lofar"
  before_script:
    - sudo apt-get update
    - sudo apt-get install -y git make docker-compose
    - touch ~/.Xauthority
  script:
    - cd docker-compose
    - make pull
    - make minimal
    - make build
linting:
  stage: linting
  allow_failure: true
  script:
    - cd devices
    - tox -e pep8
unit_test:
  stage: unit-tests
  before_script:
    - sudo apt-get update
    - sudo apt-get install -y git
  script:
    - cd devices
    - tox -e py37
