# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- project:
    templates:
      - openstack-cover-jobs
      - openstack-python-jobs
      - openstack-python35-jobs
      - docs-on-readthedocs
      - openstack-python36-jobs
    vars:
      rtd_webhook_id: '38572'
    check:
      jobs:
        - airship-deckhand-tox-py27-postgresql
        - airship-deckhand-tox-py35-postgresql
        - airship-deckhand-functional-uwsgi-py35:
            voting: false
        - airship-deckhand-functional-docker-py35
        - airship-deckhand-integration-uwsgi-py35:
            voting: false
        - airship-deckhand-integration-docker-py35
        - airship-deckhand-docker-build-gate
    gate:
      jobs:
        - airship-deckhand-tox-py27-postgresql
        - airship-deckhand-tox-py35-postgresql
        - airship-deckhand-functional-docker-py35
        - airship-deckhand-integration-docker-py35
        - airship-deckhand-docker-build-gate
    post:
      jobs:
        - airship-deckhand-docker-tag
        - airship-deckhand-docker-publish

- nodeset:
    name: airship-deckhand-single-node
    nodes:
      - name: primary
        label: ubuntu-xenial

- job:
    name: airship-deckhand-tox-py27-postgresql
    parent: openstack-tox-py27
    pre-run:
      - tools/gate/playbooks/install-postgresql.yaml
    vars:
      tox_envlist: py27-postgresql

- job:
    name: airship-deckhand-tox-py35-postgresql
    parent: openstack-tox-py35
    pre-run:
      - tools/gate/playbooks/install-postgresql.yaml
    vars:
      tox_envlist: py35-postgresql

- job:
    name: airship-deckhand-functional-uwsgi-py35
    description: |
      Run tox-based functional tests for the Airship Deckhand project using a
      minimalistic deployment consisting of uwsgi for Deckhand API and pifpaf
      for ephemeral PostgreSQL DB, under cPython version 3.5.
    run: tools/gate/playbooks/run-functional-tests-uwsgi.yaml
    nodeset: airship-deckhand-single-node
    vars:
      tox_envlist: functional-dev
    irrelevant-files:
      - ^.*\.rst$
      - ^doc/.*$
      - ^etc/.*$
      - ^releasenotes/.*$
      - ^setup.cfg$
      - ^deckhand/tests/unit/.*$

- job:
    name: airship-deckhand-functional-docker-base
    description: |
      Base job for running airship-deckhand functional tests. Runs tests
      against Docker image generated from source code.
    roles:
      - zuul: openstack/openstack-helm-infra
    timeout: 3600
    pre-run:
      - tools/gate/playbooks/osh-infra-upgrade-host.yaml
      - tools/gate/playbooks/osh-infra-deploy-docker.yaml
    run: tools/gate/playbooks/run-functional-tests-docker.yaml
    required-projects:
      - openstack/openstack-helm-infra

- job:
    name: airship-deckhand-functional-docker-py35
    description: |
      Run tox-based functional tests for the Airship Deckhand project under
      cPython version 3.5. Uses tox with the ``functional-py35`` environment.
    parent: airship-deckhand-functional-docker-base
    nodeset: airship-deckhand-single-node
    vars:
      tox_envlist: functional
      disable_keystone: true
    irrelevant-files:
      - ^.*\.rst$
      - ^doc/.*$
      - ^etc/.*$
      - ^releasenotes/.*$
      - ^setup.cfg$
      - ^deckhand/tests/unit/.*$

- job:
    name: airship-deckhand-integration-uwsgi-py35
    description: |
      Run tox-based integration tests for the Airship Deckhand project using a
      minimalistic deployment consisting of uwsgi for Deckhand API and pifpaf
      for ephemeral PostgreSQL DB, under cPython version 3.5.
    timeout: 3600
    run: tools/gate/playbooks/run-integration-tests-uwsgi.yaml
    nodeset: airship-deckhand-single-node
    irrelevant-files:
      - ^.*\.rst$
      - ^doc/.*$
      - ^etc/.*$
      - ^releasenotes/.*$
      - ^setup.cfg$
      - ^deckhand/tests/unit/.*$
    vars:
      disable_keystone: true

