Skip to content
Snippets Groups Projects
.gitlab-ci.yml 21.2 KiB
Newer Older
Varac's avatar
Varac committed
---
include:
  - /.gitlab/ci_templates/kaniko.yml
  - /.gitlab/ci_templates/ssh_setup.yml
  - template: 'Workflows/MergeRequest-Pipelines.gitlab-ci.yml'
# Global templates and YAML anchors
# =================================
# Used in various stages/job definitions

# We don't use a `before_script` definition here because `extend` doesn't merge
# `before_script` but rather overwrites it.
# So we rather use [yaml anchors](https://docs.gitlab.com/ce/ci/yaml/README.html#anchors)
# here. Unfortunatly, anchors can't get included from files so we need to
# define them here.
.debug_information: &debug_information
  - |
    echo "Env vars:"
    echo
Varac's avatar
Varac committed
    env | grep -E '^(HOSTNAME|CLUSTER_NAME|FQDN|IP_ADDRESS|CLUSTER_DIR|ANSIBLE_HOST_KEY_CHECKING|KANIKO_BUILD_IMAGENAME|SSH_KEY_ID|SHELL|CI_PROJECT_DIR)='
Varac's avatar
Varac committed
    echo
    echo "Uptime:                    $(uptime)"
    echo "KANIKO build image ref:    ${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_CONTAINER_TAG}"
Varac's avatar
Varac committed
    echo
  - if [ -f .ci.env ]; then echo "Content of .ci.env:"; cat .ci.env; fi
  - if [ -f .cluster.env ]; then echo "Content of .ci.env:"; cat .cluster.env; fi
# The dotenv report requires us to report the artifacts in every job that is
# required with a `needs:` from another job.
.report_artifacts:
  artifacts:
    paths:
      - clusters
    expire_in: 1 month
    when: always
    reports:
      dotenv:
        $CLUSTER_DIR/.cluster.env

# Rules that enable the cluster to be built and are applied to most steps
# (except for application-specific steps)
.general_rules:
  rules:
    - changes:
      - .gitlab-ci.yml
      - .gitlab/ci_scripts/*
      - Dockerfile
      - ansible/**/*
      - flux/**/*
      - flux2/**/*
      - install/**/*
      - test/**/*
      - requirements.txt
    - if: '$TRIGGER_JOBS =~ /enable-.*/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-/'
    - if: '$CI_COMMIT_BRANCH == "main"'
