From 7928f46f2d5c2ad98fcdd4865368dfa931c0b255 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Mon, 4 Mar 2024 14:43:54 +0100 Subject: [PATCH] ci: use host mapping volumes to improve the ccache hits --- .gitlab/ci/common.yml | 10 +++++++++- tools/ci/configure_ci_environment.sh | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index 698f2b50f6..de628f12bd 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -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 diff --git a/tools/ci/configure_ci_environment.sh b/tools/ci/configure_ci_environment.sh index 9c7e00a1fe..d4c4de4044 100644 --- a/tools/ci/configure_ci_environment.sh +++ b/tools/ci/configure_ci_environment.sh @@ -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