---
# xos tosca unit test

- job-template:
    id: 'xos-tosca-unit-test'
    name: 'verify_{project}_unit-test'

    description: |
      Created by {id} job-template from ci-management/jjb/xos-tosca-unit.yaml

    triggers:
      - cord-infra-gerrit-trigger-patchset:
          gerrit-server-name: '{gerrit-server-name}'
          project-regexp: '^{project}$'
          branch-regexp: '{branch-regexp}'
          dependency-jobs: '{dependency-jobs}'
          file-include-regexp: '{all-files-regexp}'

    properties:
      - cord-infra-properties:
          build-days-to-keep: '{build-days-to-keep}'
          artifact-num-to-keep: '{artifact-num-to-keep}'

    wrappers:
      - lf-infra-wrappers:
          build-timeout: '{build-timeout}'
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

    scm:
      - cord-infra-gerrit-repo-scm:
          manifest-url: '{gerrit-server-url}/{cord-repo-manifest}'
          branch: '$GERRIT_BRANCH'
          destination-dir: 'cord'

    node: '{build-node}'
    project-type: freestyle
    concurrent: true

    builders:
      - cord-infra-gerrit-repo-patch:
          destination-dir: 'cord'
          project: '$GERRIT_PROJECT'
          change-number: '$GERRIT_CHANGE_NUMBER'
          patchset-number: '$GERRIT_PATCHSET_NUMBER'
      - shell: |
          #!/usr/bin/env bash
          set -ex -o pipefail

          export XOS_DIR=$WORKSPACE/cord/orchestration/xos
          export TOSCA_DIR=$WORKSPACE/cord/orchestration/xos-tosca

          # setup virtual env
          $XOS_DIR/scripts/setup_venv.sh
          source "$WORKSPACE/venv-xos/bin/activate"
          set -u

          # Run the tests
          pushd "$WORKSPACE/cord/orchestration/xos-tosca"
          make tests
          popd

    publishers:
      - junit:
          results: "**/nose2-junit.xml"
      - cobertura:
          report-file: "**/coverage.xml"
          targets:
            - files:
                healthy: 80
                unhealthy: 0
                failing: 0
            - method:
                healthy: 50
                unhealthy: 0
                failing: 0

