From: Gregory Meno Date: Sat, 6 May 2017 01:56:20 +0000 (-0700) Subject: limit shellcheck to files changed by the PR X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=83b99762805edd3bf133ee1a2d02674b90c241c5;p=ceph-build.git limit shellcheck to files changed by the PR also add some provisions for running locally Signed-off-by: Gregory Meno --- diff --git a/ceph-docker-lint/build/build b/ceph-docker-lint/build/build index 6f29f42b..93880e3d 100755 --- a/ceph-docker-lint/build/build +++ b/ceph-docker-lint/build/build @@ -1,5 +1,48 @@ -sudo yum -y install epel-release -sudo yum -y install ShellCheck -cd $WORKSPACE/ceph-docker -set +e -find . -name '*.sh' | grep -v NOT_MAINTAINED_ANYMORE | while read filename; do shellcheck "$filename"; done +#!/bin/bash + +set -e +set -x + + +# install some of our dependencies +if [ "${HUDSON_URL}" = "jenkins.ceph.com" ] +then + sudo yum -y install epel-release + sudo yum -y install ShellCheck + sudo yum -y install jq + pull_request_id=${ghprbPullId:-$2} + workspace=${WORKSPACE:-$1} +else + if [[ ! -x $(which jq) ]] + then + echo 'install jq first' + fi + if [[ ! -x $(which shellcheck) ]] + then + echo 'install shellcheck first' + fi + pull_request_id=${ghprbPullId:-$2} + workspace=${WORKSPACE:-$1} +fi + + +pushd "$workspace/ceph-docker" + +if [[ "$pull_request_id" -eq "" || "$ghprbCommentBody" = "jenkins lint all" ]] +then + find . -name '*.sh'| grep -v NOT_MAINTAINED_ANYMORE | + while read -r filename; do + echo "$filename"; + shellcheck "$filename" || true; + done +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 + while read -r filename; do + echo "$filename"; + shellcheck "$filename" || true; + done +fi + +popd