language: php

addons:
    apt:
        packages:
            - jpegoptim
            - libjpeg-progs
            - optipng

sudo: false

cache:
    directories:
        - $HOME/.composer/cache/files

php:
    - 5.3
    - 5.4
    - 5.5
    - 5.6
    - 7.0
    - 7.1
    - hhvm

matrix:
    allow_failures:
        - php: hhvm
        - php: 7.1
    include:
        - php: 5.3
          env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable' SYMFONY_DEPRECATIONS_HELPER=weak
        - php: 5.6
          env: DEPENDENCIES=dev

before_script:
    # php deps
    - composer self-update
    - if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
    - composer update $COMPOSER_FLAGS

    # node deps
    - npm install uglify-js@1 && mkdir -p vendor/uglifyjs && mv node_modules vendor/uglifyjs
    - npm install
    - export NODE_VERSION=$(node -v | egrep -o "[0-9]+.[0-9]+.[0-9]+")
    - export UGLIFYJS_BIN=vendor/uglifyjs/node_modules/uglify-js/bin/uglifyjs
    - if [[ "$NODE_VERSION" =~ ^0.[0-9].[0-9]+$|^0.10.[0-9]+$|^0.11.[0-9]$|^0.11.1[0-2]$ ]]; then export AUTOPREFIXER_BIN=node_modules/.bin/autoprefixer; else export AUTOPREFIXER_BIN=node_modules/.bin/autoprefixer-cli; fi;

    # java deps
    - mkdir -p vendor/java
    - wget http://dl.google.com/closure-compiler/compiler-latest.zip && unzip compiler-latest.zip -d vendor/java/compiler && mv vendor/java/compiler/closure-compiler-*.jar vendor/java/compiler/compiler.jar
    - export CLOSURE_JAR=vendor/java/compiler/compiler.jar
    - wget https://github.com/google/closure-stylesheets/releases/download/v1.4.0/closure-stylesheets.jar && mv closure-stylesheets.jar vendor/java
    - export GSS_JAR=vendor/java/closure-stylesheets.jar
#    TODO find the new URL for the cssembed JAR
#    - wget https://github.com/downloads/nzakas/cssembed/cssembed-0.4.5.jar && mv cssembed-0.4.5.jar vendor/java
#    - export CSSEMBED_JAR=vendor/java/cssembed-0.4.5.jar
    - wget http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.7.zip && unzip yuicompressor-2.4.7.zip -d vendor/java
    - export YUI_COMPRESSOR_JAR=vendor/java/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar

    # ruby deps
    - bundle install

    # other deps

    - wget -q http://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-linux-x64-release.zip && unzip dartsdk-linux-x64-release.zip && mv dart-sdk vendor
    - export DART_BIN=vendor/dart-sdk/bin/dart2js

    - wget -q http://static.jonof.id.au/dl/kenutils/pngout-20130221-linux.tar.gz && tar -xzf pngout-20130221-linux.tar.gz && mv pngout-20130221-linux vendor
    - export PNGOUT_BIN=vendor/pngout-20130221-linux/x86_64/pngout

script: ./bin/phpunit -v
