diff options
| -rw-r--r-- | build-gluster-org/jobs/python-lint.yml | 60 | ||||
| -rw-r--r-- | build-gluster-org/scripts/python-lint.sh | 26 | 
2 files changed, 86 insertions, 0 deletions
diff --git a/build-gluster-org/jobs/python-lint.yml b/build-gluster-org/jobs/python-lint.yml new file mode 100644 index 0000000..a039343 --- /dev/null +++ b/build-gluster-org/jobs/python-lint.yml @@ -0,0 +1,60 @@ +- job: +    name: python-lint +    node: smoke7 +    description: python validation of code using pylint and flake8 +    project-type: freestyle +    concurrent: true + +    scm: +    - glusterfs + +    properties: +    - discard-after-x: +        x: 30 +    - one-build-per-node + +    triggers: +    - gerrit: +        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 smoke" +        server-name: review.gluster.org_for-smoke-jobs +        skip-vote: +          failed: true +          unstable: true +          notbuilt: true +        projects: +          - project-compare-type: 'PLAIN' +            project-pattern: 'glusterfs' +            branches: +              - branch-compare-type: 'ANT' +                branch-pattern: '**' + +    parameters: +    - string: +        default: refs/heads/master +        description: 'For review 12345 and patch set 6, this will be refs/changes/45/12345/6. Default: Tip of master' +        name: GERRIT_REFSPEC +    - string: +        default: master +        description: 'Name of the branch you want to build from. We usually build from master' +        name: GERRIT_BRANCH + +    builders: +    - shell: !include-raw: ../scripts/python-lint.sh + +    publishers: +    - archive: +        allow-empty: true +        artifacts: "./python-lint/*" +        default-excludes: true +        fingerprint: false +        only-if-success: false + +    wrappers: +    - timestamps diff --git a/build-gluster-org/scripts/python-lint.sh b/build-gluster-org/scripts/python-lint.sh new file mode 100644 index 0000000..772b6ba --- /dev/null +++ b/build-gluster-org/scripts/python-lint.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +RESULT="$WORKSPACE/python-lint" +mkdir $RESULT + +./autogen.sh +./configure --disable-bd-xlator --enable-debug --enable-gnfs --silent + +# run flake8 +flake8 . >"$RESULT/flake8-check.txt" +FLAKE_COUNT="$(wc -l < '$RESULT/flake8-check.txt')" + +#run pylint +find . -iname "*.py" | xargs pylint --output-format=text >"$RESULT/pylint-check.txt" +PYLINT_COUNT="$(egrep -wc 'R:|C:|W:|E:|F:' pylint-check.txt)" + +#fail build if there's any pylint and flake8 related issues +if [[ "$FLAKE_COUNT" -gt 0  && "$PYLINT_COUNT" -gt 0 ]]; then +  echo "" +  echo "=========================================================" +  echo "              Result of python linter" +  echo "         Number of flake8 issues: ${FLAKE_COUNT}" +  echo "         Number of pylint issues: ${PYLINT_COUNT}" +  echo "=========================================================" +  exit 1 +fi  | 
