Merge "Add license check job using new lhc"
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Sat, 23 Jun 2018 15:02:18 +0000 (15:02 +0000)
committerGerrit Code Review <gerrit@linuxfoundation.org>
Sat, 23 Jun 2018 15:02:18 +0000 (15:02 +0000)
1  2 
docs/jjb/lf-ci-jobs.rst
jjb/lf-ci-jobs.yaml
jjb/lf-macros.yaml

diff --combined docs/jjb/lf-ci-jobs.rst
@@@ -212,7 -212,6 +212,7 @@@ OpenStack Cloud plugin version supporte
  * 2.32
  * 2.33
  * 2.34
 +* 2.35
  
  Cloud configuration are managed via a directory structure in ci-management as
  follows:
@@@ -427,6 -426,34 +427,34 @@@ other file changes. Verifies INFO.yaml 
          (default: true)
      :gerrit_verify_triggers: Override Gerrit Triggers.
  
+ .. _license-checker:
+ License Checker
+ ---------------
+ Job to scan projects for files missing license headers.
+ :Template Names:
+     - {project-name}-license-check
+     - gerrit-license-check
+     - github-license-check
+ :Optional parameters:
+     :file-patterns: Space-separated list of file patterns to scan.
+         (default: \*.go \*.groovy \*.java \*.py \*.sh)
+     :spdx-disable: Disable the SPDX-Identifier checker. (default: false)
+     :lhc-version: Version of LHC to use. (default: 0.2.0)
+     :license-exclude-paths: Comma-separated list of paths to exclude from the
+         license checker. The paths used here will be matched using a contains
+         rule so it is best to be as precise with the path as possible.
+         For example a path of '/src/generated/' will be searched as
+         '**/src/generated/**'.
+         Example: org/opendaylight/yang/gen,protobuff/messages
+         (default: '')
+     :licenses-allowed: Comma-separated list of allowed licenses.
+         (default: Apache-2.0,EPL-1.0,MIT)
  .. _gjjb-packer-merge:
  
  Packer Merge
diff --combined jjb/lf-ci-jobs.yaml
@@@ -36,7 -36,6 +36,6 @@@
        - gerrit-packer-merge
        - gerrit-packer-verify
  
  - job-group:
      name: '{project-name}-github-packer-jobs'
  
          pattern: '.*\.groovy'
        - compare-type: REG_EXP
          pattern: '.*\.sh'
 +      - compare-type: REG_EXP
 +        pattern: '.*\.bat'
 +      - compare-type: REG_EXP
 +        pattern: '.*\.ps1'
        - compare-type: REG_EXP
          pattern: '.*\.(yaml|yml)'
        - compare-type: REG_EXP
      github_included_regions:
        - '.*\.groovy'
        - '.*\.sh'
 +      - '.*\.bat'
 +      - '.*\.ps1'
        - '.*\.(yaml|yml)'
        - '.*\/global-jjb'
  
            github-hooks: true
            included-regions: '{obj:github_included_regions}'
  
