dependencies:
  cache_directories:
    - "~/.stack"
  pre:
    - 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"
  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/84a0591a52491268102f

dependencies:
  cache_directories:
    - "~/.stack"
  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"
  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/84a0591a52491268102f

Downgrade GCC due to compilation error
Downgrade GCC due to compilation error

```
Configuring direct-sqlite-2.3.16...
Building direct-sqlite-2.3.16...
Preprocessing library direct-sqlite-2.3.16...
[1 of 4] Compiling Database.SQLite3.Bindings.Types ( .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Database/SQLite3/Bindings/Types.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Database/SQLite3/Bindings/Types.o )
[2 of 4] Compiling Database.SQLite3.Bindings ( Database/SQLite3/Bindings.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Database/SQLite3/Bindings.o )
/tmp/ghc13096_0/ghc_13.o: In function `rcLN_closure:
```
