---
# -----------------------------------------------------------------------
# Copyright 2018-2024 Open Networking Foundation Contributors
#
# 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.
#
# SPDX-FileCopyrightText: 2018-2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
# Entropy: 0fcb5ffa-d1a4-11ee-be5e-9f44b7181764
# -----------------------------------------------------------------------
# Intent:
# CORD lint and static code validation job templates
# These are invoked by the per-git-repo jobs stored in verify/
# -----------------------------------------------------------------------

# Verify that there is valid license/copyright on files
- job-template:
    id: verify-licensed
    name: 'verify_{project}_licensed'
    description: |
      Created by verify-licensed job-template from ci-management/jjb/lint.yaml

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

    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:
      - lf-infra-gerrit-scm:
          git-url: '$GIT_URL/$GERRIT_PROJECT'
          refspec: '$GERRIT_REFSPEC'
          branch: '$GERRIT_BRANCH'
          submodule-disable: '{submodule-disable}'
          submodule-recursive: 'false'
          submodule-timeout: '{submodule-timeout}'
          choosing-strategy: gerrit
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

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

    builders:
      - shell: !include-raw-escape: shell/licensecheck.sh


# run `ansible-lint` to validate ansible playbooks/roles
- job-template:
    id: verify-ansible-lint
    name: 'verify_{project}_ansible-lint'
    description: >+
      Created by verify-ansible-lint job-template
      from ci-management/jjb/lint.yaml

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

    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:
      - lf-infra-gerrit-scm:
          git-url: '$GIT_URL/$GERRIT_PROJECT'
          refspec: '$GERRIT_REFSPEC'
          branch: '$GERRIT_BRANCH'
          submodule-disable: '{submodule-disable}'
          submodule-recursive: 'false'
          submodule-timeout: '{submodule-timeout}'
          choosing-strategy: gerrit
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

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

    builders:
      - inject:
          properties-content: |
            SKIP_DIRS={skip-dirs}
      - shell: !include-raw-escape: shell/ansiblelint.sh


# run `shellcheck` to validate shell scripts charts
- job-template:
    id: verify-shellcheck
    name: 'verify_{project}_shellcheck'
    description: |
      Created by {id} job-template from ci-management/jjb/lint.yaml

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

    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:
      - lf-infra-gerrit-scm:
          git-url: '$GIT_URL/$GERRIT_PROJECT'
          refspec: '$GERRIT_REFSPEC'
          branch: '$GERRIT_BRANCH'
          submodule-disable: '{submodule-disable}'
          submodule-recursive: 'false'
          submodule-timeout: '{submodule-timeout}'
          choosing-strategy: gerrit
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

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

    builders:
      - shell: !include-raw-escape: shell/shcheck.sh

# [EOF]
