#########################
# MANAGED BY MODULESYNC #
#########################

stages:
  - build
  - test
  - upload

variables:
  DOCKER_IMAGE_BASE: registry.icinga.com/build-docker

.build: &build
  stage: build
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
  script:
    - icinga-build-package
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - ccache/
      - 'icingaweb2-module-nagvis.git'
  artifacts:
    paths:
      - build/*
    expire_in: 1 week

.test: &test
  stage: test
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/${DOCKER_IMAGE}
  script:
    - find build/
    - icinga-build-test

.upload: &upload
  stage: upload
  tags:
    - docker
  image: ${DOCKER_IMAGE_BASE}/upload
  script:
    - find build/
    - icinga-build-upload-aptly
  only:
    - tags

###################################
# Debian
###################################

build/debian/buster:
  <<: *build
  variables:
    DOCKER_IMAGE: debian/buster

test/debian/buster:
  <<: *test
  variables:
    DOCKER_IMAGE: debian/buster
  dependencies:
    - build/debian/buster

upload/debian/buster:
  <<: *upload
  dependencies:
    - build/debian/buster

build/debian/stretch:
  <<: *build
  variables:
    DOCKER_IMAGE: debian/stretch

test/debian/stretch:
  <<: *test
  variables:
    DOCKER_IMAGE: debian/stretch
  dependencies:
    - build/debian/stretch

upload/debian/stretch:
  <<: *upload
  dependencies:
    - build/debian/stretch
###################################
# Ubuntu
###################################

build/ubuntu/groovy:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/groovy

test/ubuntu/groovy:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/groovy
  dependencies:
    - build/ubuntu/groovy

upload/ubuntu/groovy:
  <<: *upload
  dependencies:
    - build/ubuntu/groovy

build/ubuntu/focal:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/focal

test/ubuntu/focal:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/focal
  dependencies:
    - build/ubuntu/focal

upload/ubuntu/focal:
  <<: *upload
  dependencies:
    - build/ubuntu/focal

build/ubuntu/bionic:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/bionic

test/ubuntu/bionic:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/bionic
  dependencies:
    - build/ubuntu/bionic

upload/ubuntu/bionic:
  <<: *upload
  dependencies:
    - build/ubuntu/bionic

build/ubuntu/xenial:
  <<: *build
  variables:
    DOCKER_IMAGE: ubuntu/xenial

test/ubuntu/xenial:
  <<: *test
  variables:
    DOCKER_IMAGE: ubuntu/xenial
  dependencies:
    - build/ubuntu/xenial

upload/ubuntu/xenial:
  <<: *upload
  dependencies:
    - build/ubuntu/xenial
