dependencies:
  cache_directories:
    - "~/.stack"
    - ".stack-work"
  pre:
    # Downgrade GCC due to `direct-sqlite` compilation error:
    # See: http://stackoverflow.com/a/34811594/125305
    - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
    - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
    - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 10
    - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 10

    - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 575159689BEFB442
    - echo 'deb http://download.fpcomplete.com/ubuntu precise main' | sudo tee /etc/apt/sources.list.d/fpco.list
    - sudo apt-get update && sudo apt-get install stack -y
  override:
    - stack setup
    - stack build --ghc-options="-Wall -Werror -O3"
  post:
    - ./ops/keter-bundle.sh
    - cp zoomhub.keter $CIRCLE_ARTIFACTS

test:
  override:
    - stack test

deployment:
  staging:
    branch: /^((?!master).)*$/  # all branches but master
    commands:
      - ./ops/deploy.sh staging.zoomhub.net

  production:
    branch: master
    commands:
      - ./ops/deploy.sh staging.zoomhub.net
      - ./ops/deploy.sh zoomhub.net

notify:
  webhooks:
    - url: https://webhooks.gitter.im/e/a19b5d5a13ef5d90d340

dependencies:
  cache_directories:
    - "~/.stack"
    - ".stack-work"
  override:
    - stack build --ghc-options="-Wall -Werror -O3"
  post:
    - ./ops/keter-bundle.sh
    - cp zoomhub.keter $CIRCLE_ARTIFACTS

test:
  override:
    - stack test

deployment:
  staging:
    branch: /^((?!master).)*$/  # all branches but master
    commands:
      - ./ops/deploy.sh staging.zoomhub.net

  production:
    branch: master
    commands:
      - ./ops/deploy.sh staging.zoomhub.net
      - ./ops/deploy.sh zoomhub.net

notify:
  webhooks:
    - url: https://webhooks.gitter.im/e/a19b5d5a13ef5d90d340

Simplify `stack` setup on Circle
Simplify `stack` setup on Circle