- job:
    name: airship-deckhand-integration-docker-base
    description: |
      Base job for running airship-deckhand integration tests. Runs tests
      against Docker image generated from source code.
    timeout: 3600
    roles:
      - zuul: openstack/openstack-helm-infra
    vars:
      zuul_osh_relative_path: ../openstack-helm/
      zuul_osh_infra_relative_path: ../openstack-helm-infra/
    pre-run:
      - tools/gate/playbooks/osh-infra-upgrade-host.yaml
      - tools/gate/playbooks/osh-infra-deploy-docker.yaml
    run: tools/gate/playbooks/run-integration-tests-docker.yaml
    post-run: tools/gate/playbooks/osh-infra-collect-logs.yaml
    required-projects:
      - openstack/openstack-helm
      - openstack/openstack-helm-infra
    irrelevant-files:
      - ^.*\.rst$
      - ^doc/.*$
      - ^releasenotes/.*$

- job:
    name: airship-deckhand-integration-docker-py35
    description: |
      Run tox-based integration tests for the Airship Deckhand project under
      cPython version 3.5.
    parent: airship-deckhand-integration-docker-base
    nodeset: openstack-helm-single-node
    vars:
      disable_keystone: false

- job:
    name: airship-deckhand-docker-build-gate
    timeout: 1800
    run: tools/gate/playbooks/docker-image-build.yaml
    nodeset: airship-deckhand-single-node
    irrelevant-files: &non-code-files-template
      - ^.*\.rst$
      - ^doc/.*$
      - ^charts/.*$
      - ^etc/.*$
      - ^releasenotes/.*$
      - ^setup.cfg$
    vars:
      publish: false
      tags:
        dynamic:
          patch_set: true

- job:
    name: airship-deckhand-docker-publish
    description: |
      Runs on every merge, unless files in a dictionary below are changed.
      Builds and publishes container images on quay.io with a set of tags
      listed in vars section. Waits in Zuul queue for a node (VM) assignment.
    timeout: 1800
    run: tools/gate/playbooks/docker-image-build.yaml
    nodeset: airship-deckhand-single-node
    secrets:
      - airship_deckhand_quay_creds
    irrelevant-files: *non-code-files-template
    vars:
      publish: true
      tags:
        dynamic:
          branch: true
          commit: true
        static:
          - latest
- job:
    name: airship-deckhand-docker-tag
    description: |
      Runs on every merge when files in a dictionalry below are changed, and
      adds git commit id tag onto the container image published on quay.io,
      which has `latest` tag set. Does not wait in queue for a node (VM)
      assignment, runs almost immediately.
    timeout: 1800
    run: tools/gate/playbooks/docker-image-tag.yaml
    nodeset:
      nodes: []
    secrets:
      - airship_deckhand_quay_creds
# file pattern here must be exactly the same as in
# airship-deckhand-docker-publish job above,
# job will be executed on merge only when any of this files get changed
    files: *non-code-files-template

