---
kind: pipeline
name: build

platform:
  os: linux
  arch: amd64

steps:
- name: test
  pull: always
  image: golang:1.14.2
  commands:
  - make test

- name: lint
  pull: always
  image: golang:1.14.2
  commands:
  - make lint
  - git diff --exit-code

- name: build
  pull: always
  image: golang:1.14.2
  commands:
  - make thanos-receive-controller

- name: generate
  pull: always
  image: quay.io/coreos/jsonnet-ci:latest
  commands:
  - make generate validate --always-make
  - git diff --exit-code

- name: tags
  image: golang:1.14.2
  commands:
  - echo -n "$(git rev-parse --abbrev-ref HEAD | tr / -)-$(date +%Y-%m-%d)-$(git rev-parse --short HEAD),latest" > .tags
  when:
    branch:
    - master
    event:
    - push

- name: docker
  image: plugins/docker
  settings:
    registry: quay.io
    repo: quay.io/observatorium/thanos-receive-controller
    password:
      from_secret: quay_password
    username:
      from_secret: quay_username
  when:
    branch:
    - master
    event:
    - push

- name: docker-test
  image: plugins/docker
  settings:
    dry_run: true
    repo: quay.io/observatorium/thanos-receive-controller
  when:
    branch:
    event:
    - pull-request
