# See pom.xml for information about building

language: java

# Build twice
# 1) build with no testing, this is what gets released
# 2) apply a patch to enable testing, this is what is tested
# We do this because we don't want to have 2x as many projects that would
# be required to support tests in fragments. This is a solution to
# maintain the traditional PyDev development model
# NOTE: If you add more matrix entries, review travisupload so that
# they don't squash each other on S3

env:
  matrix:
    - PYDEV_TEST=true
    - PYDEV_TEST=false
  global:
    # Set the DISPLAY to match the one started with xvfb below
    - "DISPLAY=:99.0"

    # These environment variables are used by s3cmd and ./make_s3cfg to
    # access the S3 bucket for storing build results and caching m2 repository
    - ARTIFACTS_S3_BUCKET=pydevbuilds2
    - ARTIFACTS_AWS_REGION=us-east-1
        # ARTIFACTS_AWS_ACCESS_KEY_ID=
    - secure: "U9AGWmSTwqa2DrmDSBZX6lHkXkSBkxnToj2QtEe3oZmcJYrMi5lX2I4SWMgBu08GCjkBLi4ztRvfoVyE+L5G90QN8Q2+FQNMnoX+mDzcVBOBuFEZBIOBnFrAfGDtYJl0OnTRezZMJY1hk8pBuF8qBSytCNYT7Pz7lDg94o+Oxn0="
        # ARTIFACTS_AWS_SECRET_ACCESS_KEY=
    - secure: "Pfq+chN3NUoFhPXDdFoksEYZdJjmtFctdSQksaY+c/YbfFmWAe/8VMekj01IiFeNIFz3WoissaYvF/knJFaJl6VCJY825rwHWuTD2eCSYbpTXLE4n0K9WO63I4dpWrXlMREFmn4M5bcA7KNuIbQSFv2Tdhhmk/gZQTW45uTXNXo="

    # We set the PYDEV_TEST_PLATFORM to control which TestDependent we use (i.e. TestDependent.travis.properties)
    - PYDEV_TEST_PLATFORM=travis

    # The top-level pom has a profile to sign the jars if the following environment variables are set
    # The keystore is downloaded in before_install
    - SIGN_KEYSTORE=~/pydev.keystore
    - SIGN_ALIAS=kc_eclipse
        # SIGN_STOREPASS=
    - secure: "T6mFt4Gn2ix6OowWbMtSG0skKf27WoaQCxy0s+q1rBTF1FN8zJARveAR2hpvjcyRDBeQdCynvZWL7sawQL7xzUUniCsfFtpHl7fro66IzhIBZGkS8Ra/wprGOxQ56ZCNB/QJ3f7gnisrQg+G2mhlV1U7RsBMNYfRdKsOUwJ0wXs="
        # SIGN_KEYPASS=
    - secure: "V62QbNAT4SfRSUUEE1nlpx9UmjBnW54SnMf+ZR4stM+kBZxZUT7u3XatOABNupb052xJTYGISEjPqXDZ4VqOjM6fUu902LOCCZ0U1ojyOUdpai2gFz2ajtMTzg7MFXFFuYytZ9KRSalKLOzRylXroZVJK7DUtC9NMih6dCANvbA="

before_install:
  # Make sure package list is up to date before we start anything else
  - "sudo apt-get update -qq"

  # Use s3cmd to communicate with AWS S3, s3cmd uses ~/.s3cfg for keys and config...
  - "sudo apt-get install -qq s3cmd"
  # ...so make one based on the ARTIFACTS_AWS_* variables above
  - "./make_s3cfg.sh"

  # Start an XServer so that we can run tests using the Display
  - "sh -e /etc/init.d/xvfb start"

  # Install the the m2 repo cached on S3
  - "./travism2_install.sh"

  # Get the keystore (see SIGN_* variables above). If we fail to get the file, the build
  # proceeds, but jars won't be signed
  - "./travisgetkeystore.sh"


install:
  # Build, but don't test
  - "./mvnts.sh install -Dtycho.localArtifacts=ignore -DskipTests=true -B"

before_script:
  # Apply the changes needed to test with Tycho
  - if [ "$PYDEV_TEST" == "true" ]; then git apply --whitespace=nowarn test_with_tycho.patch; fi
  # Load up all the dependencies needed to test PyDev
  - if [ "$PYDEV_TEST" == "true" ]; then ./travisdeps.sh; fi

script:
  # Run the integration tests (all Tycho tests are integration tests)
  - if [ "$PYDEV_TEST" == "true" ]; then ./mvnts.sh integration-test -B; fi

after_script:
  # Upload the build results (p2 repo, test results, etc)
  - "./travisupload.sh"

  # Upload the update m2 repo cache
  - "./travism2_upload.sh"
