ci: use host mapping volumes to improve the ccache hits

This commit is contained in:
Fu Hanxi 2024-03-04 14:43:54 +01:00
parent 4f3cd0deb9
commit 7928f46f2d
2 changed files with 20 additions and 1 deletions

View File

@ -89,6 +89,14 @@ variables:
IDF_CI_BUILD: 1
# ccache settings
# some settings need to set in .gitlab-ci.yml as it takes effect while start-up the job
# https://ccache.dev/manual/latest.html#_configuring_ccache
# host mapping volume to share ccache between runner concurrent jobs
CCACHE_DIR: "/cache/idf_ccache"
CCACHE_MAXSIZE: "20G"
################################################
# `before_script` and `after_script` Templates #
################################################
@ -187,7 +195,7 @@ variables:
.show_ccache_statistics: &show_ccache_statistics |
# Show ccache statistics if enabled globally
test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats || true
test "$CI_CCACHE_STATS" == 1 && test -n "$(which ccache)" && ccache --show-stats -vv || true
.upload_failed_job_log_artifacts: &upload_failed_job_log_artifacts |
if [ $CI_JOB_STATUS = "failed" ]; then

View File

@ -33,9 +33,20 @@ if [ "$CI_CCACHE_DISABLE" = 1 ]; then
echo "INFO: ccache disabled globally using CI_CCACHE_DISABLE=0"
fi
# https://ccache.dev/manual/latest.html#_configuring_ccache
# Set ccache base directory to the project checkout path, to cancel out differences between runners
export CCACHE_BASEDIR="${CI_PROJECT_DIR}"
# host mapping volume to share ccache fbetween runner concurrent jobs
export CCACHE_SLOPPINESS="time_macros"
# CCACHE_RECACHE Used when invalidating the current cache.
# could be enabled by MR label "ccache:recache"
if [ -n "${CI_MERGE_REQUEST_LABELS}" ] && echo "${CI_MERGE_REQUEST_LABELS}" | grep -q "ccache::recache"; then
export CCACHE_RECACHE="1"
echo "INFO: ccache recache enabled"
fi
# 'CI_CCACHE_DISABLE_NOHASHDIR' variable can be used at project level to revert to hash_dir=true, in
# case we start seeing failures due to false cache hits.
if [ "${CI_CCACHE_DISABLE_NOHASHDIR}" != "1" ]; then