[07/15] oozie git commit: OOZIE-1986 Add FindBugs report to pre-commit build (andras.piros via rkanter)
OOZIE-1986 Add FindBugs report to pre-commit build (andras.piros via rkanter) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/51920be8 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/51920be8 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/51920be8 Branch: refs/heads/oya Commit: 51920be8480c80638e11faff20ad089b02a7f5fb Parents: bd54452 Author: Robert Kanter Authored: Tue Oct 18 18:27:20 2016 -0700 Committer: Robert Kanter Committed: Tue Oct 18 18:27:20 2016 -0700 -- bin/test-patch-11-findbugs-diff | 274 +++ ...est-patch-11-findbugs-diff-0.1.0-all.jar.md5 | 1 + pom.xml | 1 + release-log.txt | 1 + 4 files changed, 277 insertions(+) -- http://git-wip-us.apache.org/repos/asf/oozie/blob/51920be8/bin/test-patch-11-findbugs-diff -- diff --git a/bin/test-patch-11-findbugs-diff b/bin/test-patch-11-findbugs-diff new file mode 100644 index 000..0376ab0 --- /dev/null +++ b/bin/test-patch-11-findbugs-diff @@ -0,0 +1,274 @@ +#!/bin/bash +# +# 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. + +if [ "${TESTPATCHDEBUG}" == "true" ] ; then + set -x +fi + +BASEDIR=$(pwd) +TASKNAME="FINDBUGS_DIFF" +OP="" +TEMPDIR=${BASEDIR}/tmp +REPORTDIR="" +SUMMARYFILE="" +STDOUT="/dev/null" +MVNPASSTHRU="" +FINDBUGS_JAR_URL=https://repo1.maven.org/maven2/me/andrz/findbugs/findbugs-diff/0.1.0/findbugs-diff-0.1.0-all.jar +FINDBUGS_JAR=findbugs-diff-0.1.0-all.jar +# Priorities.HIGH_PRIORITY and Priorities.NORMAL_PRIORITY +FINDBUGS_PRIORITY_THRESHOLD=2 +# Scariest and scary +FINDBUGS_RANK_THRESHOLD=9 +FINDBUGS_XML_NAME=findbugsXml.xml + + +cleanup_and_exit() { + remove_file_if_present "${DIFF_DIR}/${FINDBUGS_JAR}" + remove_file_if_present "${DIFF_DIR}/${FINDBUGS_JAR}.md5" + + exit "$1" +} + + +remove_file_if_present() { + FILE_NAME=$1 + + if [ -f "${FILE_NAME}" ]; then +rm -f "${FILE_NAME}" +echo "[TRACE] File [${FILE_NAME}] removed" + fi +} + +print_usage() { + echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir= --reportdir= --summaryfile=) [--verbose] [-D...] [-P...]" + echo +} + + +parse_args() { + for i in "$@"; do +case $i in +--taskname) + echo ${TASKNAME} + exit 0 + ;; +--op=*) + OP=${i#*=} + ;; +--tempdir=*) + TEMPDIR=${i#*=} + ;; +--reportdir=*) + REPORTDIR=${i#*=} + ;; +--summaryfile=*) + SUMMARYFILE=${i#*=} + ;; +--verbose) + STDOUT="/dev/stdout" + ;; +-D*) + MVNPASSTHRU="${MVNPASSTHRU} $i" + ;; +-P*) + MVNPASSTHRU="${MVNPASSTHRU} $i" + ;; +esac + done + if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then +echo "Missing options" +echo +print_usage +cleanup_and_exit 1 + fi + if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then +echo "Invalid operation" +echo +print_usage +cleanup_and_exit 1 + fi +} + + +verify_and_save_findbugs_output() { + FINDBUGS_OUTPUT_DIR=$1 + BRANCH_LABEL=$2 + REPORT_SUFFIX=$3 + + echo "[TRACE] Verifying and saving FindBugs output in ${BRANCH_LABEL}" + + mvn clean verify -DskipTests "${MVNPASSTHRU}" | tee "${REPORTDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" >> ${STDOUT} + + if [ ! -d "$FINDBUGS_OUTPUT_DIR" ]; then +mkdir -p "${FINDBUGS_OUTPUT_DIR}" + fi + + find . -name ${FINDBUGS_XML_NAME} -exec rsync -avqR {} "${FINDBUGS_OUTPUT_DIR}" ";" + + if [ "$(ls -A "${FINDBUGS_OUTPUT_DIR}")" ] ; then +echo "{color:green}+1{color} ${BRANCH_LABEL} produces FindBugs output" >> "${TEMPDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" + else +echo "{color:red}-1{color} ${BRANCH_LABEL} does not produce FindBugs output" >> "${TEMPDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" + fi + + echo "[TRACE] FindBugs output in ${BRANCH_LABEL} verified and saved" +} + + +download_and_check_findbugs_diff_jar() { + DIFF_DIR=$1 + BASH_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + mkdir -p "${DIFF_DIR}" + + echo "[TRACE] Downloading FindBugs diff JAR from ${FINDBUGS_JAR_URL}" + + curl -Ls ${FINDBUGS_JAR_URL} > "
oozie git commit: OOZIE-1986 Add FindBugs report to pre-commit build (andras.piros via rkanter)
Repository: oozie Updated Branches: refs/heads/master bd5445280 -> 51920be84 OOZIE-1986 Add FindBugs report to pre-commit build (andras.piros via rkanter) Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/51920be8 Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/51920be8 Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/51920be8 Branch: refs/heads/master Commit: 51920be8480c80638e11faff20ad089b02a7f5fb Parents: bd54452 Author: Robert Kanter Authored: Tue Oct 18 18:27:20 2016 -0700 Committer: Robert Kanter Committed: Tue Oct 18 18:27:20 2016 -0700 -- bin/test-patch-11-findbugs-diff | 274 +++ ...est-patch-11-findbugs-diff-0.1.0-all.jar.md5 | 1 + pom.xml | 1 + release-log.txt | 1 + 4 files changed, 277 insertions(+) -- http://git-wip-us.apache.org/repos/asf/oozie/blob/51920be8/bin/test-patch-11-findbugs-diff -- diff --git a/bin/test-patch-11-findbugs-diff b/bin/test-patch-11-findbugs-diff new file mode 100644 index 000..0376ab0 --- /dev/null +++ b/bin/test-patch-11-findbugs-diff @@ -0,0 +1,274 @@ +#!/bin/bash +# +# 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. + +if [ "${TESTPATCHDEBUG}" == "true" ] ; then + set -x +fi + +BASEDIR=$(pwd) +TASKNAME="FINDBUGS_DIFF" +OP="" +TEMPDIR=${BASEDIR}/tmp +REPORTDIR="" +SUMMARYFILE="" +STDOUT="/dev/null" +MVNPASSTHRU="" +FINDBUGS_JAR_URL=https://repo1.maven.org/maven2/me/andrz/findbugs/findbugs-diff/0.1.0/findbugs-diff-0.1.0-all.jar +FINDBUGS_JAR=findbugs-diff-0.1.0-all.jar +# Priorities.HIGH_PRIORITY and Priorities.NORMAL_PRIORITY +FINDBUGS_PRIORITY_THRESHOLD=2 +# Scariest and scary +FINDBUGS_RANK_THRESHOLD=9 +FINDBUGS_XML_NAME=findbugsXml.xml + + +cleanup_and_exit() { + remove_file_if_present "${DIFF_DIR}/${FINDBUGS_JAR}" + remove_file_if_present "${DIFF_DIR}/${FINDBUGS_JAR}.md5" + + exit "$1" +} + + +remove_file_if_present() { + FILE_NAME=$1 + + if [ -f "${FILE_NAME}" ]; then +rm -f "${FILE_NAME}" +echo "[TRACE] File [${FILE_NAME}] removed" + fi +} + +print_usage() { + echo "Usage: $0 --taskname | (--op=pre|post|report --tempdir= --reportdir= --summaryfile=) [--verbose] [-D...] [-P...]" + echo +} + + +parse_args() { + for i in "$@"; do +case $i in +--taskname) + echo ${TASKNAME} + exit 0 + ;; +--op=*) + OP=${i#*=} + ;; +--tempdir=*) + TEMPDIR=${i#*=} + ;; +--reportdir=*) + REPORTDIR=${i#*=} + ;; +--summaryfile=*) + SUMMARYFILE=${i#*=} + ;; +--verbose) + STDOUT="/dev/stdout" + ;; +-D*) + MVNPASSTHRU="${MVNPASSTHRU} $i" + ;; +-P*) + MVNPASSTHRU="${MVNPASSTHRU} $i" + ;; +esac + done + if [[ "${TASKNAME}" == "" || "${OP}" == "" || "${TEMPDIR}" == "" || "${REPORTDIR}" == "" || "${SUMMARYFILE}" == "" ]] ; then +echo "Missing options" +echo +print_usage +cleanup_and_exit 1 + fi + if [[ "${OP}" != "pre" && "${OP}" != "post" && "${OP}" != "report" ]] ; then +echo "Invalid operation" +echo +print_usage +cleanup_and_exit 1 + fi +} + + +verify_and_save_findbugs_output() { + FINDBUGS_OUTPUT_DIR=$1 + BRANCH_LABEL=$2 + REPORT_SUFFIX=$3 + + echo "[TRACE] Verifying and saving FindBugs output in ${BRANCH_LABEL}" + + mvn clean verify -DskipTests "${MVNPASSTHRU}" | tee "${REPORTDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" >> ${STDOUT} + + if [ ! -d "$FINDBUGS_OUTPUT_DIR" ]; then +mkdir -p "${FINDBUGS_OUTPUT_DIR}" + fi + + find . -name ${FINDBUGS_XML_NAME} -exec rsync -avqR {} "${FINDBUGS_OUTPUT_DIR}" ";" + + if [ "$(ls -A "${FINDBUGS_OUTPUT_DIR}")" ] ; then +echo "{color:green}+1{color} ${BRANCH_LABEL} produces FindBugs output" >> "${TEMPDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" + else +echo "{color:red}-1{color} ${BRANCH_LABEL} does not produce FindBugs output" >> "${TEMPDIR}/${TASKNAME}-${REPORT_SUFFIX}.txt" + fi + + echo "[TRACE] FindBugs output in ${BRANCH_LABEL} verified and saved" +} + + +download_and_check_findbugs_diff_jar() { + DIFF_DIR=$1 + BASH_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + mkdir -p "${DIFF_DIR}" + + echo "[TRACE] Downloadi