Varac's avatar
Varac committed
#
# Define the rules when/if app specific jobs are run.
# Just add the variable RESOURCE to the job like this:
Varac's avatar
Varac committed
#   variables:
#     RESOURCE: "eventrouter"
# and import the templates with i.e.
#   extends: .eventrouter_rules
# .eventrouter_rules will ensure that the job is only executed:
# - when files related to the app changed in the repo
# - A pipeline gets started from the UI and the job name is included in the
#   CI variable `TRIGGER_JOBS`
# - A commit is pushed containing the pattern TRIGGER_JOBS=.*<job name>
#   (i.e. TRIGGER_JOBS=ci-test-image-build,enable-nextcloud)
#
# Gitlab CI allows pushing CI vars via `git push` but a bug prevents this when
# using merge request pipelines (see https://gitlab.com/gitlab-org/gitlab/-/issues/326098)
        - flux2/apps/monitoring/*.yaml
        - flux2/cluster/optional/monitoring/*.yaml
        - flux2/core/base/sources/grafana.yaml
        - flux2/core/base/sources/wikimedia.yaml
        - flux2/core/base/sources/prometheus-community.yaml
Maarten de Waard's avatar
Maarten de Waard committed
        - flux2/config/monitoring/*.yaml
        - install/flux-version-check.sh
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-monitoring/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-monitoring/'
    - if: '$CI_COMMIT_BRANCH == "main"'
.nextcloud_rules:
  rules:
    - changes:
        - flux2/apps/$RESOURCE/*.yaml
        - flux2/cluster/optional/$RESOURCE/*.yaml
        - flux2/core/base/sources/nextcloud.yaml
        - install/install-app.sh
        - install/flux-version-check.sh
Varac's avatar
Varac committed
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-nextcloud/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-nextcloud/'
    - if: '$CI_COMMIT_BRANCH == "main"'
.single_sign_on_rules:
  rules:
    - changes:
        - flux2/core/base/$RESOURCE/*.yaml
        - flux2/infrastructure/sources/single-sign-on.yaml
        - install/install-stackspin.sh
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-single-sign-on/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-single-sign-on/'
    - if: '$CI_COMMIT_BRANCH == "main"'

Arie Peterson's avatar
Arie Peterson committed
.velero_rules:
  rules:
    - changes:
        - flux2/apps/$RESOURCE/*.yaml
        - flux2/cluster/optional/$RESOURCE/*.yaml
        - flux2/core/base/sources/vmware-tanzu.yaml
        - install/install-app.sh
        - install/flux-version-check.sh
    - if: '$TRIGGER_JOBS =~ /enable-velero/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-velero/'
    - if: '$CI_COMMIT_BRANCH == "main"'

Varac's avatar
Varac committed
.wekan_rules:
  rules:
    - changes:
        - flux2/apps/$RESOURCE/*.yaml
        - flux2/cluster/optional/$RESOURCE/*.yaml
Varac's avatar
Varac committed
        - install/install-app.sh
        - install/flux-version-check.sh
Varac's avatar
Varac committed
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-wekan/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-wekan/'
    - if: '$CI_COMMIT_BRANCH == "main"'
Varac's avatar
Varac committed

.wordpress_rules:
  rules:
    - changes:
        - flux2/apps/$RESOURCE/*.yaml
        - flux2/cluster/optional/$RESOURCE/*.yaml
        - flux2/core/base/sources/wordpress.yaml
        - install/install-app.sh
        - install/flux-version-check.sh
Varac's avatar
Varac committed
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-wordpress/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-wordpress/'
    - if: '$CI_COMMIT_BRANCH == "main"'
Maarten de Waard's avatar
Maarten de Waard committed
.zulip_rules:
  rules:
    - changes:
        - flux2/apps/$RESOURCE/*.yaml
        - flux2/cluster/optional/$RESOURCE/*.yaml
Maarten de Waard's avatar
Maarten de Waard committed
        - install/install-app.sh
        - install/flux-version-check.sh
Maarten de Waard's avatar
Maarten de Waard committed
        - test/taiko/*
    - if: '$TRIGGER_JOBS =~ /enable-zulip/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*enable-zulip/'
Varac's avatar
Varac committed
    - if: '$CI_COMMIT_BRANCH == "main"'
Varac's avatar
Varac committed

# Global declarations
# ===================

Varac's avatar
Varac committed
# https://docs.gitlab.com/ee/ci/yaml/README.html#workflowrules-templates
stages:
  - build
  - install-cluster
  - install-stackspin
  - base-ready
  - configure-stackspin
Varac's avatar
Varac committed
  - optional-apps-ready
Varac's avatar
Varac committed
  - certs
  - cluster-health
  - integration-test
variables:
  SSH_KEY_ID: "411"
  HOSTNAME: "${CI_COMMIT_REF_SLUG}"
  ANSIBLE_HOST_KEY_CHECKING: "False"
  KANIKO_BUILD_IMAGENAME: "stackspin-ci"
Varac's avatar
Varac committed
  CLUSTER_DIR: "clusters/${CI_COMMIT_REF_SLUG}"
  image: "${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_CONTAINER_TAG}"
Varac's avatar
Varac committed
# Stage: build
# ============
#
Varac's avatar
Varac committed
# Builds CI test container image
Varac's avatar
Varac committed
# There are 2 moments in which we (re)build the container image. If some files are
# changed, or when the job is triggered with TRIGGER_JOBS.
Varac's avatar
Varac committed
ci-test-image-build:
  stage: build
  before_script:
    - *debug_information
      echo "CI_CONTAINER_TAG=${CI_COMMIT_REF_SLUG}" | tee .ci.env
  artifacts:
    paths:
      - .ci.env
    expire_in: 1 month
    when: always
    reports:
      dotenv:
        .ci.env
  environment:
    name: image/$CI_COMMIT_REF_SLUG
    url: https://open.greenhost.net:4567/stackspin/stackspin/stackspin-ci:${CI_COMMIT_REF_SLUG}
    auto_stop_in: 3 weeks
Maarten de Waard's avatar
Maarten de Waard committed
  rules:
    # Automatically rebuild the container image if this file, the Dockerfile,
    # the installed requirements or the kaniko template change
    - changes:
        - Dockerfile
        - requirements.txt
        - .gitlab/ci_templates/kaniko.yml
    # Also rebuild when the CI variable contain this jobs name
    # or commit msg contains /TRIGGER_JOBS=.*ci-test-image-build/
    - if: '$TRIGGER_JOBS =~ /ci-test-image-build/'
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*ci-test-image-build/'
  extends:
    - .kaniko_build
report-ci-image-tag:
  stage: build
  image: "curlimages/curl"
  before_script:
    - *debug_information
  script:
    - |
Varac's avatar
Varac committed
      TAG_INFORMATION=$(curl -sS https://open.greenhost.net/api/v4/projects/stackspin%2Fstackspin/registry/repositories/73/tags/${CI_COMMIT_REF_SLUG});
Varac's avatar
Varac committed
      echo "Tag information: ${TAG_INFORMATION}"
      if [ "$TAG_INFORMATION" == '{"message":"404 Tag Not Found"}' ]; then
Varac's avatar
Varac committed
        CI_CONTAINER_TAG="main"
Varac's avatar
Varac committed
        CI_CONTAINER_TAG="${CI_COMMIT_REF_SLUG}"
Varac's avatar
Varac committed
      echo "CI_CONTAINER_TAG=${CI_CONTAINER_TAG}" | tee .ci.env
  artifacts:
    paths:
      - .ci.env
    expire_in: 1 month
    when: always
    reports:
      dotenv:
        .ci.env
  rules:
    # Make sure this job does not run if ci-test-image-build runs
    - changes:
        - Dockerfile
        - requirements.txt
        - .gitlab/ci_templates/kaniko.yml
      when: never  # Never run on file changes that trigger ci-test-image-build
    - if: '$TRIGGER_JOBS =~ /ci-test-image-build/'
      when: never  # Never run when ci-test-image is triggered manually
    - if: '$CI_COMMIT_MESSAGE =~ /TRIGGER_JOBS=.*ci-test-image-build/'
      when: never  # Never run when ci-test-image is triggered manually
    - when: always
  interruptible: true


# Stage: install-cluster
# ======================
# * Creates the vps for the pipeline
# * Installs k8s with ansible
create-vps:
  stage: install-cluster
  variables:
    SUBDOMAIN: "${CI_COMMIT_REF_SLUG}.ci"
    DOMAIN: "stackspin.net"
Varac's avatar
Varac committed
  script:
    - *debug_information
    # Creates a VPS based on a custom CI image for which the ansible playbook
    # has already run. See CONTRIBUTING.md#ci-pipeline-image for more info
    - bash .gitlab/ci_scripts/create_vps.sh
    # Make sure .ci.env variables are not lost
    - cat .ci.env >> ${CLUSTER_DIR}/.cluster.env
    - .report_artifacts
    - .general_rules
    url: https://$FQDN
    on_stop: terminate-droplet
    auto_stop_in: 1 week
test-dns:
  stage: install-cluster
Varac's avatar
Varac committed
  # Needs a pytest ansible connection to get the configured system resolvers
  script:
    - *debug_information
    - cd ansible/
Varac's avatar
Varac committed
    - pytest -v -s -m 'dns' --connection=ansible --ansible-inventory=../${CLUSTER_DIR}/inventory.yml --hosts='ansible://*'
  extends:
    - .general_rules
  interruptible: true
install-k8s:
  stage: install-cluster
  needs:
Varac's avatar
Varac committed
    - job: create-vps
    - *debug_information
    # Copy inventory files to ansible folder for use in install-apps step
Varac's avatar
Varac committed
    - chmod 700 ansible
    - cp ${CLUSTER_DIR}/inventory.yml ansible/
    # Set up cluster
    - python3 -m stackspin $HOSTNAME install
  extends:
    - .ssh_setup
    - .report_artifacts
    - .general_rules
  interruptible: true

Varac's avatar
Varac committed
# Terminates a droplet and deletes the branch container image once the MR for it is merged
terminate-droplet:
  # Stage has to be the same as the step that created the VPS
  # https://docs.gitlab.com/ee/ci/environments.html#automatically-stopping-an-environment
  stage: install-cluster
  # Gets triggered by on_stop of create-vps job
  when: manual
  variables:
    GIT_STRATEGY: none
  script:
    - *debug_information
    # Delete droplet
    - python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${CI_COMMIT_REF_SLUG}\")"
    # Delete container image if one was created
Varac's avatar
Varac committed
    - >
      "if [ \"$CI_CONTAINER_TAG\" != \"main\" ]; then
         curl --request DELETE --header \"PRIVATE-TOKEN: ${CLEANER_TOKEN}\"
         https://open.greenhost.net/api/v4/projects/stackspin%2Fstackspin/registry/repositories/73/tags/${CI_CONTAINER_TAG};
       fi"
Varac's avatar
Varac committed
  environment:
    name: $CI_COMMIT_REF_SLUG
    action: stop

# Stage: install-stackspin
# ========================
#
# Installs flux and stackspin with it

install-stackspin:
  stage: install-stackspin
  needs:
Varac's avatar
Varac committed
    - job: test-dns
    - job: install-k8s
  script:
    - *debug_information
    # Customize env file, remove all comments and empty lines
Varac's avatar
Varac committed
    - cp install/.flux.env.example ${CLUSTER_DIR}/.flux.env
    - sed -i "s/1.2.3.4/$IP_ADDRESS/" ${CLUSTER_DIR}/.flux.env
    - sed -i "s/example.org/$FQDN/"  ${CLUSTER_DIR}/.flux.env
    - sed -i "/^\s*#.*$/d; /^\s*$/d" ${CLUSTER_DIR}/.flux.env
    # Disable outgoing mail
    - sed -i "s/outgoing_mail_enabled=true/outgoing_mail_enabled=false/" ${CLUSTER_DIR}/.flux.env
    # Deploy secret/stackspin-cluster-variables
    - cp install/kustomization.yaml ${CLUSTER_DIR}
Varac's avatar
Varac committed
    - kubectl create namespace flux-system
    - kubectl apply -k ${CLUSTER_DIR}
    # Add an override so cert-manager uses the SSL.com ClusterIssuer
    - kubectl create namespace cert-manager
    - kubectl apply -f ./install/overrides/stackspin-cert-manager-override.yaml
    # Install flux and general, non-app specific secrets
    - bash ./install/install-stackspin.sh
Varac's avatar
Varac committed
  extends:
    - .report_artifacts
    - .general_rules
  interruptible: true

.enable_app_template:
Varac's avatar
Varac committed
  stage: install-stackspin
  needs:
    - job: install-stackspin
  script:
    - *debug_information
    # Add optional override values we need for the CI pipeline only
    - >
Varac's avatar
Varac committed
      [ -f ./install/overrides/stackspin-${RESOURCE}-override.yaml ] &&
Arie Peterson's avatar
Arie Peterson committed
        kubectl apply -f ./install/overrides/stackspin-${RESOURCE}-override.yaml
    - bash ./install/install-app.sh ${RESOURCE}
  interruptible: true

enable-monitoring:
  variables:
    RESOURCE: "monitoring"
  extends:
    - .enable_app_template
    - .monitoring_rules

enable-nextcloud:
  variables:
    RESOURCE: "nextcloud"
  extends:
    - .enable_app_template
    - .nextcloud_rules

Arie Peterson's avatar
Arie Peterson committed
enable-velero:
  variables:
    RESOURCE: "velero"
  extends:
    - .enable_app_template
    - .velero_rules

enable-wekan:
  variables:
    RESOURCE: "wekan"
  extends:
    - .enable_app_template
    - .wekan_rules

enable-wordpress:
  variables:
    RESOURCE: "wordpress"
  extends:
    - .enable_app_template
    - .wordpress_rules

enable-zulip:
  variables:
    RESOURCE: "zulip"
  extends:
    - .enable_app_template
    - .zulip_rules

# Stage: base-ready
Varac's avatar
Varac committed
# ====================
#
# Test if base kustomizations are ready, before configuration can get applied
# that makes use of CRDs, i.e. clusterIssuer
Maarten de Waard's avatar
Maarten de Waard committed
.kustomization-ready:
Varac's avatar
Varac committed
  stage: base-ready
Varac's avatar
Varac committed
    - job: install-stackspin
Maarten de Waard's avatar
Maarten de Waard committed
  script:
    - *debug_information
Varac's avatar
Varac committed
    - cd test/
Maarten de Waard's avatar
Maarten de Waard committed
    - export KUBECONFIG="${PWD}/../clusters/${HOSTNAME}/kube_config_cluster.yml"
Varac's avatar
Varac committed
    - pytest -v -s -m 'kustomizations' --resource="$RESOURCE" --reruns 120 --reruns-delay 20
Maarten de Waard's avatar
Maarten de Waard committed
  extends:
Maarten de Waard's avatar
Maarten de Waard committed
  interruptible: true

Maarten de Waard's avatar
Maarten de Waard committed
cert-manager-kustomization-ready:
Maarten de Waard's avatar
Maarten de Waard committed
  variables:
Maarten de Waard's avatar
Maarten de Waard committed
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
dashboard-kustomization-ready:
Varac's avatar
Varac committed
  variables:
    RESOURCE: "dashboard"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
letsencrypt-issuer-kustomization-ready:
  variables:
    RESOURCE: "letsencrypt-issuer"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
local-path-provisioner-kustomization-ready:
  variables:
    RESOURCE: "local-path-provisioner"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
metallb-kustomization-ready:
  variables:
    RESOURCE: "metallb"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
namespaces-kustomization-ready:
  variables:
    RESOURCE: "namespaces"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
nginx-kustomization-ready:
  variables:
    RESOURCE: "nginx"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
single-sign-on-kustomization-ready:
  variables:
    RESOURCE: "single-sign-on"
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
sources-kustomization-ready:
Varac's avatar
Varac committed
  extends:
    - .kustomization-ready

Maarten de Waard's avatar
Maarten de Waard committed
stackspin-kustomization-ready:
    RESOURCE: "stackspin"
  extends:
    - .kustomization-ready

# Stage: configure-stackspin
#
# Configure cluster after basic installation
# i.e. CI-related config like sslcom clusterIssuer
configure-sslcom-issuer:
  stage: configure-stackspin
  needs:
    - job: install-stackspin
Varac's avatar
Varac committed
    - job: cert-manager-kustomization-ready
  script:
    - *debug_information
    # Install custom ClusterIssuer for SSL.com production certificates
    - bash ./.gitlab/ci_scripts/install_sslcom_issuer.sh
  extends:
    - .report_artifacts
    - .general_rules
  interruptible: true


Maarten de Waard's avatar
Maarten de Waard committed

Varac's avatar
Varac committed
# Stage: optional-apps-ready
# ================
#
# Check that the kustomizations of all installed apps are ready.

.app-kustomization-ready:
Varac's avatar
Varac committed
  stage: optional-apps-ready
  extends:
    - .kustomization-ready

monitoring-kustomization-ready:
  needs:
    - job: install-stackspin
    - job: enable-monitoring
  variables:
    RESOURCE: "monitoring"
  extends:
    - .app-kustomization-ready
    - .monitoring_rules

nextcloud-kustomization-ready:
  needs:
    - job: install-stackspin
    - job: enable-nextcloud
  variables:
    RESOURCE: "nextcloud"
  extends:
    - .app-kustomization-ready
    - .nextcloud_rules

Arie Peterson's avatar
Arie Peterson committed
velero-kustomization-ready:
  needs:
    - job: install-stackspin
    - job: enable-velero
  variables:
    RESOURCE: "velero"
  extends:
    - .app-kustomization-ready
    - .velero_rules

wekan-kustomization-ready:
  needs:
    - job: install-stackspin
    - job: enable-wekan
  variables:
    RESOURCE: "wekan"
  extends:
    - .app-kustomization-ready
    - .wekan_rules

wordpress-kustomization-ready:
  needs:
    - job: install-stackspin
    - job: enable-wordpress
  variables:
    RESOURCE: "wordpress"
  extends:
    - .app-kustomization-ready
    - .wordpress_rules

Maarten de Waard's avatar
Maarten de Waard committed
zulip-kustomization-ready:
  needs:
    - job: install-stackspin
Maarten de Waard's avatar
Maarten de Waard committed
    - job: enable-zulip
  variables:
    RESOURCE: "zulip"
  extends:
    - .app-kustomization-ready
    - .zulip_rules

Varac's avatar
Varac committed
# Stage: certs
# ================
Varac's avatar
Varac committed
# Test each app for proper certs
Varac's avatar
Varac committed
.apps-cert:
  stage: certs
  script:
    - *debug_information
Varac's avatar
Varac committed
    - cd test/
    - pytest -v -s -m 'certs' --resource="$RESOURCE" --reruns 120 --reruns-delay 10
  interruptible: true
Varac's avatar
Varac committed

nextcloud-cert:
  variables:
    RESOURCE: "nextcloud"
Varac's avatar
Varac committed
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
  extends:
    - .apps-cert
    - .nextcloud_rules
Maarten de Waard's avatar
Maarten de Waard committed
kube-prometheus-stack-cert:
Varac's avatar
Varac committed
  variables:
    RESOURCE: "kube-prometheus-stack"
Varac's avatar
Varac committed
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
  extends:
    - .apps-cert
Varac's avatar
Varac committed
    - .monitoring_rules
Varac's avatar
Varac committed

single-sign-on-cert:
  variables:
    RESOURCE: "single-sign-on"
Varac's avatar
Varac committed
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
  extends:
    - .apps-cert
    - .general_rules
Varac's avatar
Varac committed
dashboard-cert:
  variables:
    RESOURCE: "dashboard"
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
Varac's avatar
Varac committed
  extends:
    - .apps-cert
    - .general_rules
Varac's avatar
Varac committed

Varac's avatar
Varac committed
wekan-cert:
  variables:
    RESOURCE: "wekan"
Varac's avatar
Varac committed
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
Varac's avatar
Varac committed
  extends:
    - .apps-cert
    - .wekan_rules

Varac's avatar
Varac committed
wordpress-cert:
  variables:
    RESOURCE: "wordpress"
Varac's avatar
Varac committed
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
  extends:
    - .apps-cert
    - .wordpress_rules
Maarten de Waard's avatar
Maarten de Waard committed
zulip-cert:
  variables:
    RESOURCE: "zulip"
  needs:
    - job: configure-sslcom-issuer
    - job: install-stackspin
Maarten de Waard's avatar
Maarten de Waard committed
  extends:
    - .apps-cert
    - .zulip_rules

# Stage: cluster-health
# =====================
Varac's avatar
Varac committed
#
# General cluster health checks

testinfra:
  stage: cluster-health
  needs:
    - job: install-stackspin
    - *debug_information
Varac's avatar
Varac committed
    - pytest -v -s -m 'testinfra' --connection=ansible --ansible-inventory=../${CLUSTER_DIR}/inventory.yml --hosts='ansible://*'
  extends:
    - .ssh_setup
    - .general_rules
  interruptible: true
prometheus-alerts:
  stage: cluster-health
  needs:
    - job: install-stackspin
    - job: kube-prometheus-stack-cert
Varac's avatar
Varac committed
  variables:
Varac's avatar
Varac committed
    # RESOURCE var is used in job specific rules (i.e. ..monitoring_rules)
    RESOURCE: "kube-prometheus-stack"
Varac's avatar
Varac committed
  script:
    - *debug_information
    - export BASIC_AUTH_PW=$(python3 -m stackspin $HOSTNAME secrets | grep stackspin-prometheus-basic-auth | awk '{ print $4 }')
Varac's avatar
Varac committed
    - cd test/
    - bash ../.gitlab/ci_scripts/retry_cmd_until_success.sh 30 10 pytest -s -m prometheus
Varac's avatar
Varac committed
    - .monitoring_rules
  interruptible: true
Varac's avatar
Varac committed

# Stage: integration-test
# =======================
#
Varac's avatar
Varac committed
# Runs integration tests for most apps using taiko
Varac's avatar
Varac committed
.taiko:
  stage: integration-test
    - *debug_information
    # Retry taiko tests 20 times until they succeed,
    # with a sleep interval of 10s in between tests
    - bash ./.gitlab/ci_scripts/retry_cmd_until_success.sh 20 10 unbuffer python3 -m stackspin $HOSTNAME test --apps $RESOURCE | ts -i | ts
Varac's avatar
Varac committed
  artifacts:
    paths:
Varac's avatar
Varac committed
      - test/taiko/Screenshot*
Varac's avatar
Varac committed
    expire_in: 1 month
    when: on_failure
  interruptible: true
Varac's avatar
Varac committed
dashboard-taiko:
  variables:
    RESOURCE: "dashboard"
  needs:
    - job: install-stackspin
Varac's avatar
Varac committed
    - job: dashboard-cert
Maarten de Waard's avatar
Maarten de Waard committed
    - job: dashboard-kustomization-ready
Varac's avatar
Varac committed
  extends:
    - .taiko
    - .general_rules

Varac's avatar
Varac committed
  variables:
    RESOURCE: "grafana"
Varac's avatar
Varac committed
  needs:
    - job: install-stackspin
Maarten de Waard's avatar
Maarten de Waard committed
    - job: kube-prometheus-stack-cert
    - job: monitoring-kustomization-ready
Varac's avatar
Varac committed
    - .taiko
Varac's avatar
Varac committed
    - .monitoring_rules
Varac's avatar
Varac committed
nextcloud-taiko:
Varac's avatar
Varac committed
  variables:
    RESOURCE: "nextcloud"
Varac's avatar
Varac committed
  needs:
    - job: install-stackspin
Varac's avatar
Varac committed
    - job: nextcloud-cert
    - job: nextcloud-kustomization-ready
Varac's avatar
Varac committed
    - .taiko
    - .nextcloud_rules
Varac's avatar
Varac committed
wekan-taiko:
  variables:
    RESOURCE: "wekan"
Varac's avatar
Varac committed
  needs:
    - job: install-stackspin
Varac's avatar
Varac committed
    - job: wekan-cert
    - job: wekan-kustomization-ready
Varac's avatar
Varac committed
  extends:
    - .taiko
    - .wekan_rules

Varac's avatar
Varac committed
wordpress-taiko:
Varac's avatar
Varac committed
  variables:
    RESOURCE: "wordpress"
Varac's avatar
Varac committed
  needs:
    - job: install-stackspin
Varac's avatar
Varac committed
    - job: wordpress-cert
    - job: wordpress-kustomization-ready
Varac's avatar
Varac committed
    - .taiko
    - .wordpress_rules
Maarten de Waard's avatar
Maarten de Waard committed
zulip-taiko:
  variables:
    RESOURCE: "zulip"
  needs:
    - job: install-stackspin
Maarten de Waard's avatar
Maarten de Waard committed
    - job: zulip-cert
Maarten de Waard's avatar
Maarten de Waard committed
    - job: zulip-kustomization-ready
  extends:
    - .taiko
    - .zulip_rules