workspace:
  base: /srv/app
  path: src/code.gitea.io/gitea

pipeline:
  test:
    image: webhippie/golang:${GO_VERSION}
    pull: true
    environment:
      CGO_ENABLED: 1
      TAGS: cert sqlite pam miniwinsvc
    commands:
      - apk -U add linux-pam-dev openssh-client

      - make clean
      - make vet
      # - make lint
      - make test
      - make build

  test-mysql:
    image: webhippie/golang:${GO_VERSION}
    pull: true
    commands:
     - make test-mysql
    when:
      event: push

  test-pgsql:
    image: webhippie/golang:${GO_VERSION}
    pull: true
    commands:
     - make test-pgsql
    when:
      event: push

  updater:
    image: karalabe/xgo-latest:latest
    pull: true
    commands:
      - make publish
    when:
      event: [ push, tag ]
      branch: [ master, refs/tags/* ]
      matrix:
        GO_VERSION: 1.7

  coverage:
    image: plugins/coverage
    server: https://coverage.gitea.io
    when:
      matrix:
        GO_VERSION: 1.7

  docker:
    image: plugins/docker
    repo: gitea/gitea
    tags: [ '${TAG}' ]
    when:
      event: tag
      branch: refs/tags/*
      matrix:
        GO_VERSION: 1.7

  docker:
    image: plugins/docker
    repo: gitea/gitea
    tags: [ 'latest' ]
    when:
      event: push
      branch: master
      matrix:
        GO_VERSION: 1.7

  release:
    image: plugins/s3
    path_style: true
    source: dist/release/
    target: /lgtm/master
    when:
      event: push
      branch: master
      matrix:
        GO_VERSION: 1.7

  release:
    image: plugins/s3
    path_style: true
    source: dist/release/
    target: /lgtm/$$TAG
    when:
      event: tag
      branch: refs/tags/*
      matrix:
        GO_VERSION: 1.7

  latest:
    image: plugins/s3
    path_style: true
    source: dist/latest/
    target: /lgtm/latest
    when:
      event: tag
      branch: refs/tags/*
      matrix:
        GO_VERSION: 1.7

  github:
    image: plugins/github-release
    files:
      - dist/release/*
    when:
      event: tag
      branch: refs/tags/*
      matrix:
        GO_VERSION: 1.7

  gitter:
    image: plugins/gitter

services:
  mysql:
    image: mysql:5.7
    environment:
      - MYSQL_DATABASE=test
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    when:
      event: push

  pgsql:
    image: postgres:9.5
    environment:
      - POSTGRES_DB=test
    when:
      event: push

matrix:
  GO_VERSION:
    - 1.6
    - 1.7