Skip to content

Commit f6d0959

Browse files
BUILD-7780: Use monthly cache for orchestrator
Signed-off-by: Jayadeep Kinavoor Madam <[email protected]>
1 parent 80ca7c8 commit f6d0959

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.cirrus.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,27 @@ windows_16_cpu_32G_template: &WINDOWS_16_CPU_32G
6363
preemptible: false
6464
use_ssd: true
6565

66+
orchestrator_cache_definition: &ORCHESTRATOR_CACHE_DEFINITION
67+
set_orchestrator_home_script: |
68+
# Check if SQ_VERSION exists and create an intermediary variable
69+
if [ -n "$SQ_VERSION" ]; then
70+
FOLDER="${SQ_VERSION}"
71+
else
72+
FOLDER="DEFAULT"
73+
fi
74+
75+
CURRENT_MONTH=$(date +"%B")
76+
echo "CURRENT_MONTH=${CURRENT_MONTH}" >> $CIRRUS_ENV
77+
echo "ORCHESTRATOR_HOME=${CIRRUS_WORKING_DIR}/orchestrator/${FOLDER}/${CURRENT_MONTH}" >> $CIRRUS_ENV
78+
echo "FOLDER=${FOLDER}" >> $CIRRUS_ENV
79+
mkdir_orchestrator_home_script: |
80+
echo "Create dir ${ORCHESTRATOR_HOME} if needed"
81+
mkdir -p ${ORCHESTRATOR_HOME}
82+
orchestrator_cache:
83+
folder: ${ORCHESTRATOR_HOME}
84+
fingerprint_script: echo ${FOLDER}-${CURRENT_MONTH}
85+
reupload_on_changes: "true"
86+
6687
setup_gradle_cache_template: &SETUP_GRADLE_CACHE
6788
gradle_cache:
6889
folder: .gradle/caches
@@ -78,6 +99,7 @@ cleanup_gradle_cache_script_template: &CLEANUP_GRADLE_CACHE_SCRIPT
7899

79100
gradle_its_template: &GRADLE_ITS_TEMPLATE
80101
<<: *SETUP_GRADLE_CACHE
102+
<<: *ORCHESTRATOR_CACHE_DEFINITION
81103
run_its_script:
82104
- |
83105
if [ -n "${GIT_SUB_MODULE}" ]; then
@@ -89,6 +111,7 @@ gradle_its_template: &GRADLE_ITS_TEMPLATE
89111
"-DbuildNumber=$BUILD_NUMBER"
90112
--info --console plain --no-daemon --build-cache
91113
<<: *CLEANUP_GRADLE_CACHE_SCRIPT
114+
cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh
92115

93116
only_if_sonarsource_qa_template: &ONLY_IF_SONARSOURCE_QA
94117
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*" || $CIRRUS_BRANCH =~ "dogfood-on-.*")
@@ -198,6 +221,7 @@ qa_ruling_kotlin_compiler_task:
198221
GIT_SUB_MODULE: "its/sources"
199222
<<: *LINUX_6_CPU_12G_JAVA_17
200223
<<: *SETUP_GRADLE_CACHE
224+
<<: *ORCHESTRATOR_CACHE_DEFINITION
201225
run_its_script:
202226
- |
203227
if [ -n "${GIT_SUB_MODULE}" ]; then
@@ -209,6 +233,7 @@ qa_ruling_kotlin_compiler_task:
209233
"-DbuildNumber=$BUILD_NUMBER"
210234
--info --console plain --no-daemon --build-cache
211235
<<: *CLEANUP_GRADLE_CACHE_SCRIPT
236+
cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh
212237

213238
build_win_task:
214239
<<: *QA_TASK_FILTER

.cirrus/clean-orchestrator-cache.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cd "$ORCHESTRATOR_HOME" || exit 1
5+
6+
# Find all sonar-application-* JAR files, sort them by version, and list them
7+
files=$(find . -name "sonar-application-*" | sort --version-sort --field-separator=- --key=3 --reverse)
8+
9+
# Print the files that will be kept (the latest one)
10+
echo "File that will not be deleted:"
11+
echo "$files" | head -n 1
12+
13+
# Get the files that will be deleted (all except the latest one)
14+
files_to_delete=$(echo "$files" | tail -n +2)
15+
16+
echo ""
17+
if [ -z "$files_to_delete" ]; then
18+
echo "No files will be deleted."
19+
else
20+
echo "Files that will be deleted:"
21+
echo "$files_to_delete"
22+
23+
# Delete obsolete sonar-application files
24+
echo "$files_to_delete" | xargs -I {} sh -c 'rm -f "{}" && rmdir "$(dirname "{}")" 2>/dev/null || true'
25+
fi

0 commit comments

Comments
 (0)