language: java
services:
  - mysql

install: true

addons:
  apt:
    sources:
      - mysql-5.7-trusty
    packages:
      - mysql-server
      - mysql-client

before_install:
  - chmod +x pandamonium-theorem-prover/gradlew
  - cd pandamonium-theorem-prover

before_script:
  - mysql_upgrade --force -uroot
  - mysql -u root -e 'CREATE DATABASE IF NOT EXISTS pandamonium;'
  - mysql -u root -e "CREATE USER 'panda'@'localhost' IDENTIFIED BY 'secret';"
  - mysql -u root -e "GRANT ALL PRIVILEGES ON *.* to 'panda'@'localhost';"
  - mysql -u root pandamonium < persistence/scripts/mysql/local_development.sql

stages:
  - name: Load Database
  - name: Build
  - name: Unit Tests
  - name: Integration Tests

jobs:
  include:
    - stage: Load Database
      script: ./gradlew loaddb
    - stage: Build
      script: ./gradlew build
    - stage: Unit Tests
      script: ./gradlew test
    - stage: Integration Tests
      script: ./gradlew integrationTest
