language: python
python:
  - 3.4
  - 3.5
  - 3.6
  - 3.7
  - 3.8
services:
 - docker
cache: pip
before_install:
  - pip install --upgrade pip wheel
  - pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium
  # - docker build -t zeronet .
  # - docker run -d -v $PWD:/root/data -p 15441:15441 -p 127.0.0.1:43110:43110 zeronet
install:
 - pip install --upgrade -r requirements.txt
 - pip list
before_script:
  - openssl version -a
  # Add an IPv6 config - see the corresponding Travis issue
  # https://github.com/travis-ci/travis-ci/issues/8361
  - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
      sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
    fi
script:
 - catchsegv python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini
 - export ZERONET_LOG_DIR="log/CryptMessage"; catchsegv python -m pytest -x plugins/CryptMessage/Test
 - export ZERONET_LOG_DIR="log/Bigfile"; catchsegv python -m pytest -x plugins/Bigfile/Test
 - export ZERONET_LOG_DIR="log/AnnounceLocal"; catchsegv python -m pytest -x plugins/AnnounceLocal/Test
 - export ZERONET_LOG_DIR="log/OptionalManager"; catchsegv python -m pytest -x plugins/OptionalManager/Test
 - export ZERONET_LOG_DIR="log/Multiuser"; mv plugins/disabled-Multiuser plugins/Multiuser && catchsegv python -m pytest -x plugins/Multiuser/Test
 - export ZERONET_LOG_DIR="log/Bootstrapper"; mv plugins/disabled-Bootstrapper plugins/Bootstrapper && catchsegv python -m pytest -x plugins/Bootstrapper/Test
 - find src -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
 - find plugins -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')"
 - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/
after_failure:
  - zip -r log.zip log/
  - curl --upload-file ./log.zip https://transfer.sh/log.zip 
after_success:
  - codecov
  - coveralls --rcfile=src/Test/coverage.ini
notifications:
  email:
    recipients:
      hello@zeronet.io
    on_success: change