Skip to content

Commit 30142cc

Browse files
authored
HBASE-28054 Add spotless in hbase-connectors pre commit check (#122)
Signed-off-by: <[email protected]> Signed-off-by: <[email protected]>
1 parent ee2b51c commit 30142cc

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

dev-support/jenkins/hbase-personality.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,54 @@ function hb_maven_modules_worker {
363363

364364
# } End workaround stuff caused by our need for a package phase to run
365365
# on hbase-spark-protocol and hbase-spark-protocol-shaded
366+
367+
######################################
368+
# Below plugin is copied from https://github.com/apache/hbase/blob/master/dev-support/hbase-personality.sh
369+
######################################
370+
371+
add_test_type spotless
372+
373+
## @description spotless file filter
374+
## @audience private
375+
## @stability evolving
376+
## @param filename
377+
function spotless_filefilter
378+
{
379+
# always add spotless check as it can format almost all types of files
380+
add_test spotless
381+
}
382+
## @description run spotless:check to check format issues
383+
## @audience private
384+
## @stability evolving
385+
## @param repostatus
386+
function spotless_rebuild
387+
{
388+
local repostatus=$1
389+
local logfile="${PATCH_DIR}/${repostatus}-spotless.txt"
390+
391+
if ! verify_needed_test spotless; then
392+
return 0
393+
fi
394+
395+
big_console_header "Checking spotless on ${repostatus}"
396+
397+
start_clock
398+
399+
local -a maven_args=('spotless:check')
400+
401+
# disabled because "maven_executor" needs to return both command and args
402+
# shellcheck disable=2046
403+
echo_and_redirect "${logfile}" $(maven_executor) "${maven_args[@]}"
404+
405+
count=$(${GREP} -c '\[ERROR\]' "${logfile}")
406+
if [[ ${count} -gt 0 ]]; then
407+
add_vote_table -1 spotless "${repostatus} has ${count} errors when running spotless:check, run spotless:apply to fix."
408+
add_footer_table spotless "@@BASE@@/${repostatus}-spotless.txt"
409+
return 1
410+
fi
411+
412+
add_vote_table +1 spotless "${repostatus} has no errors when running spotless:check."
413+
return 0
414+
}
415+
416+
######################################

0 commit comments

Comments
 (0)