Blob Blame History Raw
image: registry.opensuse.org/opensuse/infrastructure/containers/heroes-salt-testing:latest

stages:
  - test
  - deploy

.test_mr:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' || $CI_COMMIT_BRANCH == 'production'

.test_common:
  extends:
    - .test_mr
  stage: test
  tags:
    - docker

.test_artifacts:
  artifacts:
    when: always
    paths:
      - '*.txt'

lint:
  extends:
    - .test_common
  image: registry.opensuse.org/opensuse/infrastructure/containers_tumbleweed/heroes-salt-validation:latest
  script:
    - bin/set_gitlab_ci_safe_directory.sh
    - bin/lint.sh

validate:
  extends:
    - .test_common
  image: registry.opensuse.org/opensuse/infrastructure/containers_tumbleweed/heroes-salt-validation:latest
  script:
    - bin/set_gitlab_ci_safe_directory.sh
    - bin/test_validate.sh

show_highstate:
  extends:
    - .test_common
    - .test_artifacts
  before_script:
    - bin/prepare_test_env.sh -g -o Leap,15,5 -s
  script: bin/test_show_highstate.sh

test_haproxy:
  extends:
    - .test_common
    - .test_artifacts
  image: registry.opensuse.org/opensuse/infrastructure/containers/heroes-salt-testing-haproxy:latest
  before_script:
    - bin/prepare_test_env.sh -g -s -n
    - bin/replace_secrets.sh
  script: bin/test_haproxy.sh
#     changes:
#       - bin/test_haproxy.sh
#       - pillar/cluster/*/*
#       - pillar/common/haproxy/*
#       - salt/profile/proxy/*
#       - salt/role/proxy*

test_nftables:
  extends:
    - .test_common
  image: registry.opensuse.org/opensuse/infrastructure/containers/heroes-salt-testing-nftables:latest
  script: bin/test_nftables.pl

test_prometheus:
  extends:
    - .test_common
  image: registry.opensuse.org/opensuse/infrastructure/containers/heroes-salt-testing-prometheus:latest
  before_script: bin/prepare_test_env.sh -g -s -n
  script: bin/test_prometheus.sh
  artifacts:
    when: always
    paths:
      - '*.txt'
      - rules/*.txt

# Dynamically generated jobs
prepare_includes:
  extends:
    - .test_mr
  script: bin/render_gitlab_ci_includes.py -w
  artifacts:
    paths:
      - .gitlab-ci.includes/*.yml

test_highstate:
  extends:
    - .test_mr
  needs:
    - prepare_includes
  trigger:
    include:
      - artifact: .gitlab-ci.includes/test_highstate.yml
        job: prepare_includes
    strategy: depend

test_nginx:
  extends:
    - .test_mr
  needs:
    - prepare_includes
  trigger:
    include:
      - artifact: .gitlab-ci.includes/test_nginx.yml
        job: prepare_includes
    strategy: depend

.deploy:
  rules:
    - if: $CI_COMMIT_BRANCH == 'production'
  stage: deploy
  tags:
    - docker

sync:
  extends: .deploy
  script:
    - "rsync -a --delete --super --owner --group --chown=477:479 --chmod='u=rwX,g=rX,o=' $PWD/ rsync://saltpush@witch1.infra.opensuse.org:873/salt-push/"

deploy:
  extends: .deploy
  image: registry.opensuse.org/opensuse/infrastructure/containers_tumbleweed/heroes-salt-deployment:latest
  needs:
    - sync
  script:
    - bin/set_gitlab_ci_safe_directory.sh
    - bin/deploy.py --mode test --no-mine-update --state-verbose=False