From cd4b14ef79224694958b10d6558e4227e8f7702e Mon Sep 17 00:00:00 2001 From: Ricardo Zanini Date: Wed, 10 Apr 2024 16:47:40 -0300 Subject: [PATCH] Fix #1755 - Fix SpellSheck runner and warning in script files Signed-off-by: Ricardo Zanini --- .github/workflows/kogito-images-pr-check.yml | 23 +++++++++++-------- .../added/configure-custom-truststore.sh | 3 ++- .../kogito-launch-scripts/added/configure.sh | 2 ++ modules/kogito-maven/common/configure | 2 +- .../common/build/added/cleanup_project.sh | 2 +- .../common/scripts/added/add-extension.sh | 3 ++- .../common/scripts/added/build-app.sh | 3 ++- .../common/scripts/added/create-app.sh | 3 ++- .../common/scripts/added/jvm-settings.sh | 7 ++++-- .../runtime/common/added/run-app-devmode.sh | 3 ++- 10 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/workflows/kogito-images-pr-check.yml b/.github/workflows/kogito-images-pr-check.yml index 98a5199ba..31331b404 100644 --- a/.github/workflows/kogito-images-pr-check.yml +++ b/.github/workflows/kogito-images-pr-check.yml @@ -10,11 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install xmllint run: | - sudo apt-get update - sudo apt-get install libxml2-utils --fix-missing + sudo apt-get update &&\ + sudo apt-get -y install --no-install-recommends --fix-missing \ + libxml2-utils - name: Cache bats binaries uses: actions/cache@v1 with: @@ -25,7 +26,7 @@ jobs: - name: run bats run: | ./scripts/run-bats.sh - + validate_kogito_imagestream: concurrency: group: ${{ github.repository.name }}_validate_kogito_imagestream-${{ github.head_ref }} @@ -33,14 +34,14 @@ jobs: name: Validate Kogito imagestreams runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download openshift-validator-tool run: | wget https://github.com/jboss-container-images/jboss-kie-modules/raw/main/tools/openshift-template-validator/openshift-template-validator-linux-amd64 - name: Add execution permission to openshift-validator-tool run: | chmod +x openshift-template-validator-linux-amd64 - mv openshift-template-validator-linux-amd64 ${HOME} + mv openshift-template-validator-linux-amd64 ${HOME} - name: validate kogito imagestream run: | ${HOME}/openshift-template-validator-linux-amd64 validate -f kogito-imagestream.yaml @@ -53,11 +54,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Shellcheck - run: sudo apt install shellcheck + run: | + sudo apt-get update &&\ + sudo apt-get -y install --no-install-recommends \ + shellcheck - name: Check configure scripts run: | # Ignore SC2034 since we have many var which are unused in the script but can be used while deployment at runtime by setting env. For eg: ${KOGITO_QUARKUS_JVM_PROPS} # Ignore SC1090 since the source files in our case didn't need to be checked - shellcheck -e SC2034 -e SC1090 modules/**/configure modules/**/*.sh \ No newline at end of file + shopt -s globstar nullglob + shellcheck -e SC2034 -e SC1090 -S warning modules/**/configure modules/**/*.sh diff --git a/modules/kogito-custom-truststore/added/configure-custom-truststore.sh b/modules/kogito-custom-truststore/added/configure-custom-truststore.sh index f3c180f88..3438a0d4e 100755 --- a/modules/kogito-custom-truststore/added/configure-custom-truststore.sh +++ b/modules/kogito-custom-truststore/added/configure-custom-truststore.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -20,6 +20,7 @@ set -e # imports +# shellcheck source=/dev/null source "${KOGITO_HOME}"/launch/logging.sh function prepareEnv() { diff --git a/modules/kogito-launch-scripts/added/configure.sh b/modules/kogito-launch-scripts/added/configure.sh index 638e9bbcf..8244ba32f 100644 --- a/modules/kogito-launch-scripts/added/configure.sh +++ b/modules/kogito-launch-scripts/added/configure.sh @@ -84,6 +84,7 @@ function prepareModule() { # $1 - module file # $2 - function name function executeModule() { + # shellcheck source=/dev/null source "$1" if [ -n "$(type -t "$2")" ]; then eval "$2" @@ -93,6 +94,7 @@ function executeModule() { # Run through the list of scripts, executing the specified function for each. # $1 - function name function executeModules() { + # shellcheck disable=SC2048 for module in ${CONFIGURE_SCRIPTS[*]}; do prepareModule executeModule "${module}" "${1}" diff --git a/modules/kogito-maven/common/configure b/modules/kogito-maven/common/configure index 7f5306045..e28dccbbd 100755 --- a/modules/kogito-maven/common/configure +++ b/modules/kogito-maven/common/configure @@ -25,7 +25,7 @@ SCRIPT_DIR=$(dirname "${0}") mvn_install_dir="/usr/share/maven" # Verify if mvn is installed -if [ ! -d ${mvn_install_dir} ] && ! command -v mvn &> /dev/null ; +if [ ! -d ${mvn_install_dir} ] && ! command -v mvn > /dev/null 2>&1 ; then echo "---> Maven not found, downloading and installing it" tar xzf "${SOURCES_DIR}"/apache-maven-"${MAVEN_VERSION}"-bin.tar.gz -C /usr/share diff --git a/modules/kogito-swf/common/build/added/cleanup_project.sh b/modules/kogito-swf/common/build/added/cleanup_project.sh index adfac1d52..69e0a61e9 100755 --- a/modules/kogito-swf/common/build/added/cleanup_project.sh +++ b/modules/kogito-swf/common/build/added/cleanup_project.sh @@ -35,7 +35,7 @@ rm -rfv "${PROJECT_ARTIFACT_ID}"/*.bak echo 'Clean Maven useless files' find "${KOGITO_HOME}"/.m2/repository -name _remote.repositories -type f -delete find "${KOGITO_HOME}"/.m2/repository -name _maven.repositories -type f -delete -find "${KOGITO_HOME}"/.m2/repository -name *.lastUpdated -type f -delete +find "${KOGITO_HOME}"/.m2/repository -name '*.lastUpdated' -type f -delete # Remove files that include build timestamps to have reproducible images find "${KOGITO_HOME}"/.m2/ -name resolver-status.properties -delete diff --git a/modules/kogito-swf/common/scripts/added/add-extension.sh b/modules/kogito-swf/common/scripts/added/add-extension.sh index 82a023ace..6dc158d2a 100755 --- a/modules/kogito-swf/common/scripts/added/add-extension.sh +++ b/modules/kogito-swf/common/scripts/added/add-extension.sh @@ -20,12 +20,13 @@ set -e -script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # extensions to be added, comma separated. extensions="$1" # parameter passed which will trigger or not the jvm/maven configuration. ignore_jvm_settings=${2:-false} +# shellcheck source=/dev/null source "${script_dir_path}"/logging.sh if [ "${SCRIPT_DEBUG}" = "true" ] ; then diff --git a/modules/kogito-swf/common/scripts/added/build-app.sh b/modules/kogito-swf/common/scripts/added/build-app.sh index c85927c4b..671d6e09b 100755 --- a/modules/kogito-swf/common/scripts/added/build-app.sh +++ b/modules/kogito-swf/common/scripts/added/build-app.sh @@ -20,12 +20,13 @@ set -e -script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" resources_path="$1" if [ -n "${resources_path}" ]; then resources_path="$(realpath "${resources_path}")" fi +# shellcheck source=/dev/null source "${script_dir_path}"/logging.sh if [ "${SCRIPT_DEBUG}" = "true" ] ; then diff --git a/modules/kogito-swf/common/scripts/added/create-app.sh b/modules/kogito-swf/common/scripts/added/create-app.sh index f965d9b78..ac8a5ebe6 100755 --- a/modules/kogito-swf/common/scripts/added/create-app.sh +++ b/modules/kogito-swf/common/scripts/added/create-app.sh @@ -20,8 +20,9 @@ set -e -script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null source "${script_dir_path}"/logging.sh if [ "${SCRIPT_DEBUG}" = "true" ] ; then diff --git a/modules/kogito-swf/common/scripts/added/jvm-settings.sh b/modules/kogito-swf/common/scripts/added/jvm-settings.sh index b8a1fce95..168e53216 100755 --- a/modules/kogito-swf/common/scripts/added/jvm-settings.sh +++ b/modules/kogito-swf/common/scripts/added/jvm-settings.sh @@ -30,14 +30,17 @@ set -e +# shellcheck source=/dev/null source "${KOGITO_HOME}"/launch/logging.sh log_info "--> checking if .mvn/jvm.config exists." if [ -f ".mvn/jvm.config" ]; then log_info "---> .mvn/jvm.config exists." - export JAVA_OPTIONS=$(cat .mvn/jvm.config) + JAVA_OPTIONS=$(cat .mvn/jvm.config) + export JAVA_OPTIONS else log_info "---> .mvn/jvm.config does not exists, memory will be calculated based on container limits." fi -export MAVEN_OPTS="${JAVA_OPTIONS} $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) $(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/debug-options)" \ No newline at end of file +MAVEN_OPTS="${JAVA_OPTIONS} $("${JBOSS_CONTAINER_JAVA_JVM_MODULE}"/java-default-options) $("${JBOSS_CONTAINER_JAVA_JVM_MODULE}"/debug-options)" +export MAVEN_OPTS \ No newline at end of file diff --git a/modules/kogito-swf/devmode/runtime/common/added/run-app-devmode.sh b/modules/kogito-swf/devmode/runtime/common/added/run-app-devmode.sh index ba8edc658..6f5ec3610 100755 --- a/modules/kogito-swf/devmode/runtime/common/added/run-app-devmode.sh +++ b/modules/kogito-swf/devmode/runtime/common/added/run-app-devmode.sh @@ -20,8 +20,9 @@ set -e -script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" +script_dir_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=/dev/null source "${script_dir_path}"/logging.sh if [ "${SCRIPT_DEBUG}" = "true" ] ; then