---
language: node_js
node_js:
- '0.10'
cache:
  directories:
  - node_modules
before_install:
- |
    if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
      PR_FIRST=$(curl -s https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST}.patch | head -1 | grep -o -E '\b[0-9a-f]{40}\b' | tr -d '\n')
      TRAVIS_COMMIT_RANGE=$PR_FIRST^..$TRAVIS_COMMIT
    fi
    git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/' || {
      echo "Only docs were updated, stopping build process."
      exit
    }
script:
- |
    grunt $TEST_TYPE
after_script:
- |
    if [ "$TEST_TYPE" = test ] && [ "$SERVER" ]; then
      grunt build
      curl \
        -F "react=@build/react.js" \
        -F "react.min=@build/react.min.js" \
        -F "transformer=@build/JSXTransformer.js" \
        -F "react-with-addons=@build/react-with-addons.js" \
        -F "react-with-addons.min=@build/react-with-addons.min.js" \
        -F "npm-react=@build/react.tgz" \
        -F "npm-react-tools=@build/react-tools.tgz" \
        -F "commit=$TRAVIS_COMMIT" \
        -F "date=`git log --format='%ct' -1`" \
        -F "pull_request=$TRAVIS_PULL_REQUEST" \
        -F "token=$SECRET_TOKEN" \
        -F "branch=$TRAVIS_BRANCH" \
        $SERVER
    fi
env:
  matrix:
  - TEST_TYPE=test
  - TEST_TYPE=lint
  - TEST_TYPE=test:webdriver:saucelabs:modern
  global:
  # SERVER
  - secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
  # SECRET_TOKEN
  - secure: dkpPW+VnoqC/okhRdV90m36NcyBFhcwEKL3bNFExAwi0dXnFao8RoFlvnwiPlA23h2faROkMIetXlti6Aju08BgUFV+f9aL6vLyU7gUent4Nd3413zf2fwDtXIWIETg6uLnOpSykGKgCAT/hY3Q2oPLqOoY0OxfgnbqwxkxljrE=
matrix:
  fast_finish: true
  allow_failures:
    - env: TEST_TYPE=lint
    - env: TEST_TYPE=test:coverage
    - env: TEST_TYPE=perf:full
    - env: TEST_TYPE=test:webdriver:saucelabs:modern
    - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
    - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
    - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
    - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
    - env: TEST_TYPE=test:webdriver:saucelabs:ios
    - env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
notifications:
  irc:
    use_notice: true
    skip_join: true
    on_success: change
    on_failure: change
    channels:
    - chat.freenode.net#reactjs
