From fbd53d71a9ccfe9a52b7370cd8071e791c30e42e Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 09:03:45 -0600 Subject: [PATCH 1/9] Per #2379, move rgb2ctable.py into the python utility scripts directory for better organization and to enable convenient SonarQube scanning. --- .../NCL_colortables => scripts/python/utility}/rgb2ctable.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {data/colortables/NCL_colortables => scripts/python/utility}/rgb2ctable.py (100%) diff --git a/data/colortables/NCL_colortables/rgb2ctable.py b/scripts/python/utility/rgb2ctable.py similarity index 100% rename from data/colortables/NCL_colortables/rgb2ctable.py rename to scripts/python/utility/rgb2ctable.py From 732dbb062b02c1240b07fb275f0b9238b97f6950 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 09:05:46 -0600 Subject: [PATCH 2/9] Per #2379, remove point.py from the vx_python3_utils directory which cleary was inadvertenlty added during development 4 years ago. As far as I can tell it isn't being called by any other code and doesn't belong in the repository. Note that scripts/python/met/point.py has the same name but is entirely different. --- src/libcode/vx_python3_utils/point.py | 39 --------------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/libcode/vx_python3_utils/point.py diff --git a/src/libcode/vx_python3_utils/point.py b/src/libcode/vx_python3_utils/point.py deleted file mode 100644 index 699aa46e51..0000000000 --- a/src/libcode/vx_python3_utils/point.py +++ /dev/null @@ -1,39 +0,0 @@ - - -############################################################### - - -import sys - - -############################################################### - -print ('============= start point.py ===========') - -print (sys.argv) - - -############################################################### - - -point_data = [[ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 837.0, 1618, 'NA', 1618 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 837.0, 1618, 'NA', 273.05 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 17, 837.0, 1618, 'NA', 271.85 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 52, 837.0, 1618, 'NA', 92 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 53, 837.0, 1618, 'NA', 0.00417 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 826.0, 1724, 'NA', 1724 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 826.0, 1724, 'NA', 274.55 ]] - - -############################################################### - - -print (point_data) - - -print ('============= end point.py ===========') - - -############################################################### - - From d15533159b9324c5848ddaf4ad7b923fa719289e Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 09:44:08 -0600 Subject: [PATCH 3/9] Per #2379, update the GHA SonarQube scan to do a single one with Python and C++ combined. The nightly build script is still doing 2 separate scans for now. If this all works well, they could also be combined into a single one. --- .github/jobs/build_sonarqube_image.sh | 1 - .github/workflows/sonarqube.yml | 17 ++----- internal/scripts/docker/Dockerfile.sonarqube | 1 - .../scripts/docker/build_met_sonarqube.sh | 45 ++++++------------- internal/scripts/sonarqube/run_sonarqube.sh | 26 +++++------ .../sonarqube/sonar-project.properties | 16 +++---- 6 files changed, 35 insertions(+), 71 deletions(-) diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh index 9cdeea3395..92d0b27314 100755 --- a/.github/jobs/build_sonarqube_image.sh +++ b/.github/jobs/build_sonarqube_image.sh @@ -43,4 +43,3 @@ fi id=$(docker create ${DOCKERHUB_TAG}) time_command docker cp $id:/met/.scannerwork /tmp/met_scannerwork docker rm -v $id - diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index 36c2ccc02d..de7d1a9200 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -69,21 +69,11 @@ jobs: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: SonarQube Python Quality Gate check - id: sonarqube-python-quality-gate-check + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master with: - scanMetadataReportFile: /tmp/met_scannerwork/python-report-task.txt - timeout-minutes: 5 - env: - SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - name: SonarQube CXX Quality Gate check - id: sonarqube-cxx-quality-gate-check - uses: sonarsource/sonarqube-quality-gate-action@master - with: - scanMetadataReportFile: /tmp/met_scannerwork/cxx-report-task.txt + scanMetadataReportFile: /tmp/met_scannerwork/report-task.txt timeout-minutes: 5 env: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} @@ -100,4 +90,3 @@ jobs: name: logs_sonarqube path: ${{ runner.workspace }}/logs if-no-files-found: ignore - diff --git a/internal/scripts/docker/Dockerfile.sonarqube b/internal/scripts/docker/Dockerfile.sonarqube index 156fa14bf7..75dc3c952c 100644 --- a/internal/scripts/docker/Dockerfile.sonarqube +++ b/internal/scripts/docker/Dockerfile.sonarqube @@ -92,4 +92,3 @@ RUN if [ ! -e "${MET_REPO_DIR}/configure.ac" ]; then \ RUN cd ${MET_REPO_DIR} \ && internal/scripts/docker/build_met_sonarqube.sh - diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index f726d8b3b9..b9468da785 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -81,48 +81,29 @@ if [ -z ${SONARQUBE_OUT_DIR} ]; then export SONARQUBE_OUT_DIR=bw-outputs fi +# Define the version string +SONAR_PROJECT_VERSION=$(cat docs/version | cut -d'=' -f2 | tr -d '" ') + # Store the full path to the scripts directory SONAR_PROPERTIES_DIR=internal/scripts/sonarqube SONAR_PROPERTIES=sonar-project.properties -# Copy sonar-project.properties for Python code +# Configure the sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ +sed -e "s|SONAR_PROJECT_KEY|METcalcpy_NB|" \ + -e "s|SONAR_PROJECT_NAME|METcalcpy Nightly Build|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET-GHA-Python|" \ - -e "s|SONAR_PROJECT_NAME|MET GHA Python|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ - -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ - $SONAR_PROPERTIES_DIR/python.sonar-project.properties > $SONAR_PROPERTIES + $SCRIPT_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # The source and reference branches must differ to define new code if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES fi - -# Run SonarQube scan for Python code -time_command $SONAR_SCANNER - -# Copy the Python scan report-task.txt file -mkdir -p /met/.scannerwork -cp .scannerwork/report-task.txt /met/.scannerwork/python-report-task.txt - -# Copy sonar-project.properties for C/C++ code -[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET-GHA-CXX|" \ - -e "s|SONAR_PROJECT_NAME|MET GHA CXX|" \ - -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ - -e "s|SONAR_REFERENCE_BRANCH|$SONAR_REFERENCE_BRANCH|" \ - $SONAR_PROPERTIES_DIR/sonar-project.properties > $SONAR_PROPERTIES -# The source and reference branches must differ to define new code -if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then - echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES -fi - -# Run the configure script +# Run the MET configure script time_command ./configure \ BUFRLIB_NAME=${BUFRLIB_NAME} \ GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \ @@ -136,11 +117,11 @@ time_command make clean # Run SonarQube make time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make -# Run SonarQube scan for C/C++ code +# Run SonarQube scan time_command $SONAR_SCANNER -# Copy the C/C++ scan report-task.txt file +# Copy the scan report-task.txt file mkdir -p /met/.scannerwork -cp .scannerwork/report-task.txt /met/.scannerwork/cxx-report-task.txt +cp .scannerwork/report-task.txt /met/.scannerwork/report-task.txt [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 917158b461..4367c49f1d 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -90,7 +90,6 @@ function run_command() { return ${STATUS} } - # Store the full path to the scripts directory SCRIPT_DIR=`dirname $0` if [[ ${0:0:1} != "/" ]]; then SCRIPT_DIR=$(pwd)/${SCRIPT_DIR}; fi @@ -113,8 +112,8 @@ export MET_DEVELOPMENT=true # Run the configure script run_command "./configure --prefix=`pwd` --enable-all" -# Set the build id -#BUILD_ID="MET-${1}" +# Define the version string +SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\'\" ") SONAR_PROPERTIES=sonar-project.properties @@ -125,11 +124,12 @@ if [ -z "$SONAR_TOKEN" ]; then echo " == ERROR == SONAR_TOKEN is not defined" exit 1 else - sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ + sed -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ -e "s|SONAR_PROJECT_NAME|MET python Nightly Build|" \ - -e "s|SONAR_BRANCH_NAME|develop|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_BRANCH_NAME|${1}|" \ $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube scan for Python code @@ -137,11 +137,12 @@ else # Copy sonar-project.properties for C/C++ code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ + sed -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ - -e "s|SONAR_BRANCH_NAME|develop|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_BRANCH_NAME|${1}|" \ $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES # Run SonarQube clean @@ -155,6 +156,3 @@ else [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES fi - -# Run SonarQube report generator to make a PDF file -#TODAY=`date +%Y%m%d` diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index c09f1d31b1..215749e75b 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -1,17 +1,15 @@ +# Project and source code settings sonar.projectKey=SONAR_PROJECT_KEY sonar.projectName=SONAR_PROJECT_NAME -sonar.projectVersion=1.0 - -sonar.sources=src +sonar.projectVersion=SONAR_PROJECT_VERSION +sonar.branch.name=SONAR_BRANCH_NAME +sonar.sources=src,scripts/python,data/wrappers +sonar.python.version=3.6.3 +sonar.sourceEncoding=UTF-8 # The build-wrapper output dir sonar.cfamily.build-wrapper-output=bw-outputs -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server +# SonarQube server sonar.host.url=SONAR_HOST_URL - sonar.token=SONAR_TOKEN -sonar.branch.name=SONAR_BRANCH_NAME From 68c600b61165d49354a868a3d4bb9e7a36211e2e Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 10:09:03 -0600 Subject: [PATCH 4/9] Per #2379, eliminate MET_CONFIG_OPTIONS from the SonarQube workflow since it doesn't need to be and probably shouldn't be configurable. --- .github/jobs/build_sonarqube_image.sh | 3 +-- .github/workflows/sonarqube.yml | 3 +-- internal/scripts/docker/build_met_sonarqube.sh | 14 ++++---------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh index 92d0b27314..abbf7f2404 100755 --- a/.github/jobs/build_sonarqube_image.sh +++ b/.github/jobs/build_sonarqube_image.sh @@ -28,7 +28,6 @@ time_command docker build -t ${DOCKERHUB_TAG} \ --build-arg MET_BASE_REPO \ --build-arg MET_BASE_TAG \ --build-arg SOURCE_BRANCH \ - --build-arg MET_CONFIG_OPTS \ --build-arg SONAR_SCANNER_VERSION \ --build-arg SONAR_HOST_URL \ --build-arg SONAR_TOKEN \ @@ -41,5 +40,5 @@ fi # Copy the .scannerwork directory from the image id=$(docker create ${DOCKERHUB_TAG}) -time_command docker cp $id:/met/.scannerwork /tmp/met_scannerwork +time_command docker cp $id:/met/.scannerwork /tmp/scannerwork docker rm -v $id diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml index de7d1a9200..6a6627fb69 100644 --- a/.github/workflows/sonarqube.yml +++ b/.github/workflows/sonarqube.yml @@ -64,7 +64,6 @@ jobs: MET_BASE_TAG: v3.2 SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }} WD_REFERENCE_BRANCH: ${{ github.event.inputs.reference_branch }} - MET_CONFIG_OPTS: '--enable-all' SONAR_SCANNER_VERSION: 5.0.1.3006 SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} @@ -73,7 +72,7 @@ jobs: id: sonarqube-quality-gate-check uses: sonarsource/sonarqube-quality-gate-action@master with: - scanMetadataReportFile: /tmp/met_scannerwork/report-task.txt + scanMetadataReportFile: /tmp/scannerwork/report-task.txt timeout-minutes: 5 env: SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index b9468da785..0c37645736 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -5,7 +5,7 @@ # # This build_met_sonarqube.sh script must be run from the top-level # directory of the MET repository to be analyzed. It runs SonarQube to -# scan both the Python and C/C++ MET source code. +# scan the MET source code. # # Usage: internal/scripts/docker/build_met_sonarqube.sh # @@ -48,12 +48,6 @@ if [ -z ${SONAR_REFERENCE_BRANCH+x} ]; then exit 1 fi -# Check whether MET_CONFIG_OPTS is defined -if [ -z ${MET_CONFIG_OPTS+x} ]; then - MET_CONFIG_OPTS='--enable-all' - echo "Setting MET_CONFIG_OPTS=${MET_CONFIG_OPTS} to scan all available options." -fi - # Locate the wrapper WRAPPER_NAME=build-wrapper-linux-x86-64 SONAR_WRAPPER=$(which $WRAPPER_NAME 2> /dev/null) @@ -90,8 +84,8 @@ SONAR_PROPERTIES=sonar-project.properties # Configure the sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -sed -e "s|SONAR_PROJECT_KEY|METcalcpy_NB|" \ - -e "s|SONAR_PROJECT_NAME|METcalcpy Nightly Build|" \ +sed -e "s|SONAR_PROJECT_KEY|MET-GHA|" \ + -e "s|SONAR_PROJECT_NAME|MET GHA|" \ -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ @@ -107,7 +101,7 @@ fi time_command ./configure \ BUFRLIB_NAME=${BUFRLIB_NAME} \ GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \ - ${MET_CONFIG_OPTS} \ + --enable-all \ CPPFLAGS="-I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/cairo" \ LIBS="-ltirpc" From 9812c1b3541b1f1952d54dadefbe48752fb51b52 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 10:24:33 -0600 Subject: [PATCH 5/9] Per #2379, trying to copy report-task.txt out of the image --- .github/jobs/build_sonarqube_image.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh index abbf7f2404..55d558624b 100755 --- a/.github/jobs/build_sonarqube_image.sh +++ b/.github/jobs/build_sonarqube_image.sh @@ -40,5 +40,6 @@ fi # Copy the .scannerwork directory from the image id=$(docker create ${DOCKERHUB_TAG}) -time_command docker cp $id:/met/.scannerwork /tmp/scannerwork +time_command mkdir -p /tmp/scannerwork +time_command docker cp $id:/met/.scannerwork/report-task.txt /tmp/scannerwork/report-task.txt docker rm -v $id From d6540969edc4a5bd2da90ec8a5d48d24a4edf7be Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 13:18:57 -0600 Subject: [PATCH 6/9] Per #2379, update build_met_sonarqube.sh to check the scan return status --- internal/scripts/docker/build_met_sonarqube.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index 0c37645736..99a6ff1515 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -113,6 +113,13 @@ time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make # Run SonarQube scan time_command $SONAR_SCANNER +status = $? + +# Check return status +if [ $status -ne 0 ]; then + echo "ERROR: ${0} -> the SonarQube scan failed with status ${status}!" + exit ${status} +fi # Copy the scan report-task.txt file mkdir -p /met/.scannerwork From a314cf609cbc465f421c7dc0565a75bb5d9d0178 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 13:36:33 -0600 Subject: [PATCH 7/9] Per #2379, fix bash assignment syntax --- internal/scripts/docker/build_met_sonarqube.sh | 6 +++--- internal/scripts/sonarqube/run_sonarqube.sh | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index 99a6ff1515..723e7a3a3d 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -113,11 +113,11 @@ time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make # Run SonarQube scan time_command $SONAR_SCANNER -status = $? +status=$? # Check return status -if [ $status -ne 0 ]; then - echo "ERROR: ${0} -> the SonarQube scan failed with status ${status}!" +if [[ $status -ne 0 ]]; then + echo "ERROR: ${0} -> the SonarQube scan returned with non-zero status (${status})!" exit ${status} fi diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 4367c49f1d..f29ccb24cd 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -24,10 +24,10 @@ GIT_REPO="https://github.com/dtcenter/${GIT_REPO_NAME}" function usage { - echo - echo "USAGE: $(basename $0) name" - echo " where \"name\" specifies a branch, tag, or hash." - echo + echo + echo "USAGE: $(basename $0) name" + echo " where \"name\" specifies a branch, tag, or hash." + echo } # Check for arguments From 82afbfb934bcf7582a4b3dbb60d1f09b522af3ea Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 13:50:22 -0600 Subject: [PATCH 8/9] Per #2379, remove unused SCRIPT_DIR envvar --- internal/scripts/docker/build_met_sonarqube.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh index 723e7a3a3d..45e1d10fc5 100755 --- a/internal/scripts/docker/build_met_sonarqube.sh +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -90,7 +90,7 @@ sed -e "s|SONAR_PROJECT_KEY|MET-GHA|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ - $SCRIPT_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES + $SONAR_PROPERTIES_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # The source and reference branches must differ to define new code if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then From de2d27e5e855a30d1d0a4859841bb2c726fcd74c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Sat, 6 Apr 2024 14:37:58 -0600 Subject: [PATCH 9/9] Per #2379, switch to a single SonarQube scan for MET's nightly build as well --- .../sonarqube/python.sonar-project.properties | 17 -------------- internal/scripts/sonarqube/run_sonarqube.sh | 22 +++++-------------- 2 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 internal/scripts/sonarqube/python.sonar-project.properties diff --git a/internal/scripts/sonarqube/python.sonar-project.properties b/internal/scripts/sonarqube/python.sonar-project.properties deleted file mode 100644 index 71b6b36b71..0000000000 --- a/internal/scripts/sonarqube/python.sonar-project.properties +++ /dev/null @@ -1,17 +0,0 @@ -sonar.projectKey=SONAR_PROJECT_KEY -sonar.projectName=SONAR_PROJECT_NAME -sonar.projectVersion=1.0 - -sonar.sources=scripts/python,data/wrappers -sonar.python.version=3.6.3 - -# The build-wrapper output dir - -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server -sonar.host.url=SONAR_HOST_URL - -sonar.token=SONAR_TOKEN -sonar.branch.name=SONAR_BRANCH_NAME diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index f29ccb24cd..1a57b0b726 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -117,41 +117,29 @@ SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\' SONAR_PROPERTIES=sonar-project.properties -# Copy sonar-project.properties for Python code +# Configure sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES [ -z "$SONAR_HOST_URL" ] && SONAR_HOST_URL="http://localhost:9000" if [ -z "$SONAR_TOKEN" ]; then echo " == ERROR == SONAR_TOKEN is not defined" exit 1 else - sed -e "s|SONAR_PROJECT_KEY|MET_python_NB|" \ - -e "s|SONAR_PROJECT_NAME|MET python Nightly Build|" \ - -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ - -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ - -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ - -e "s|SONAR_BRANCH_NAME|${1}|" \ - $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES - - # Run SonarQube scan for Python code - run_command "$SONAR_SCANNER" - - # Copy sonar-project.properties for C/C++ code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_PROJECT_KEY|MET_develop_NB|" \ + sed -e "s|SONAR_PROJECT_KEY|MET_NB|" \ -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ -e "s|SONAR_BRANCH_NAME|${1}|" \ - $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES + $SCRIPT_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # Run SonarQube clean run_command "make clean" - # Run SonarQube make + # Run SonarQube build wrapper run_command "$SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make" - # Run SonarQube scan for C/C++ code + # Run SonarQube scan run_command "$SONAR_SCANNER" [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES