sudo: required
services:
  - docker 

language: go

go:
  - 1.5.3
  - 1.6

env:
  - DEX_TEST_DSN="postgres://postgres@127.0.0.1:15432/postgres?sslmode=disable" ISOLATED=true
    DEX_TEST_LDAP_HOST="tlstest.local:1389"
    DEX_TEST_LDAP_BINDNAME="cn=admin,dc=example,dc=org"
    DEX_TEST_LDAP_BINDPASS="admin"

install:
  - go get golang.org/x/tools/cmd/cover
  - docker pull quay.io/coreos/postgres
  - docker pull osixia/openldap

script:
  - docker run -d -p 127.0.0.1:15432:5432 quay.io/coreos/postgres
  - LDAPCONTAINER=`docker run -e LDAP_TLS_PROTOCOL_MIN=3.0 -e LDAP_TLS_CIPHER_SUITE=NORMAL -d -p 127.0.0.1:1389:389 -p 127.0.0.1:1636:636 -h tlstest.local osixia/openldap`
  - ./build
  - ./test
  - docker cp ${LDAPCONTAINER}:container/service/:cfssl/assets/default-ca/default-ca.pem /tmp/openldap-ca.pem
  - docker cp ${LDAPCONTAINER}:container/service/slapd/assets/certs/ldap.key /tmp/ldap.key
  - chmod 644 /tmp/ldap.key
  - docker cp ${LDAPCONTAINER}:container/service/slapd/assets/certs/ldap.crt /tmp/ldap.crt
  - sudo sh -c 'echo "127.0.0.1 tlstest.local" >> /etc/hosts'
  - ./test-functional
  - DEX_TEST_DSN="sqlite3://:memory:" ./test-functional

deploy:
  provider: script
  script: "./build-docker-push"
  skip_cleanup: true
  on:
    branch: master
    go: '1.5.3'
    condition: "$TRAVIS_PULL_REQUEST = false"

notifications:
  email: false