include: ci-templates/core.yml

workflow:
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /^kinetic-.*/
      variables:
        DEFAULT_DISTRO: "kinetic"
    - if: $CI_COMMIT_REF_NAME =~ /^melodic-.*/
      variables:
        DEFAULT_DISTRO: "melodic"
    - if: $CI_COMMIT_REF_NAME =~ /^noetic-.*/
      variables:
        DEFAULT_DISTRO: "noetic"
    - if: $CI_COMMIT_REF_NAME =~ /^humble-.*/
      variables:
        DEFAULT_DISTRO: "humble"
    - if: $CI_COMMIT_REF_NAME =~ /^jazzy-.*/
      variables:
        DEFAULT_DISTRO: "jazzy"
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH

industrial_ci_kinetic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: kinetic
  rules:
    - if: $DEFAULT_DISTRO == "kinetic"
    - if: $BUILD_KINETIC

industrial_ci_melodic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: melodic
  rules:
    - if: $DEFAULT_DISTRO == "melodic"
    - if: $BUILD_MELODIC

industrial_ci_noetic:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: noetic
  rules:
    - if: $DEFAULT_DISTRO == "noetic"
    - if: $BUILD_NOETIC

industrial_ci_humble:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: humble
  rules:
    - if: $DEFAULT_DISTRO == "humble"
    - if: $BUILD_HUMBLE

industrial_ci_jazzy:
  extends: .industrial_ci
  variables:
    ROS_DISTRO: jazzy
  rules:
    - if: $DEFAULT_DISTRO == "jazzy"
    - if: $BUILD_JAZZY

.py3_rules:
  rules:
    - if: $DEFAULT_DISTRO == "noetic"
      when: always
    - if: $BUILD_NOETIC
      when: always
    - if: $DEFAULT_DISTRO == "humble"
      when: always
    - if: $BUILD_HUMBLE
      when: always
    - if: $DEFAULT_DISTRO == "jazzy"
      when: always
    - if: $BUILD_JAZZY
      when: always

py3-flake8:
  extends:
    - .py3_rules
    - .py3-flake8

py3-flake8_extended:
  extends:
    - .py3_rules
    - .py3-flake8_extended

py3-security:
  extends:
    - .py3_rules
    - .py3-security

.py2_rules:
  rules:
    - if: $DEFAULT_DISTRO == "kinetic"
      when: always
    - if: $BUILD_KINETIC
      when: always
    - if: $DEFAULT_DISTRO == "melodic"
      when: always
    - if: $BUILD_MELODIC
      when: always

py2-flake8:
  extends:
    - .py2_rules
    - .py2-flake8

ddeploy:
  extends: .ddeploy
  rules:
    - if: $CI_COMMIT_TAG
      exists:
        - ddeploy.yaml
      when: always
    - exists:
        - ddeploy.yaml
      when: manual
      allow_failure: true
