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 a626e27 [build] Skip builds with no functional changes
a626e27 is described below
commit a626e27e85e2dab780164c5d3bd075a856b11a55
Author: Grant Henke <[email protected]>
AuthorDate: Wed Mar 18 14:54:19 2020 -0500
[build] Skip builds with no functional changes
This patch introduces the option to skip builds in pre-commit when
the changes are in files or directories that do not impact the build
or test.
This functionality is disabled by default but can be enabled on our
Jenkins instance by setting `KUDU_ALLOW_SKIPPED_TESTS=1`.
I also hid the `DONT_BUILD` functionality behind the
`KUDU_ALLOW_SKIPPED_TESTS` flag to ensure commits with
`DONT_BUILD` in them do not prevent other builds that are using
this script from running.
Change-Id: If56db6593ce7aa64b562a9fb277a337bffc7b532
Reviewed-on: http://gerrit.cloudera.org:8080/15481
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
---
build-support/jenkins/build-and-test.sh | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/build-support/jenkins/build-and-test.sh
b/build-support/jenkins/build-and-test.sh
index 49b5cfd..a532658 100755
--- a/build-support/jenkins/build-and-test.sh
+++ b/build-support/jenkins/build-and-test.sh
@@ -85,13 +85,34 @@
#
# KUDU_REPORT_TEST_RESULTS Default: 0
# If non-zero, tests are reported to the central test server.
+#
+# KUDU_ALLOW_SKIPPED_TESTS Default: 0
+# If set to 1, commits with changes that do not impact the build or tests
exit early.
+# Additionally, commits with "DONT_BUILD" in the commit message will exit
early.
+
+if [ "$KUDU_ALLOW_SKIPPED_TESTS" == "1" ]; then
+ # If the commit only contains changes that do not impact the build or tests,
exit immediately.
+ # This check is conservative and attempts to have no false positives, but
may have false negatives.
+ if ! git diff-tree --no-commit-id --name-only -r HEAD |
+ grep -qvE
"^\.dockerignore|^\.gitignore|^\.ycm_extra_conf.py|^docker/|^docs/|^kubernetes/|LICENSE\.txt|NOTICE\.txt|.*\.adoc|.*\.md";
then
+ echo
+ echo ------------------------------------------------------------
+ echo "*** Changes are only in files or directories that do not impact the
build or tests. Exiting."
+ echo ------------------------------------------------------------
+ echo
+ exit 0
+ fi
-# If a commit messages contains a line that says 'DONT_BUILD', exit
-# immediately.
-DONT_BUILD=$(git show|egrep '^\s{4}DONT_BUILD$')
-if [ "x$DONT_BUILD" != "x" ]; then
+ # If a commit messages contains a line that says 'DONT_BUILD', exit
immediately.
+ DONT_BUILD=$(git show|egrep '^\s{4}DONT_BUILD$')
+ if [ "x$DONT_BUILD" != "x" ]; then
+ echo
+ echo ------------------------------------------------------------
echo "*** Build not requested. Exiting."
+ echo ------------------------------------------------------------
+ echo
exit 1
+ fi
fi
set -e