# © Copyright IBM Corporation 2018
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

sudo: required
language: go

go:
  - "1.10"

services:
  - docker

go_import_path: "github.com/ibm-messaging/mq-container"

cache:
  directories:
    - downloads

env:
  - BASE_IMAGE=ubuntu:16.04
  - BASE_IMAGE=centos:latest

jobs:
  include:
    - if: type IN (pull_request)
      env: DOCKER_DOWNGRADE="docker save -o images.tar mqadvanced-server-dev mq-dev-jms-test &&
        sudo apt-get autoremove -y docker-ce &&
        curl -fsSL \"https://apt.dockerproject.org/gpg\" | sudo apt-key add - &&
        sudo apt-add-repository \"deb https://apt.dockerproject.org/repo ubuntu-$(lsb_release -cs) main\" &&
        sudo apt-get update &&
        sudo apt-get install docker-engine=1.12.6-0~ubuntu-$(lsb_release -cs) &&
        docker load -q -i images.tar &&
        export DOCKER_API_VERSION=\"1.24\""
    - env: DOCKER_DOWNGRADE="echo nothing to be done"

before_install:
  - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  - sudo apt-get update
  - sudo apt-get -y install docker-ce
  - curl https://glide.sh/get | sh
  - sudo curl -Lo /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64
  - sudo chmod +x /usr/local/bin/dep

install:
  - echo nothing

script:
  - make deps
  - make build-devserver
  - make build-devjmstest
  - eval "$DOCKER_DOWNGRADE"
  - make test-devserver

after_success:
  - go get golang.org/x/lint/golint
  - make lint
