# Customize the test machine
machine:
  timezone:
    Europe/London

  # Indicating node also offers advantage of bypassing virtual environments
  node:
    version: 5.5.0

  # Override /etc/hosts
  hosts:
    circlehost: 127.0.0.1
    dev.mycompany.com: 127.0.0.1

# Customize checkout
checkout:
  post:
    - git submodule sync
    - git submodule update --init --recursive

# Customize dependencies
dependencies:
  pre:
    # OS extra info
    - uname -a
    - ldd --version
    - lsb_release -d

    # Install and check Python 2 and 3
    - sudo apt-get update
    - sudo apt-get install -y python-support
    - sudo apt-get install -y python-tk
    - sudo apt-get install -y python3-setuptools
    - sudo apt-get install -y python3-dev
    - sudo apt-get install -y python3-tk
    - sudo easy_install3 pip
    - python --version
    - python -c "import struct; print(struct.calcsize('P') * 8)"
    - pip2 --version
    - python3 --version
    - python3 -c "import struct; print(struct.calcsize('P') * 8)"
    - pip3 --version

    # The GLIBC version might have been updated with apt-get installs
    - ldd --version

    # Python packages (built on Python 3, tests run both 2 and 3)
    - sudo pip2 install awscli
    - sudo pip2 install mock
    #- sudo pip2 install pydocstyle
    - sudo pip2 install requests --upgrade
    - sudo pip2 install coverage
    - sudo pip3 install requests --upgrade
    - sudo pip3 install coverage
    - sudo pip3 install mkdocs
    - sudo pip3 install pyinstaller
    - pyinstaller --version
    - pip2 freeze
    # A current issue with pip causes this command to fail
    # https://github.com/pypa/pip/issues/3681
    # Fixed on the 26 May 2016, waiting for release > 8.1.2
    #- pip3 freeze

    # Check node.js versions
    - node --version
    - node -p "process.arch"
    - npm --version

  override:
    # Build and pack, each command executed from project root
    - cd blockly && python build.py
    - python3 package/build_docs.py
    - python3 package/build_pyinstaller.py linux
    - cd package/electron && npm install
    - cd package/electron && npm run release
    - python3 package/pack_ardublockly.py

# Customize test commands
test:
  override:
    - python -m coverage run ardublocklyserver/tests/run_all.py
    - python -m coverage report
    - python3 -m coverage run ardublocklyserver/tests/run_all.py
    - python3 -m coverage report
    #- pydocstyle ardublocklyserver --match-dir='ardublocklyserver'

general:
  artifacts:
    - "releases/*"

# Get the releases files into the AWS S3 bucket
deployment:
  master:
    branch: /.*/
    commands:
      - export AWS_DEFAULT_REGION=us-west-2 && cd releases && for entry in *; do aws s3 cp $entry s3://ardublockly-builds/linux/$entry; done
