From 16c9750ceb000de03e3d3e8286b43bd015db83d4 Mon Sep 17 00:00:00 2001 From: Sebastian Zumbrunn Date: Tue, 17 Dec 2024 12:02:14 +0100 Subject: [PATCH] SONARPY-2471: Orchestrator cache should be cleaned up when using the DEV version (#2254) --- .cirrus.yml | 7 +++++-- .cirrus/clean-orchestrator-cache.sh | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .cirrus/clean-orchestrator-cache.sh diff --git a/.cirrus.yml b/.cirrus.yml index 1cd33c6f04..71bc79379f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -163,7 +163,7 @@ plugin_qa_task: <<: *ONLY_SONARSOURCE_QA eks_container: <<: *QA_CONTAINER_DEFINITION - cpu: 3 + cpu: 6 memory: 8G env: CIRRUS_CLONE_DEPTH: 10 @@ -178,8 +178,10 @@ plugin_qa_task: - source cirrus-env QA - source set_maven_build_version $BUILD_NUMBER - cd its/plugin - - mvn verify -Dsonar.runtimeVersion=${SQ_VERSION} -Dmaven.test.redirectTestOutputToFile=false -B -e -V + - mvn verify -Dsonar.runtimeVersion=${SQ_VERSION} -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Djunit.jupiter.execution.parallel.config.dynamic.factor=1 cleanup_before_cache_script: cleanup_maven_repository + cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh + ruling_task: depends_on: @@ -225,6 +227,7 @@ pr_analysis_qa_task: - cd its/ruling - mvn verify -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dtest=PythonPrAnalysisTest cleanup_before_cache_script: cleanup_maven_repository + cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh promote_task: depends_on: diff --git a/.cirrus/clean-orchestrator-cache.sh b/.cirrus/clean-orchestrator-cache.sh new file mode 100644 index 0000000000..5d9c4885d7 --- /dev/null +++ b/.cirrus/clean-orchestrator-cache.sh @@ -0,0 +1,25 @@ +#!/bin/bash +cd "$ORCHESTRATOR_HOME" || exit 1 + +# Find all sonar-application-* JAR files, sort them by version, and list them +files=$(find . -name "sonar-application-*" | sort --version-sort --field-separator=- --key=3 --reverse) + +# Print the files that will be kept (the latest one) +echo "Files that won't be deleted:" +echo "$files" | head -n 1 + +# Get the files that will be deleted (all except the latest one) +files_to_delete=$(echo "$files" | tail -n +2) + +echo "" +# Check if there are files to delete +if [ -z "$files_to_delete" ]; then + echo "No files will be deleted." +else + # Print the files that will be deleted + echo "Files that will be deleted:" + echo "$files_to_delete" + + # Delete the files that will be deleted + echo "$files_to_delete" | xargs -I {} sh -c 'rm -f "{}" && rmdir "$(dirname "{}")" 2>/dev/null || true' +fi