## Customize the test machine
machine:

  # Timezone
  timezone:
    America/Los_Angeles # Set the timezone

  # Add some environment variables
  environment:
    CIRCLE_ENV: test
    CXX: g++-4.8
    DISPLAY: :99.0
    NPM_PREFIX: /home/ubuntu/nvm/v0.10.33

#general:
#  build_dir: helloworld

## Customize dependencies
dependencies:
  cache_directories:
    - ~/.meteor # relative to the user's home directory
    - ~/nvm/v0.10.33/lib/node_modules/starrynight
    - ~/nvm/v0.10.33/bin/starrynight

  pre:
    # Install Starrynight unless it is cached
    - if [ ! -e ~/nvm/v0.10.33/bin/starrynight ]; then npm install -g starrynight; else echo "Starrynight seems to be cached"; fi;
    # Install  Meteor
    - mkdir -p ${HOME}/.meteor
    # If Meteor is already cached, do not need to build it again.
    - if [ ! -e ${HOME}/.meteor/meteor ]; then curl https://install.meteor.com | /bin/sh; else echo "Meteor seems to be cached"; fi;
    # Link the meteor executable into /usr/bin
    - sudo ln -s $HOME/.meteor/meteor /usr/bin/meteor
    # Check if the helloworld directory already exists, if it doesn't, create the helloworld app
    - if [ ! -e ${HOME}/helloworld ]; then meteor create --release METEOR@1.1.0.3 helloworld; else echo "helloworld app seems to be cached"; fi;

  override:
    - cd helloworld
    - cd helloworld && ls -la
    - cd helloworld && rm helloworld.*
    - cd helloworld && meteor add anti:gagarin@0.4.11 session meteor-platform clinical:theming clinical:default-theme clinical:router clinical:router-default-config clinical:active-layout clinical:active-layout-reset clinical:active-layout-pagescreen-config grove:less
    - cd helloworld && git clone http://github.com/clinical-meteor/router-middleware-stack packages/router-middleware-stack
    - cd helloworld && meteor add clinical:router clinical:router-middleware-stack
    - cd helloworld/packages && ls -la
    - cd helloworld/packages/router-middleware-stack && ls -la
    - cd helloworld/packages/router-middleware-stack/tests && ls -la
    - cd helloworld/packages/router-middleware-stack/tests/gagarin && ls -la
    - cd helloworld && starrynight autoconfig

## Customize test commands
test:
  pre:
    - cd helloworld && meteor:
          background: true
    - sleep 80
  override:
    - cd helloworld && starrynight run-tests --type package-verification
