Skip to content
Snippets Groups Projects
.gitlab-ci.yml 9.77 KiB
workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"'
      when: never
    - when: always

stages:
  - build
  - test
  - check
  - deploy

default:
  tags:
    - exec-docker

.dind:
  tags:
    - exec-dind
  # see https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
  # for image usage and settings for building with TLS and docker in docker
  image: docker:19.03.1
  services:
    - docker:19.03.1-dind
  variables:
    DOCKER_TLS_CERTDIR: "/certs"

.kaniko-push:
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"${CR_HOST}\":{\"auth\":\"$(printf "%s:%s" "${CR_USER}" "${CR_PW}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
    - DOCKER_TAG_NAME=$(echo $CI_COMMIT_REF_SLUG- | sed 's/^master-$//')
    - "[ ! $CI_COMMIT_TAG ] && KANIKO_D=\"$KANIKO_D -d $CR_HOST/$CR_ORG/$IMAGE_NAME:${DOCKER_TAG_NAME}latest\""
    - "[ ! $CI_COMMIT_TAG ] && KANIKO_D=\"$KANIKO_D -d $CR_HOST/$CR_ORG/$IMAGE_NAME:$DOCKER_TAG_NAME$CI_COMMIT_SHORT_SHA\""
    - "[ $CI_COMMIT_TAG ] && KANIKO_D=\"$KANIKO_D -d $CR_HOST/$CR_ORG/$IMAGE_NAME:$CI_COMMIT_TAG\""
    - "[ $DOCKERFILE ] && KANIKO_DOCKERFILE=\"--dockerfile $DOCKERFILE\""
    - /kaniko/executor --context `pwd`/$CONTEXT $KANIKO_DOCKERFILE $KANIKO_D


# Theodolite Helm Chart

lint-helm:
  stage: check
  needs: []
  image:
    name: alpine/helm:3.5.2
    entrypoint: [""]
  script: helm lint helm/


# Theodolite Benchmarks

.benchmarks:
  image: openjdk:11-jdk
  variables:
    GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  cache:
    paths:
      - .gradle/wrapper
      - .gradle/caches
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - cd theodolite-benchmarks
  rules:
    - changes:
      - theodolite-benchmarks/**/*
    - when: manual
      allow_failure: true

build-benchmarks:
  stage: build
  extends: .benchmarks
  script: ./gradlew --build-cache assemble
  artifacts:
    paths:
      - "theodolite-benchmarks/build/libs/*.jar"
      - "theodolite-benchmarks/*/build/libs/*.jar"
      - "theodolite-benchmarks/*/build/distributions/*.tar"
    expire_in: 6 hours

test-benchmarks:
  stage: test
  extends: .benchmarks
  needs:
    - build-benchmarks
  script: ./gradlew test --continue
  artifacts:
    reports:
      junit:
        - "theodolite-benchmarks/**/build/test-results/test/TEST-*.xml"

checkstyle-benchmarks:
  stage: check
  extends: .benchmarks
  needs:
    - build-benchmarks
    - test-benchmarks
  script: ./gradlew checkstyle --continue
  artifacts:
    paths:
      - "theodolite-benchmarks/*/build/reports/checkstyle/main.html"
    when: on_failure
    expire_in: 1 day

pmd-benchmarks:
  stage: check
  extends: .benchmarks
  needs:
    - build-benchmarks
    - test-benchmarks
  script: ./gradlew pmd --continue
  artifacts:
    paths:
      - "theodolite-benchmarks/*/build/reports/pmd/*.html"
    when: on_failure
    expire_in: 1 day

spotbugs-benchmarks:
  stage: check
  extends: .benchmarks
  needs:
    - build-benchmarks
    - test-benchmarks
  script: ./gradlew spotbugs --continue
  artifacts:
    paths:
      - "theodolite-benchmarks/*/build/reports/spotbugs/*.html"
    when: on_failure
    expire_in: 1 day

.deploy-benchmarks:
  stage: deploy
  extends:
    - .benchmarks
    - .kaniko-push
  needs:
    - build-benchmarks
    - checkstyle-benchmarks
    - pmd-benchmarks
    - spotbugs-benchmarks
  variables:
    CONTEXT: "/$JAVA_PROJECT_NAME"
  #before_script:
  #  - cd theodolite-benchmarks/$JAVA_PROJECT_NAME
  rules:
    - changes:
      - theodolite-benchmarks/*
      - theodolite-benchmarks/$JAVA_PROJECT_NAME/**/*
      - theodolite-benchmarks/kstreams-commons/**/*
      - theodolite-benchmarks/flink-commons/**/*
      - theodolite-benchmarks/load-generator-commons/**/*
      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $IMAGE_NAME && $JAVA_PROJECT_NAME"
    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW && $IMAGE_NAME && $JAVA_PROJECT_NAME"
      when: manual
      allow_failure: true

deploy-uc1-kstreams:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc1-kstreams-app"
    JAVA_PROJECT_NAME: "uc1-kstreams"

deploy-uc2-kstreams:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc2-kstreams-app"
    JAVA_PROJECT_NAME: "uc2-kstreams"

deploy-uc3-kstreams:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc3-kstreams-app"
    JAVA_PROJECT_NAME: "uc3-kstreams"

