dist: xenial
language: python
cache: pip

services:
  - postgresql
  - mysql

python:
  - "3.7"

env:
  - TESTING_DB=sqlite3
  - TESTING_DB=postgresql
  - TESTING_DB=mysql

before_install: 

    # - psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE evennia TO evennia;"
  - psql --version
  - psql -U postgres -c "CREATE DATABASE evennia;"
  - psql -U postgres -c "CREATE USER evennia WITH PASSWORD 'password';"
  - psql -U postgres -c "ALTER USER evennia CREATEDB;"
  - mysql --version
  - mysql -u root -e "CREATE DATABASE evennia CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
  - mysql -u root -e "CREATE USER 'evennia'@'localhost' IDENTIFIED BY 'password';"
  - mysql -u root -e "GRANT ALL ON *.* TO 'evennia'@'localhost' IDENTIFIED BY 'password';"

install:
  - pip install psycopg2-binary
  - pip install mysqlclient
  - pip install coveralls
  - pip install codacy-coverage
  - pip install -e .

before_script:
  - evennia --init testing_mygame
  - cp .travis/${TESTING_DB}_settings.py testing_mygame/server/conf/settings.py
  - cd testing_mygame
  - evennia migrate
  - evennia collectstatic --noinput

script:
  - coverage run --source=../evennia --omit=*/migrations/*,*/urls.py,*/test*.py,*.sh,*.txt,*.md,*.pyc,*.service ../bin/unix/evennia test --settings=settings --keepdb evennia

after_success:
  - coveralls
  - coverage xml
  - python-codacy-coverage -r coverage.xml
