Skip to content

Commit e91e363

Browse files
committed
ci: added variable CACHEING_ENABLED
by default is false so the script can run on macos device like before in the ci is set to true Signed-off-by: IonutMuthi <[email protected]>
1 parent 51a57c1 commit e91e363

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ variables:
22
QT_FORMULAE: qt@5
33
REPO_SLUG: $(Build.Repository.Name)
44
CURRENT_COMMIT: $(Build.SourceVersion)
5+
CACHING_ENABLED: 'true'
56

67
trigger:
78
branches:
@@ -50,7 +51,7 @@ stages:
5051
path: '$(Pipeline.Workspace)/.homebrew-cache'
5152
cacheHitVar: 'HOMEBREW_CACHE'
5253
displayName: 'Cache Homebrew Downloads'
53-
condition: or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15'))
54+
condition: and(or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15')), eq(variables['CACHING_ENABLED'], 'true'))
5455

5556
# Git Repositories Cache
5657
- task: Cache@2
@@ -59,7 +60,7 @@ stages:
5960
path: '$(Pipeline.Workspace)/.git-cache'
6061
cacheHitVar: 'GIT_REPOS_CACHE'
6162
displayName: 'Cache Git Repositories'
62-
condition: or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15'))
63+
condition: and(or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15')), eq(variables['CACHING_ENABLED'], 'true'))
6364

6465
# Built Dependencies Cache
6566
- task: Cache@2
@@ -68,7 +69,7 @@ stages:
6869
path: '$(Build.Repository.LocalPath)/staging/dependencies'
6970
cacheHitVar: 'BUILT_DEPS_CACHE'
7071
displayName: 'Cache Built Dependencies'
71-
condition: or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15'))
72+
condition: and(or(eq(variables['vmImage'], 'macOS-14'), eq(variables['vmImage'], 'macOS-15')), eq(variables['CACHING_ENABLED'], 'true'))
7273

7374

7475
- script: ./ci/macOS/install_macos_deps.sh

ci/macOS/install_macos_deps.sh

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,46 @@ cleanup_old_caches() {
3737
}
3838

3939
setup_homebrew_cache() {
40-
echo "Setting up Homebrew cache..."
41-
mkdir -p "$HOMEBREW_CACHE_DIR"
42-
43-
export HOMEBREW_CACHE="$HOMEBREW_CACHE_DIR"
44-
#check if cache for homebrew exists
45-
if [ "${HOMEBREW_CACHE}" = "true" ]; then
46-
echo "Homebrew cache found, restoring cached packages"
47-
export HOMEBREW_NO_AUTO_UPDATE=1
48-
else
49-
echo "No Homebrew cache - downloading fresh packages"
50-
fi
40+
if [ "${CACHING_ENABLED}" = "true" ]; then
41+
echo "Setting up Homebrew cache..."
42+
mkdir -p "$HOMEBREW_CACHE_DIR"
43+
44+
export HOMEBREW_CACHE="$HOMEBREW_CACHE_DIR"
45+
#check if cache for homebrew exists
46+
if [ "${HOMEBREW_CACHE}" = "true" ]; then
47+
echo "Homebrew cache found, restoring cached packages"
48+
export HOMEBREW_NO_AUTO_UPDATE=1
49+
else
50+
echo "No Homebrew cache - downloading fresh packages"
51+
fi
52+
fi
5153
}
5254

5355
setup_git_cache() {
54-
echo "Setting up Git cache..."
55-
mkdir -p "$GIT_CACHE_DIR"
56-
57-
if [ "${GIT_REPOS_CACHE}" = "true" ]; then
58-
echo "Git repositories cache found, restoring cached repositories"
59-
# Validate cache isn't corrupted
60-
if [ -d "$GIT_CACHE_DIR" ] && [ "$(ls -A $GIT_CACHE_DIR 2>/dev/null)" ]; then
61-
export GIT_CACHE_ENABLED=true
62-
else
63-
echo "Git cache directory empty - clearing and rebuilding"
64-
rm -rf "$GIT_CACHE_DIR"
65-
mkdir -p "$GIT_CACHE_DIR"
66-
export GIT_CACHE_ENABLED=false
67-
fi
68-
else
69-
echo "No Git cache - cloning fresh repositories"
70-
export GIT_CACHE_ENABLED=false
71-
fi
56+
if [ "${CACHING_ENABLED}" = "true" ]; then
57+
echo "Setting up Git cache..."
58+
mkdir -p "$GIT_CACHE_DIR"
59+
60+
if [ "${GIT_REPOS_CACHE}" = "true" ]; then
61+
echo "Git repositories cache found, restoring cached repositories"
62+
# Validate cache isn't corrupted
63+
if [ -d "$GIT_CACHE_DIR" ] && [ "$(ls -A $GIT_CACHE_DIR 2>/dev/null)" ]; then
64+
export GIT_CACHE_ENABLED=true
65+
else
66+
echo "Git cache directory empty - clearing and rebuilding"
67+
rm -rf "$GIT_CACHE_DIR"
68+
mkdir -p "$GIT_CACHE_DIR"
69+
export GIT_CACHE_ENABLED=false
70+
fi
71+
else
72+
echo "No Git cache - cloning fresh repositories"
73+
export GIT_CACHE_ENABLED=false
74+
fi
75+
fi
7276
}
7377

7478
setup_dependencies_cache() {
75-
echo "Setting up dependencies cache..."
76-
77-
if [ "${BUILT_DEPS_CACHE}" = "true" ]; then
79+
if [ "${CACHING_ENABLED}" = "true" ] && [ "${BUILT_DEPS_CACHE}" = "true" ]; then
7880
echo "Built dependencies cache found, restoring cached dependencies"
7981
# Validate cache isn't corrupted
8082
if [ -d "$STAGING_AREA_DEPS" ] && [ "$(ls -A $STAGING_AREA_DEPS 2>/dev/null)" ]; then
@@ -116,7 +118,7 @@ install_packages() {
116118
major_version=$(echo "$macos_version" | cut -d '.' -f 1)
117119

118120
# Package installation based on cache status
119-
if [ "${HOMEBREW_CACHE}" = "true" ]; then
121+
if [ "${CACHING_ENABLED}" = "true" ] && [ "${HOMEBREW_CACHE}" = "true" ]; then
120122
echo "Installing packages with cache optimization (skipping update/upgrade)..."
121123
export HOMEBREW_NO_AUTO_UPDATE=1
122124
else
@@ -164,7 +166,7 @@ clone() {
164166
mkdir -p $STAGING_AREA
165167
pushd $STAGING_AREA
166168

167-
if [ "$GIT_CACHE_ENABLED" = "true" ]; then
169+
if [ "${CACHING_ENABLED}" = "true" ] && [ "$GIT_CACHE_ENABLED" = "true" ]; then
168170
echo "Using cached repositories..."
169171

170172
# If cache directory has content, use it

0 commit comments

Comments
 (0)