- secret:
    name: airship_deckhand_quay_creds
    data:
      username: !encrypted/pkcs1-oaep
        - eC+ZaBS1TN37yuvL2WoGkJQ8OFBSLiXxV0wAkH+2l9wLNjmT3QxwnjXTNSw883zEkE9C/
          XPDUxgv7RMLO/Bfs7uXKH1QjCbIJREPJ7Vk6WY9BUvn6olT/JCafpRcsmAkIS4W8p0l7J
          ZxelQnGm/Z2zcq4eWeKzKsFLGiAHyoFASXqlDf93NesR+lZ4xnZkO24+oPMpZq6o2Xr2D
          eWrxEcEsn817o7bA5d9mHb3u2e4tgyxhRevz43VD+0p1bK1thjRnUVpmOvHNjGI+jphAT
          Vf2+Zqys0+xJ4yJ62bhnayvLZeaKD96rLIXCsbm4xYWsyrzCYvJQ4nESY7McYoDEG6PgL
          3Gr/6oyNUzobQNAxuwo0GpecaBVy5Z1/8Ihlb8r1nNM3J0a7oz1PyPS4O7WRlQmXgHJ/x
          jJJmh66ruDxi1bcarmn4AR6lWmfyFqHwIlptsvX9AcJd4FWII9ZYdTUiidJ9ob4KmchIY
          G0wdqGDaekNR01VgB+JD05IM4UMLjwRnFmLUKIvo0H9YU5X253rv/GXNks1Ov2OevIlch
          RnnnpCESNso+xup0IztfWBkcGPGBpgmIh6T5s5bfg0n9CYEzsJMGiJuMKgeZcBvnif6Qb
          y1mzFxQiyEUUPzngF6ger7sBdXSrkCv8cqWsxdeVf2xEXLCDl/x2rhfj7fa5C8=
      password: !encrypted/pkcs1-oaep
        - TL/cjk3UCv2QQTk/QX6ujvLpHQDgijFmBWG3r9Hg/migT1Iry/eQi/HftHhShWjF0lk6Y
          kesdX49H8wXHkRutGxrmcb4HMde4clebtT0dIvVFU7/Ieoq5OnxVLdIPP3YBLZYLy5Ah5
          jLtfV1FJsuRN5gVGJeOXQUhPitrEnNrcj50ke1+llvfRl7PIR1byAM/6gQLbV3oUtOgk6
          jmpieqxq55yO+o76bXOp8YNNVr0eqI1nISfBoku2GL7nipAcfxDIeR3a5J4pdaJEEhJR7
          qqgp1RMt/aADkBUDqw1xbF86V2Mh2l60mWtYUHm4EvOFotrzeOd6Th73K9y57cBuQRJwT
          qP+T+3yuTtuwvzjgTG+h5deppsRb3EFtPYSI6TqWVKtH2zwRbTJCSbgdY03Tjrwn9vZJK
          QA4O1fRLBhchBqaIcpOFj8AFNPYCtz6cvL0uzAHXfQoQ3r9icNlPg0N5W2VINxYvDIiOc
          Lfpty/EyKOJJpOXoBiJlsGHFLi/8gdMAAtMDf72yrQH6KxdNxdRGs5oALkUQ1IcuLbXng
          ySP8WG+DBiwjt4IAtwd/sF+jyVBzDaywxdbS6RJycI+lRThvibQ5UFpr349yOhUdETB6p
          yzFswIVmx1tHM7NhD80zwdSEj4EjG0AL3GXuwfLHGbr5WIeCaVEuCMW+XUwQpw=
      # Token is valid for 10 years, expires on 10/10/2028
      token: !encrypted/pkcs1-oaep
        - Can0JzCSPRnujg8fZBtSXvLuGVRNaaoVkvCm8EKlqohnUmaryU7ColJxWYjPBxEEePxhB
          mzkM5pD9o8PVkkUj5wxxUXlFDO73AMiwStmh2r/p+sd7bkgw5a2jzhYpBmVtn/qmEemsm
          iIxQi0kz81qrU0H6w3r58lgskIIbD4yOYgu4DeoWmBU+yZ1V1E5RoumVQBdxB1fyenaKG
          zR4Y6ebek31+VAlqSN0HUIYMgbc6Mt7ErEn2wjj9MxNvvP52pWDyxr5U2kKpOYdJpZt9h
          EZgM2cF2zfuG+4KnpdONap54uVRnRcJCf6poI/l4UVYO5Z+EvlF3Xawp3jiPCMCGGy3dd
          lEeEkvNzJppwAj5bEWT1NoFi7PigkK91znppVHu17jBEKkcl2S6LK87RTjfqnBsAmE30d
          ibxqS7pCoSCGuUCP4XrW8QfI70Ml4Gb636bZUqZFi1WxzhfNKSO8LBPHekVQnwrmhhv2Z
          CN9JZdtqR49JpHajubfYrtWxPHuiwnTwgsnpkpM0+5Z1nss/nQhW70uCBXvJkYUtenV87
          c4Exr6ncOjgtqtjheW16hAGLtm2o36ZvBoLD7yqwYAjwb0bfuzDrw8oWa2yAgOcWnHPO6
          w0lNv46YTHiJK9hezHqI0hgn5wifVI8avRZmHwaArVvX4LUXD2N/Tk7mxi7r2U=