# Created with package:mono_repo v2.3.0
language: dart

# Custom configuration
sudo: required
addons:
  chrome: stable
env:
  global: FORCE_TEST_EXIT=true
after_failure:
  - tool/report_failure.sh

jobs:
  include:
    - stage: analyze_and_format
      name: "SDK: 2.3.0; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: `dartanalyzer --fatal-warnings .`"
      dart: "2.3.0"
      os: linux
      env: PKGS="pkgs/test pkgs/test_api pkgs/test_core"
      script: ./tool/travis.sh dartanalyzer_1
    - stage: analyze_and_format
      name: "SDK: dev; PKGS: pkgs/test, pkgs/test_api, pkgs/test_core; TASKS: [`dartfmt -n --set-exit-if-changed .`, `dartanalyzer --fatal-infos --fatal-warnings .`]"
      dart: dev
      os: linux
      env: PKGS="pkgs/test pkgs/test_api pkgs/test_core"
      script: ./tool/travis.sh dartfmt dartanalyzer_0
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 0`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test"
      script: ./tool/travis.sh command_0
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 1`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test"
      script: ./tool/travis.sh command_1
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 2`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test"
      script: ./tool/travis.sh command_2
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 3`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test"
      script: ./tool/travis.sh command_3
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test; TASKS: `xvfb-run -s \"-screen 0 1024x768x24\" pub run test --preset travis --total-shards 5 --shard-index 4`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test"
      script: ./tool/travis.sh command_4
    - stage: unit_test
      name: "SDK: dev; PKG: pkgs/test_api; TASKS: `pub run test --preset travis`"
      dart: dev
      os: linux
      env: PKGS="pkgs/test_api"
      script: ./tool/travis.sh test

stages:
  - analyze_and_format
  - unit_test

# Only building master means that we don't run two builds for each pull request.
branches:
  only:
    - master

cache:
  directories:
    - "$HOME/.pub-cache"
