You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/01/05 07:13:54 UTC

[kyuubi] branch master updated: [KYUUBI #4078] [INFRA] Enable shellcheck on CI

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2dac36417 [KYUUBI #4078] [INFRA] Enable shellcheck on CI
2dac36417 is described below

commit 2dac364177b06571b7218054791398b0b5cf11b6
Author: 袁福元 <yu...@mafengwo.com>
AuthorDate: Thu Jan 5 15:13:43 2023 +0800

    [KYUUBI #4078] [INFRA] Enable shellcheck on CI
    
    ### _Why are the changes needed?_
    
    Fix #2062
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4078 from xiaoyuandajian/fix-#2062.
    
    Closes #4078
    
    a5a01945 [Cheng Pan] Update .github/workflows/style.yml
    3c08e692 [袁福元] fix the shellcheck found error file
    a33cbb22 [袁福元] fix the shellcheck found error file
    da195782 [袁福元] fix the shellcheck found error file
    b24e6adf [袁福元] fix the shellcheck found error file
    90ef0712 [袁福元] fix the shellcheck found error file
    42acb31f [袁福元] fixup! test1
    31c1783d [袁福元] fixup! test
    c40b5f38 [袁福元] Revert "test"
    d97801fa [袁福元] Merge remote-tracking branch 'origin/fix-#2062' into fix-#2062
    39a9ff31 [袁福元] test
    fc7198da [xiaoyuandajian] Update style.yml
    62e80726 [袁福元] test
    0abdef36 [xiaoyuandajian] Delete main.yml
    1e252e2a [xiaoyuandajian] Create main.yml
    c19728ec [xiaoyuandajian] Delete main.yml
    5db61e5a [xiaoyuandajian] Delete main1.yml
    9e27a363 [xiaoyuandajian] Create main1.yml
    69540652 [xiaoyuandajian] Create main.yml
    
    Lead-authored-by: 袁福元 <yu...@mafengwo.com>
    Co-authored-by: xiaoyuandajian <51...@users.noreply.github.com>
    Co-authored-by: Cheng Pan <pa...@gmail.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .github/workflows/style.yml | 10 ++++++++++
 bin/docker-image-tool.sh    |  1 +
 bin/kyuubi                  |  2 ++
 bin/load-kyuubi-env.sh      |  3 ++-
 bin/stop-application.sh     |  1 +
 build/dist                  | 18 ++++++++++++++++++
 6 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml
index e70cb1bdc..48603c2ed 100644
--- a/.github/workflows/style.yml
+++ b/.github/workflows/style.yml
@@ -100,3 +100,13 @@ jobs:
           echo "If there is a problem that cannot be fixed by the command, "
           echo "you need to manually fix it by following the information told by the command above"
           echo "---------------------------------------------------------------------------------"
+
+  shellcheck:
+    name: Shellcheck
+    runs-on: ubuntu-22.04
+    steps:
+      - uses: actions/checkout@v3
+      - name: check bin directory
+        uses: ludeeus/action-shellcheck@master
+        with:
+          severity: error
diff --git a/bin/docker-image-tool.sh b/bin/docker-image-tool.sh
index ac29ee261..e9e4338b5 100755
--- a/bin/docker-image-tool.sh
+++ b/bin/docker-image-tool.sh
@@ -227,6 +227,7 @@ Examples:
 EOF
 }
 
+# shellcheck disable=SC2199
 if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   usage
   exit 0
diff --git a/bin/kyuubi b/bin/kyuubi
index f40f2828e..414bdeb86 100755
--- a/bin/kyuubi
+++ b/bin/kyuubi
@@ -30,6 +30,7 @@ function usage() {
   echo "    -h | --help  - Show this help message"
 }
 
+# shellcheck disable=SC2199
 if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
   usage
   exit 0
@@ -48,6 +49,7 @@ function kyuubi_rotate_log() {
     num=${KYUUBI_MAX_LOG_FILES}
   else
     echo "Error: KYUUBI_MAX_LOG_FILES must be a positive number, but got ${KYUUBI_MAX_LOG_FILES}"
+    # shellcheck disable=SC2242
     exit -1
   fi
 
diff --git a/bin/load-kyuubi-env.sh b/bin/load-kyuubi-env.sh
index 0f0beaef9..bfb922658 100755
--- a/bin/load-kyuubi-env.sh
+++ b/bin/load-kyuubi-env.sh
@@ -59,11 +59,12 @@ fi
 
 export KYUUBI_WORK_DIR_ROOT="${KYUUBI_WORK_DIR_ROOT:-"${KYUUBI_HOME}/work"}"
 if [[ ! -e ${KYUUBI_WORK_DIR_ROOT} ]]; then
-  mkdir -p ${KYUUBI_WORK_DIR_ROOT}
+  mkdir -p "${KYUUBI_WORK_DIR_ROOT}"
 fi
 
 if [[ -z ${JAVA_HOME} ]]; then
   if [[ $(command -v java) ]]; then
+    # shellcheck disable=SC2155
     export JAVA_HOME="$(dirname $(dirname $(which java)))"
   fi
 fi
diff --git a/bin/stop-application.sh b/bin/stop-application.sh
index 74a714dca..b208ab505 100755
--- a/bin/stop-application.sh
+++ b/bin/stop-application.sh
@@ -16,6 +16,7 @@
 # limitations under the License.
 #
 
+# shellcheck disable=SC2071
 if [[ $# < 1 ]] ; then
   echo "USAGE: $0 <application_id>"
   exit 1
diff --git a/build/dist b/build/dist
index 7d0fa4ec3..062bc49bc 100755
--- a/build/dist
+++ b/build/dist
@@ -105,6 +105,7 @@ done
 # Setup java
 if [[ -z "$JAVA_HOME" ]]; then
   # Fallback on JAVA_HOME from rpm, if found
+  # shellcheck disable=SC2046
   if [ $(command -v rpm) ]; then
     RPM_JAVA_HOME="$(rpm -E %java_home 2>/dev/null)"
     if [ "$RPM_JAVA_HOME" != "%java_home" ]; then
@@ -114,8 +115,10 @@ if [[ -z "$JAVA_HOME" ]]; then
   fi
 
   if [ -z "$JAVA_HOME" ]; then
+    # shellcheck disable=SC2006
     if [[ `command -v java` ]]; then
       # If java is in /usr/bin/java, we want /usr
+      # shellcheck disable=SC2046
       JAVA_HOME="$(dirname $(dirname $(which java)))"
     fi
   fi
@@ -123,6 +126,7 @@ fi
 
 if [[ -z "$JAVA_HOME" ]]; then
   echo "Error: JAVA_HOME is not set, cannot proceed."
+  # shellcheck disable=SC2242
   exit -1
 fi
 
@@ -141,41 +145,49 @@ fi
 if [ ! "$(command -v "$MVN")" ] ; then
     echo -e "Could not locate Maven command: '$MVN'."
     echo -e "Specify the Maven command with the --mvn flag"
+    # shellcheck disable=SC2242
     exit -1;
 fi
 
 echo "MVN is set to $MVN"
 
+# shellcheck disable=SC2068
 VERSION=$("$MVN" help:evaluate -Dexpression=project.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 JAVA_VERSION=$("$MVN" help:evaluate -Dexpression=java.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 SCALA_VERSION=$("$MVN" help:evaluate -Dexpression=scala.binary.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 FLINK_VERSION=$("$MVN" help:evaluate -Dexpression=flink.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 SPARK_VERSION=$("$MVN" help:evaluate -Dexpression=spark.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 HADOOP_VERSION=$("$MVN" help:evaluate -Dexpression=hadoop.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
     | tail -n 1)
 
+# shellcheck disable=SC2068
 HIVE_VERSION=$("$MVN" help:evaluate -Dexpression=hive.version $@ 2>/dev/null\
     | grep -v "INFO"\
     | grep -v "WARNING"\
@@ -217,6 +229,7 @@ export MAVEN_OPTS="${MAVEN_OPTS:--Xmx2g}"
 BUILD_COMMAND=("$MVN" clean install $MVN_DIST_OPT $@)
 
 echo -e "\nBuilding with..."
+# shellcheck disable=SC2145
 echo -e "\$ ${BUILD_COMMAND[@]}\n"
 
 "${BUILD_COMMAND[@]}"
@@ -240,6 +253,7 @@ echo "Flink $FLINK_VERSION" >> "$DISTDIR/RELEASE"
 echo "Spark $SPARK_VERSION" >> "$DISTDIR/RELEASE"
 echo "Kyuubi Hadoop $HADOOP_VERSION" >> "$DISTDIR/RELEASE"
 echo "Hive $HIVE_VERSION" >> "$DISTDIR/RELEASE"
+# shellcheck disable=SC2145
 echo "Build flags: $@" >> "$DISTDIR/RELEASE"
 
 # Copy kyuubi server jars
@@ -249,6 +263,7 @@ cp -r "$KYUUBI_HOME"/kyuubi-assembly/target/scala-$SCALA_VERSION/jars/*.jar "$DI
 cp "$KYUUBI_HOME"/kyuubi-hive-beeline/target/*.jar "$DISTDIR/beeline-jars/"
 
 # Share the jars w/ server to reduce binary size
+# shellcheck disable=SC2045
 for jar in $(ls "$DISTDIR/jars/"); do
   if [[ -f "$DISTDIR/beeline-jars/$jar" ]]; then
     (cd $DISTDIR/beeline-jars; ln -snf "../jars/$jar" "$DISTDIR/beeline-jars/$jar")
@@ -266,6 +281,7 @@ cp "$KYUUBI_HOME/externals/kyuubi-trino-engine/target/kyuubi-trino-engine_${SCAL
 cp -r "$KYUUBI_HOME"/externals/kyuubi-trino-engine/target/scala-$SCALA_VERSION/jars/*.jar "$DISTDIR/externals/engines/trino/"
 
 # Share the jars w/ server to reduce binary size
+# shellcheck disable=SC2045
 for jar in $(ls "$DISTDIR/jars/"); do
   if [[ -f "$DISTDIR/externals/engines/trino/$jar" ]]; then
     (cd $DISTDIR/externals/engines/trino; ln -snf "../../../jars/$jar" "$DISTDIR/externals/engines/trino/$jar")
@@ -280,6 +296,7 @@ cp "$KYUUBI_HOME/externals/kyuubi-jdbc-engine/target/kyuubi-jdbc-engine_${SCALA_
 cp -r "$KYUUBI_HOME"/externals/kyuubi-jdbc-engine/target/scala-$SCALA_VERSION/jars/*.jar "$DISTDIR/externals/engines/jdbc/"
 
 # Share the jars w/ server to reduce binary size
+# shellcheck disable=SC2045
 for jar in $(ls "$DISTDIR/jars/"); do
   if [[ -f "$DISTDIR/externals/engines/jdbc/$jar" ]]; then
     (cd $DISTDIR/externals/engines/jdbc; ln -snf "../../../jars/$jar" "$DISTDIR/externals/engines/jdbc/$jar")
@@ -296,6 +313,7 @@ fi
 
 # Copy Kyuubi Spark extension
 SPARK_EXTENSION_VERSIONS=('3-1' '3-2' '3-3')
+# shellcheck disable=SC2068
 for SPARK_EXTENSION_VERSION in ${SPARK_EXTENSION_VERSIONS[@]}; do
   if [[ -f $"$KYUUBI_HOME/extensions/spark/kyuubi-extension-spark-$SPARK_EXTENSION_VERSION/target/kyuubi-extension-spark-${SPARK_EXTENSION_VERSION}_${SCALA_VERSION}-${VERSION}.jar" ]]; then
     mkdir -p "$DISTDIR/extension"