deploy-uc4-kstreams:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc4-kstreams-app"
    JAVA_PROJECT_NAME: "uc4-kstreams"

deploy-uc1-flink:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc1-flink"
    JAVA_PROJECT_NAME: "uc1-flink"

deploy-uc2-flink:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc2-flink"
    JAVA_PROJECT_NAME: "uc2-flink"

deploy-uc3-flink:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc3-flink"
    JAVA_PROJECT_NAME: "uc3-flink"

deploy-uc4-flink:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc4-flink"
    JAVA_PROJECT_NAME: "uc4-flink"

deploy-uc1-load-generator:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc1-workload-generator"
    JAVA_PROJECT_NAME: "uc1-load-generator"

deploy-uc2-load-generator:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc2-workload-generator"
    JAVA_PROJECT_NAME: "uc2-load-generator"

deploy-uc3-load-generator:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc3-workload-generator"
    JAVA_PROJECT_NAME: "uc3-load-generator"

deploy-uc4-load-generator:
  extends: .deploy-benchmarks
  variables:
    IMAGE_NAME: "theodolite-uc4-workload-generator"
    JAVA_PROJECT_NAME: "uc4-load-generator"
      

# Theodolite Framework

.theodolite:
  image:
    name: ghcr.io/graalvm/native-image:java11-21.1.0
    entrypoint: [""]
  variables:
    GRADLE_OPTS: "-Dorg.gradle.daemon=false"
  cache:
    paths:
      - .gradle/wrapper
      - .gradle/caches
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - cd theodolite

build-theodolite-jvm:
  stage: build
  extends: .theodolite
  script: ./gradlew --build-cache assemble
  artifacts:
    paths:
      - "theodolite/build/lib/*"
      - "theodolite/build/*-runner.jar"
    expire_in: 6 hours

build-theodolite-native:
  stage: build
  extends: .theodolite
  script:
    - ./gradlew --build-cache assemble -Dquarkus.package.type=native
  when: manual
  artifacts:
    paths:
      - "theodolite/build/*-runner"
    expire_in: 6 hours

test-theodolite:
  stage: test
  extends: .theodolite
  needs:
    - build-theodolite-jvm
    #- build-theodolite-native
  script: ./gradlew test --stacktrace
  artifacts:
    reports:
      junit:
        - "theodolite/**/build/test-results/test/TEST-*.xml"

# Disabled for now
.ktlint-theodolite:
  stage: check
  extends: .theodolite
  needs:
    - build-theodolite-jvm
    - test-theodolite
  script: ./gradlew ktlintCheck --continue

# Disabled for now
.detekt-theodolite: 
  stage: check
  extends: .theodolite
  needs:
    - build-theodolite-jvm
    - test-theodolite
  script: ./gradlew detekt --continue

deploy-theodolite:
  stage: deploy
  extends:
    - .theodolite
    - .kaniko-push
  needs:
    #- build-theodolite-native
    - build-theodolite-jvm
    - test-theodolite
  variables:
    IMAGE_NAME: theodolite
    DOCKERFILE: src/main/docker/Dockerfile.jvm
    #DOCKERFILE: src/main/docker/Dockerfile.native
  rules:
    - changes:
      - theodolite/**/*
      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
      when: manual
      allow_failure: true


# Theodolite SLO Checker

test-slo-checker-lag-trend:
  stage: test
  needs: []
  image: python:3.7-slim
  before_script:
    - cd slo-checker/record-lag
  script:
    - pip install -r requirements.txt
    - cd app
    - python -m unittest
  rules:
    - changes:
      - slo-checker/record-lag/**/*
    - when: manual
      allow_failure: true

test-slo-checker-dropped-records-kstreams:
  stage: test
  needs: []
  image: python:3.7-slim
  before_script:
    - cd slo-checker/dropped-records
  script:
    - pip install -r requirements.txt
    - cd app
    - python -m unittest
  rules:
    - changes:
      - slo-checker/dropped-records/**/*
    - when: manual
      allow_failure: true

deploy-slo-checker-lag-trend:
  stage: deploy
  extends:
    - .kaniko-push
  needs:
    - test-slo-checker-lag-trend
  before_script:
    - cd slo-checker/record-lag
  variables:
    IMAGE_NAME: theodolite-slo-checker-lag-trend
  rules:
    - changes:
      - slo-checker/record-lag/**/*
      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
      when: manual
      allow_failure: true

deploy-slo-checker-dropped-records-kstreams:
  stage: deploy
  extends:
    - .kaniko-push
  needs:
    - test-slo-checker-dropped-records-kstreams
  before_script:
    - cd slo-checker/dropped-records
  variables:
    IMAGE_NAME: theodolite-slo-checker-dropped-records-kstreams
  rules:
    - changes:
      - slo-checker/dropped-records/**/*
      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
      when: manual
      allow_failure: true


# Theodolite Random Scheduler

deploy-random-scheduler:
  stage: deploy
  extends:
    - .kaniko-push
  needs: []
  before_script:
    - cd execution/infrastructure/random-scheduler
  variables:
    IMAGE_NAME: theodolite-random-scheduler
  rules:
    - changes:
      - execution/infrastructure/random-scheduler/**/*
      if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
    - if: "$CR_HOST && $CR_ORG && $CR_USER && $CR_PW"
      when: manual
      allow_failure: true