+ #################
+ # License Check #
+ #################
+ - lf_license_check: &lf_license_check
+     name: lf-license-check
+     ######################
+     # Default parameters #
+     ######################
+     branch: master
+     build-days-to-keep: 7
+     build-timeout: 15
+     file-patterns: >
+         *.go
+         *.groovy
+         *.java
+         *.py
+         *.sh
+     git-url: '$GIT_URL/$PROJECT'
+     lhc-version: 0.2.0
+     license-exclude-paths: ''
+     licenses-allowed: Apache-2.0,EPL-1.0,MIT
+     spdx-disable: false
+     stream: master
+     #####################
+     # Job Configuration #
+     #####################
+     project-type: freestyle
+     node: '{build-node}'
+     concurrent: true
+     properties:
+       - lf-infra-properties:
+           build-days-to-keep: '{build-days-to-keep}'
+     parameters:
+       - lf-infra-parameters:
+           project: '{project}'
+           branch: '{branch}'
+           stream: '{stream}'
+           lftools-version: '{lftools-version}'
+     wrappers:
+       - lf-infra-wrappers:
+           build-timeout: '{build-timeout}'
+           jenkins-ssh-credential: '{jenkins-ssh-credential}'
+     builders:
+       - lf-license-check:
+           file-patterns: '{file-patterns}'
+           spdx-disable: '{spdx-disable}'
+           lhc-version: '{lhc-version}'
+           license-exclude-paths: '{license-exclude-paths}'
+           licenses-allowed: '{licenses-allowed}'
+     publishers:
+       - lf-infra-publish
+ - job-template:
+     name: '{project-name}-license-check'
+     id: gerrit-license-check
+     <<: *lf_license_check
+     git-url: '$GIT_URL/$GERRIT_PROJECT'
+     scm:
+       - lf-infra-gerrit-scm:
+           git-url: '{git-url}'
+           refspec: '$GERRIT_REFSPEC'
+           branch: '$GERRIT_BRANCH'
+           # Submodules are out of the project's control
+           submodule-recursive: false
+           choosing-strategy: gerrit
+           jenkins-ssh-credential: '{jenkins-ssh-credential}'
+     triggers:
+       - gerrit:
+           server-name: '{gerrit-server-name}'
+           # Trigger should not be overridable as we want to always run
+           trigger-on:
+             - patchset-created-event:
+                 exclude-drafts: false
+                 exclude-trivial-rebase: false
+                 exclude-no-code-change: false
+             - draft-published-event
+             - comment-added-contains-event:
+                 comment-contains-value: recheck$
+           projects:
+             - project-compare-type: ANT
+               project-pattern: '**'
+               branches:
+                 - branch-compare-type: ANT
+                   branch-pattern: '**'
+ - job-template:
+     name: '{project-name}-license-check'
+     id: github-license-check
+     <<: *lf_license_check
+     properties:
+       - github:
+           url: '{git-url}/{github-org}/{project}'
+     scm:
+       - lf-infra-github-scm:
+           url: '{git-clone-url}{github-org}/{project}'
+           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
+           branch: '$sha1'
+           # Submodules are out of the project's control
+           submodule-recursive: false
+           choosing-strategy: default
+           jenkins-ssh-credential: '{jenkins-ssh-credential}'
+     triggers:
+       - github-pull-request:
+           trigger-phrase: '^recheck$'
+           only-trigger-phrase: false
+           status-context: 'License Check'
+           permit-all: true
+           github-hooks: true
  ####################
  # Info YAML Verify #
  ####################
                file-paths:
                  - compare-type: REG_EXP
                    pattern: 'packer\/provision\/.*\.sh'
 +                - compare-type: REG_EXP
 +                  pattern: 'packer\/provision\/.*\.bat'
 +                - compare-type: REG_EXP
 +                  pattern: 'packer\/provision\/.*\.ps1'
                  - compare-type: REG_EXP
                    pattern: 'packer\/provision\/{templates}\.yaml'
                  - compare-type: REG_EXP
            # included-regions MUST match Gerrit Trigger file-paths
            included-regions:
              - 'packer\/provision\/.*\.sh'
 +            - 'packer\/provision\/.*\.bat'
 +            - 'packer\/provision\/.*\.ps1'
              - 'packer\/provision\/{templates}\.yaml'
              - 'packer\/provision\/local-{templates}\.yaml'
              - 'packer\/templates\/{templates}\.json'
diff --combined jjb/lf-macros.yaml
        - inject:
            properties-file: $WORKSPACE/.dependency.properties
  
+ - builder:
+     name: lf-license-check
+     builders:
+       - inject:
+           properties-content: |
+               FILE_PATTERNS={file-patterns}
+               SPDX_DISABLE={spdx-disable}
+               LHC_VERSION={lhc-version}
+               LICENSE_EXCLUDE_PATHS={license-exclude-paths}
+               LICENSES_ALLOWED={licenses-allowed}
+       - shell: !include-raw-escape:
+           - ../shell/license-check.sh
  - builder:
      name: lf-infra-create-netrc
      builders:
      builders:
        - inject:
            properties-content: |
 -              PROJECT='{project}'
 -              GERRIT_COMMIT_MESSAGE='{gerrit-commit-message}'
 -              GERRIT_HOST='{gerrit-host}'
 -              GERRIT_TOPIC='{gerrit-topic}'
 -              GERRIT_USER='{gerrit-user}'
 -              REVIEWERS_EMAIL='{reviewers-email}'
 +              PROJECT={project}
 +              GERRIT_COMMIT_MESSAGE={gerrit-commit-message}
 +              GERRIT_HOST={gerrit-host}
 +              GERRIT_TOPIC={gerrit-topic}
 +              GERRIT_USER={gerrit-user}
 +              REVIEWERS_EMAIL={reviewers-email}
        - shell: !include-raw-escape: ../shell/gerrit-push-patch.sh
  
  - builder: