You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/11/05 07:25:00 UTC

[jira] [Commented] (AVRO-1887) set up precommit checks via Apache Yetus

    [ https://issues.apache.org/jira/browse/AVRO-1887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16674759#comment-16674759 ] 

ASF GitHub Bot commented on AVRO-1887:
--------------------------------------

Fokko closed pull request #344: AVRO-1887. Setup precommit hooks using Apache Yetus
URL: https://github.com/apache/avro/pull/344
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/build.sh b/build.sh
index 8810d6bfa..2abb45aba 100755
--- a/build.sh
+++ b/build.sh
@@ -38,6 +38,8 @@ do
   case "$target" in
 
     test)
+      java -version
+
       # run lang-specific tests
       (cd lang/java; ./build.sh test)
       # install java artifacts required by other builds and interop tests
diff --git a/pom.xml b/pom.xml
index e3f48442c..d0c9d274b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -281,6 +281,7 @@
                 <exclude>lang/csharp/Avro.sln</exclude> <!-- visual studio -->
                 <!-- build-related files -->
                 <exclude>BUILD.md</exclude>
+                <exclude>share/precommit/README.md</exclude>
                 <exclude>**/VERSION.txt</exclude>
                 <exclude>**/dependency-reduced-pom.xml</exclude>
                 <exclude>lang/perl/.shipit</exclude>
diff --git a/share/precommit/README.md b/share/precommit/README.md
new file mode 100644
index 000000000..0219c172e
--- /dev/null
+++ b/share/precommit/README.md
@@ -0,0 +1,9 @@
+# Apache Yetus integration
+
+The plugin under `buildtest.sh` will provide the plugin to run the base `build.sh test` which will trigger the tests of the main Avro projects, and the sections below `lang/*/build.sh`. To run this, use:
+
+```bash
+test-patch --plugins=buildtest --user-plugins=share/precommit/ --run-tests --empty-patch --docker --dockerFile=share/docker/Dockerfile --dirty-workspace --verbose=true
+```
+
+Note, that this is still a very crude implementation of Apache Yetus, and in the future we would like to refine this to provide plugins for the different languages.
diff --git a/share/precommit/buildtest.sh b/share/precommit/buildtest.sh
new file mode 100644
index 000000000..86a82865d
--- /dev/null
+++ b/share/precommit/buildtest.sh
@@ -0,0 +1,80 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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 WARRCMAKEIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_test_type buildtest
+
+VERBOSE=false
+
+# files that we want to kick off
+BUILD_FILES=()
+
+
+function buildtest_usage
+{
+  yetus_add_option "--verbose=<true|false>" "print output to console (default: false)"
+}
+
+function buildtest_parse_args
+{
+  local i
+
+  for i in "$@"; do
+    case ${i} in
+    --verbose=*)
+      VERBOSE=${i#*=}
+    ;;
+    esac
+  done
+}
+
+function buildtest_filefilter
+{
+  local filename=$1
+
+  if [[ ${filename} =~ build\.sh$ ]]; then
+    yetus_debug "Buildtest: run the tests for ${filename}"
+    add_test buildtest
+    yetus_add_array_element BUILD_FILES "${filename}"
+  fi
+}
+
+function buildtest_postcompile
+{
+  for file in "${BUILD_FILES[@]}}"; do
+
+    big_console_header "Running ${file}"
+
+    #shellcheck disable=SC2001
+    sanitized_filename=$(echo "${file}" | sed -e 's,[/\.],-,g')
+
+    if [ "$VERBOSE" == "true" ]; then
+      # Write both to stdout and the file using tee
+      eval "cd ${BASEDIR}; ./${file} test" | tee -a "${PATCH_DIR}/build-${sanitized_filename}.txt"
+      result=${PIPESTATUS[0]}
+    else
+      eval "cd ${BASEDIR}; ./${file} test" >> "${PATCH_DIR}/build-${sanitized_filename}.txt"
+      result=$?
+    fi
+
+    if [[ ${result} -ne 0 ]]; then
+      add_vote_table -1 buildtest "The testsuite failed, please check the output"
+      add_footer_table buildtest "@@BASE@@/build-${sanitized_filename}.txt"
+      return 1
+    fi
+
+    add_vote_table +1 buildtest "The build has passed"
+  done
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> set up precommit checks via Apache Yetus
> ----------------------------------------
>
>                 Key: AVRO-1887
>                 URL: https://issues.apache.org/jira/browse/AVRO-1887
>             Project: Avro
>          Issue Type: Task
>          Components: build, community
>            Reporter: Sean Busbey
>            Assignee: Suraj Acharya
>            Priority: Blocker
>         Attachments: AVRO-1887-0.patch, AVRO-1887-1.patch, AVRO-1887-2.patch
>
>
> The lack of automated checks for things like doing a full build is negatively impacting my ability to do timely reviews. We should leverage the work done by other communities and get precommit checks going with Apache Yetus ([ref Apache Yetus Precommit|http://yetus.apache.org/documentation/0.3.0/precommit-basic/])
> Yetus has built in support for using Docker as a containerized build environment ([ref docs|https://yetus.apache.org/documentation/0.3.0/precommit-advanced/#Docker_Support]), but I don't know if we can use the one we have directly or if we'll need to do some refactoring.
> Implementing this will ultimately require a committer (so that they can make changes to builds.apache.org), but a non-cmmitter can get the bulk of the work done by managing to do local yetus checks with the docker feature active.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)