From: Zack Cerza Date: Wed, 31 May 2017 20:39:42 +0000 (-0600) Subject: Add ceph-docker-flake8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=02358f6862b3cc2b178d129a926d4c5838b2f56f;p=ceph-build.git Add ceph-docker-flake8 This is a blatant ripoff of ceph-docker-lint, only for Python files. Signed-off-by: Zack Cerza --- diff --git a/ceph-docker-flake8/build/build b/ceph-docker-flake8/build/build new file mode 100755 index 00000000..70a43b03 --- /dev/null +++ b/ceph-docker-flake8/build/build @@ -0,0 +1,56 @@ +#!/bin/bash + +set -e +set -x + +function generate_filelist(){ + if [[ "$pull_request_id" -eq "" || "${ghprbCommentBody:-}" = "jenkins flake8 all" ]] + then + find . -name '*.py' + else + curl -XGET "https://api.github.com/repos/ceph/ceph-docker/pulls/$pull_request_id/files" | + jq '.[].filename' | # just the files please + tr -d '"' | # remove the quoting from JSON + grep ".py$" # just the python + fi + +} + +function check(){ + local file + while read -r filename; do + pushd "$(dirname "$filename")" + file=$(basename "$filename") + sudo docker run --rm -v "$(pwd)"/"$file":/"$file" eeacms/flake8 /"$file" + popd + done + return $? +} + +function main() { + # install some of our dependencies + if [ "${HUDSON_URL}" = "https://jenkins.ceph.com/" ] + then + sudo yum -y install epel-release + sudo yum -y install docker jq + sudo systemctl start docker + pull_request_id=${ghprbPullId:-$2} + workspace=${WORKSPACE:-$1} + else + if ! command -v docker || ! command -v jq + then + echo "docker or jq is/are missing, install it/them" + exit 1 + fi + pull_request_id=${ghprbPullId:-$2} + workspace=${WORKSPACE:-$1} + fi + + + pushd "$workspace/ceph-docker" + generate_filelist | check + popd + exit $? +} + +main "$@" diff --git a/ceph-docker-flake8/config/definitions/ceph-docker-flake8.yml b/ceph-docker-flake8/config/definitions/ceph-docker-flake8.yml new file mode 100644 index 00000000..7f0d29d5 --- /dev/null +++ b/ceph-docker-flake8/config/definitions/ceph-docker-flake8.yml @@ -0,0 +1,60 @@ +- scm: + name: ceph-docker + scm: + - git: + url: https://github.com/ceph/ceph-docker.git + branches: + - ${sha1} + refspec: +refs/pull/*:refs/remotes/origin/pr/* + browser: auto + timeout: 20 + skip-tag: true + wipe-workspace: false + basedir: "ceph-docker" + +- job: + name: ceph-docker-flake8 + node: small && centos7 + defaults: global + display-name: 'ceph-docker-flake8' + properties: + - github: + url: https://github.com/ceph/ceph-docker/ + logrotate: + daysToKeep: 15 + numToKeep: 30 + artifactDaysToKeep: -1 + artifactNumToKeep: -1 + + parameters: + - string: + name: sha1 + description: "A pull request ID, like 'origin/pr/72/head'" + + triggers: + - github-pull-request: + admin-list: + - alfredodeza + - ktdreyer + - gmeno + - zcerza + org-list: + - ceph + trigger-phrase: 'jenkins flake8' + only-trigger-phrase: false + github-hooks: true + permit-all: true + auto-close-on-fail: false + status-context: "Testing: for sloppy python" + started-status: "Running: flake8" + success-status: "OK - nice work" + failure-status: "FAIL - please clean up for merge" + + scm: + - ceph-docker + + builders: + - shell: + !include-raw: + - ../../build/build +