diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a2062a..86363b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - support for mongo 8 (`install_mongo8`) - added `get_flavor_from_git_ref` `get_version_from_git_ref` `get_custom_from_git_ref` helpers to parse git ref names (tag or branch names). + - added `install_sona_scanner_cli` to install SonarQube scanner cli tool ### Removed diff --git a/kash.sh b/kash.sh index 5691ee5..0edc972 100644 --- a/kash.sh +++ b/kash.sh @@ -56,11 +56,11 @@ fi if [ -n "$CI_ID" ]; then CI=true - echo "Running in CI mode ($CI_ID)..." + echo "Running in CI mode ($CI_ID) ..." # Make sure we have the requirements to run kash functions set +e - command -v curl >/dev/null 2>&1 && command -v git >/dev/null 2>&1 && command -v sha256sum >/dev/null 2>&1 + command -v curl >/dev/null 2>&1 && command -v git >/dev/null 2>&1 && command -v sha256sum >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 RC=$? set -e @@ -68,13 +68,13 @@ if [ -n "$CI_ID" ]; then case "$OS_ID" in debian | ubuntu) if [ "$(id -u)" -eq 0 ]; then - apt-get update && apt-get --no-install-recommends --yes install sudo curl ca-certificates coreutils git + apt-get update && apt-get --no-install-recommends --yes install sudo curl ca-certificates coreutils git unzip else - sudo apt-get update && sudo apt-get --no-install-recommends --yes install curl ca-certificates coreutils git + sudo apt-get update && sudo apt-get --no-install-recommends --yes install curl ca-certificates coreutils git unzip fi ;; alpine) - apk update && apk add curl ca-certificates coreutils git + apk update && apk add curl ca-certificates coreutils git unzip ;; *) ;; @@ -105,6 +105,12 @@ if [ -d "$HOME/.nvm" ]; then . "$HOME/.nvm/nvm.sh" fi +# If sonar-scanner-cli is present, add it to PATH +# See install_sonar_scanner_cli +if [ -d "$HOME/.local/sonar-scanner" ]; then + export PATH=$PATH:$HOME/.local/sonar-scanner/bin +fi + # Define a TMP_DIR to operate with temp files if [ -n "${RUNNER_TEMP:-}" ]; then # RUNNER_TEMP is Github Action specific TMP_DIR="$RUNNER_TEMP" @@ -143,6 +149,9 @@ NODE22_VERSION=22.3.0 MONGODB7_VERSION=7.0.15 MONGODB8_VERSION=8.0.3 +# https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/scanners/sonarscanner/ +SONAR_SCANNER_CLI_VERSION=6.2.1.4610 + # Install yq in ~/.local/bin # Arg1: a writable folder where to write downloaded files install_yq() { @@ -366,6 +375,22 @@ install_mongo8() { cd ~- } +# Install sonar-scanner in ~/.local/sonar-scanner-cli +# Arg1: a writable folder where to write downloaded files +install_sonar_scanner_cli() { + local DL_ROOT=$1 + local DL_PATH="$DL_ROOT/sonarscannercli" + if [ ! -d "$DL_PATH" ]; then + mkdir -p "$DL_PATH" && cd "$DL_PATH" + curl -OLsS https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux-x64.zip + unzip sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux-x64.zip + cd ~- + fi + cd "$DL_PATH" + mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux-x64 ~/.local/sonar-scanner + cd ~- +} + # Install kubectl in ~/.local/bin # Expected args: # 1. a writable folder where to write downloaded files diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index ad0e6d6..08e7fb9 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -11,7 +11,7 @@ ROOT_DIR=$(dirname "$THIS_DIR") ### Github Actions init_github() { - install_reqs yq age sops nvm node16 node18 node20 cc_test_reporter + install_reqs yq age sops nvm node16 node18 node20 cc_test_reporter sonar_scanner_cli # mongo is not available for alpine hosts if [ "$OS_ID" != "alpine" ]; then