You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2020/03/13 00:20:09 UTC

[kudu] branch master updated: [build] Fail the LINT build with Java static analysis issues

This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b0fc45  [build] Fail the LINT build with Java static analysis issues
5b0fc45 is described below

commit 5b0fc45d610237983ac860e9ad88fe01424802eb
Author: Grant Henke <gr...@apache.org>
AuthorDate: Wed Mar 11 13:43:32 2020 -0500

    [build] Fail the LINT build with Java static analysis issues
    
    This patch changes the Gradle build to fail when static analysis
    issues are found. In the past warnings would be logged and reports
    were created, but the build would still succeed.
    
    A `-PignoreCheckFailures` was added in case users wanted to
    manually revert back to the old behavior.
    
    Additionally the LINT Jenkins build was updated to run the
    static analysis checks and fail if any are found.
    
    Change-Id: I6fb8494639b1bbf9be6d2bd214a986b101496525
    Reviewed-on: http://gerrit.cloudera.org:8080/15409
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
 build-support/jenkins/build-and-test.sh | 41 +++++++++++++++++++++++++++++----
 java/gradle/quality.gradle              | 12 +++++++---
 2 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/build-support/jenkins/build-and-test.sh b/build-support/jenkins/build-and-test.sh
index 8231835..7bea8da 100755
--- a/build-support/jenkins/build-and-test.sh
+++ b/build-support/jenkins/build-and-test.sh
@@ -56,6 +56,9 @@
 #
 #   BUILD_JAVA        Default: 1
 #     Build and test java code if this is set to 1.
+#     Note: The Java code required for the C++ code and tests to run,
+#     such as the HMS plugin and the Java subprocess, will still be built
+#     even if set to 0.
 #
 #   BUILD_PYTHON       Default: 1
 #     Build and test the Python wrapper of the client API.
@@ -276,6 +279,10 @@ else
   CLANG=$(pwd)/thirdparty/clang-toolchain/bin/clang
 fi
 
+# Make sure we use JDK8
+export JAVA_HOME=$JAVA8_HOME
+export PATH=$JAVA_HOME/bin:$PATH
+
 # Some portions of the C++ build may depend on Java code, so we may run Gradle
 # while building. Pass in some flags suitable for automated builds; these will
 # also be used in the Java build.
@@ -357,8 +364,35 @@ fi
 
 # Short circuit for LINT builds.
 if [ "$BUILD_TYPE" = "LINT" ]; then
-  make lint | tee $TEST_LOGDIR/lint.log
-  exit $?
+  LINT_FAILURES=""
+  LINT_RESULT=0
+
+  if [ "$BUILD_JAVA" == "1" ]; then
+    pushd $SOURCE_ROOT/java
+    if ! ./gradlew $EXTRA_GRADLE_FLAGS clean check -x test $EXTRA_GRADLE_TEST_FLAGS; then
+      LINT_RESULT=1
+      LINT_FAILURES="$LINT_FAILURES"$'Java Gradle check failed\n'
+    fi
+    popd
+  fi
+
+  if ! make lint | tee $TEST_LOGDIR/lint.log; then
+    LINT_RESULT=1
+    LINT_FAILURES="$LINT_FAILURES"$'make lint failed\n'
+  fi
+
+  if [ -n "$LINT_FAILURES" ]; then
+    echo
+    echo
+    echo ======================================================================
+    echo Lint Failure summary
+    echo ======================================================================
+    echo $LINT_FAILURES
+    echo
+    echo
+  fi
+
+  exit $LINT_RESULT
 fi
 
 # Short circuit for IWYU builds: run the include-what-you-use tool on the files
@@ -443,9 +477,6 @@ if [ "$BUILD_JAVA" == "1" ]; then
   echo Building and testing java...
   echo ------------------------------------------------------------
 
-  # Make sure we use JDK8
-  export JAVA_HOME=$JAVA8_HOME
-  export PATH=$JAVA_HOME/bin:$PATH
   pushd $SOURCE_ROOT/java
   set -x
 
diff --git a/java/gradle/quality.gradle b/java/gradle/quality.gradle
index 640f9fa..44785b8 100644
--- a/java/gradle/quality.gradle
+++ b/java/gradle/quality.gradle
@@ -23,10 +23,16 @@ apply plugin: "com.github.ben-manes.versions" // Provides a task to determine wh
 apply plugin: "ru.vyarus.animalsniffer" // Ensures Java code uses APIs from a particular version of Java.
 apply plugin: "scalafmt" // Automatically formats Scala code on each build.
 
+def ignoreCheckFailures = false
+if (propertyExists("ignoreCheckFailures")) {
+  ignoreCheckFailures = true
+}
+
 checkstyle {
   toolVersion = versions.checkstyle
   configDir = file("$rootProject.projectDir/config/checkstyle")
-  ignoreFailures = true
+  ignoreFailures = ignoreCheckFailures
+  maxWarnings = 0
   showViolations = true
 }
 
@@ -38,7 +44,7 @@ task checkstyle(dependsOn: [checkstyleMain, checkstyleTest], group: "Verificatio
 
 spotbugs {
   toolVersion = versions.spotBugs
-  ignoreFailures = true
+  ignoreFailures = ignoreCheckFailures
   effort = "max"
   reportLevel = "low"
   excludeFilter = file("$rootProject.projectDir/config/spotbugs/excludeFilter.xml")
@@ -79,7 +85,7 @@ if(!JavaVersion.current().isJava12Compatible()) {
     options.errorprone {
       disableWarningsInGeneratedCode = true
       excludedPaths = '.*/build/generated.*/.*'
-      allErrorsAsWarnings = true
+      allErrorsAsWarnings = false
       def fix = propertyWithDefault("errorprone-fix", "")
       if (!fix.isEmpty()) {
         errorproneArgs += ['-XepPatchChecks:' + fix, '-XepPatchLocation:IN_PLACE']