language: python
sudo: false
dist: xenial
matrix:
  include:
    - python: 3.7
addons:
  firefox: latest
  chrome: stable
before_install:
  - "sudo service mysql start"
  - "sudo mysql -e 'CREATE DATABASE IF NOT EXISTS test_db;'"
  - "sudo mysql -h 127.0.0.1 -u root test_db < seleniumbase/core/create_db_tables.sql"
  - "mysqladmin -u root password test"
  # - "mysqladmin -u root -p'old_password' password new_password"
  - "sudo service mysql restart"
install:
  - "pip install --upgrade pip"
  - "pip install -r requirements.txt --upgrade"
  - "python setup.py install"
  - "sudo rm -f /etc/boto.cfg"
before_script:
  - "flake8 --exclude=temp"
  # - "wget https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip && unzip chromedriver_linux64.zip && sudo cp chromedriver /usr/local/bin/ && sudo chmod +x /usr/local/bin/chromedriver"
  # - "wget https://github.com/mozilla/geckodriver/releases/download/v0.27.0/geckodriver-v0.27.0-linux64.tar.gz -O /tmp/geckodriver.tar.gz && tar -C /opt -xzf /tmp/geckodriver.tar.gz && sudo chmod 755 /opt/geckodriver && sudo ln -fs /opt/geckodriver /usr/bin/geckodriver && sudo ln -fs /opt/geckodriver /usr/local/bin/geckodriver"
  # - "wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 && tar -xvf ./phantomjs-2.1.1-linux-x86_64.tar.bz2 && export PATH=$PWD/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
  - "seleniumbase"
  - "seleniumbase install chromedriver"
  # - "seleniumbase install geckodriver"
  - "seleniumbase mkdir browser_tests"
script:
  - "pytest browser_tests/boilerplates/boilerplate_test.py --headless --with-db_reporting"
  - "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting"
  - "nosetests examples/boilerplates/boilerplate_test.py --browser=chrome --headless"
  # - "pytest examples/my_first_test.py --browser=firefox -s --headless --with-db_reporting"
  - "pytest examples/my_first_test.py --browser=chrome -s --headless --with-db_reporting --demo_mode --demo_sleep=0.2"
  - "pytest examples/test_inspect_html.py --browser=chrome -s --headless --with-db_reporting"
  - "pytest examples/tour_examples/google_tour.py -s --headless --with-db_reporting"
  - "sudo mysql --password=test -e 'select test_address,browser,state,start_time,runtime from test_db.test_run_data'"
#after_script:
#  - "sudo mysql -e 'DROP DATABASE test_db;'"
notifications:
  email: false
