machine:
  environment:
    # NOTE if updating yarn version, don't forget about code deploy setting as well
    YARN_VERSION: 0.21.3
    PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"

dependencies:
  cache_directories:
    - ~/.yarn
    - ~/.cache/yarn
  pre:
    - ~/nvm/nvm.sh && nvm install && nvm use && nvm alias default $(nvm current)
    - |
      if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
        curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
      fi
    - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
  override:
    - yarn install

test:
  override:
    - mkdir -p $CIRCLE_TEST_REPORTS/junit
    - nvm use && yarn test:ci:
        environment:
          TEST_REPORT_PATH: $CIRCLE_TEST_REPORTS/junit

general:
  artifacts:
    - ./coverage

deployment:
  develop:
    branch: feature/content-maps
    codedeploy:
      LighthouseApp:
        application_root: /
        revision_location:
          revision_type: S3
          s3_location:
            bucket: "revisions-lighthouse-app"
            key_pattern: "{BRANCH}-{COMMIT}-{BUILD_NUM}"
        region: us-east-1
        deployment_group: develop
        deployment_config: CodeDeployDefault.AllAtOnce
  production-us:
    branch: master
    codedeploy:
      LighthouseApp:
        application_root: /
        revision_location:
          revision_type: S3
          s3_location:
            bucket: "revisions-lighthouse-app"
            key_pattern: "{BRANCH}-{COMMIT}-{BUILD_NUM}"
        region: us-east-1
        deployment_group: production
        deployment_config: CodeDeployDefault.AllAtOnce
  production-au:
    branch: master
    codedeploy:
      LighthouseApp-AU:
        application_root: /
        revision_location:
          revision_type: S3
          s3_location:
            bucket: "revisions-lighthouse-app-au"
            key_pattern: "{BRANCH}-{COMMIT}-{BUILD_NUM}"
        region: ap-southeast-2
        deployment_group: production
        deployment_config: CodeDeployDefault.AllAtOnce
