Skip to content

Commit d6996ea

Browse files
committed
Use hot cache in build-cmk-distro-package job
... the usage can be toggled with the env variable USE_STASHED_BAZEL_FOLDER_CMK_DISTRO_BUILD and requires USE_STASHED_BAZEL_FOLDER to be true as well CMK-29837 Change-Id: I3baefc0ca5afdc28e5fa98e88f3c574b2920983a (cherry picked from commit 959c831)
1 parent 671c7b4 commit d6996ea

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

buildscripts/scripts/build-cmk-distro-package.groovy

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void main() {
2929
def versioning = load("${checkout_dir}/buildscripts/scripts/utils/versioning.groovy");
3030
def bazel_logs = load("${checkout_dir}/buildscripts/scripts/utils/bazel_logs.groovy");
3131
def package_helper = load("${checkout_dir}/buildscripts/scripts/utils/package_helper.groovy");
32+
def artifacts_helper = load("${checkout_dir}/buildscripts/scripts/utils/upload_artifacts.groovy");
3233

3334
def omd_env_vars = [
3435
"DEBFULLNAME='Checkmk Team'",
@@ -205,14 +206,28 @@ void main() {
205206
if (edition == "community") {
206207
license_flag = '--//:repo_license="gpl"'
207208
}
208-
sh("""
209-
bazel build \
210-
--cmk_version=${cmk_version} \
211-
--cmk_edition=${edition} \
212-
${license_flag} \
213-
--execution_log_json_file="${checkout_dir}/deps_install.json" \
214-
//omd:${package_type}_${edition}
215-
""");
209+
artifacts_helper.withHotCache([
210+
download_dest: "~",
211+
remove_existing_cache: true,
212+
target_name: "build-omd-${package_type}",
213+
cache_prefix: versioning.distro_code(),
214+
// When we mount the shared repository cache, we won't pack the repository cache under ~/.cache
215+
// into the hot cache and therefore we dont need to consider WORKSPACE and MODULE.bazel.lock
216+
files_to_consider: [
217+
'.bazelversion',
218+
'requirements.txt',
219+
'bazel/tools/package.json',
220+
] + (env.MOUNT_SHARED_REPOSITORY_CACHE == "1" ? [] : ['WORKSPACE', 'MODULE.bazel.lock']),
221+
]) {
222+
sh("""
223+
bazel build \
224+
--cmk_version=${cmk_version} \
225+
--cmk_edition=${edition} \
226+
${license_flag} \
227+
--execution_log_json_file="${checkout_dir}/deps_install.json" \
228+
//omd:${package_type}_${edition}
229+
""");
230+
}
216231
sh("cp --no-preserve=mode ${checkout_dir}/bazel-bin/omd/check-mk*.${package_type} ${checkout_dir}");
217232
}
218233
package_name = cmd_output("ls check-mk-${edition}-${cmk_version}*.${package_type}");

buildscripts/scripts/utils/upload_artifacts.groovy

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ boolean download_hot_cache(Map args) {
154154
timeout(time: 120, unit: 'SECONDS') {
155155
sh("""
156156
mkdir -p ${args.download_dest}
157-
cp ${env.PERSISTENT_K8S_VOLUME_PATH}/${args.file_pattern}{${hashfile_extension},} ${args.download_dest}
157+
cp \
158+
${env.PERSISTENT_K8S_VOLUME_PATH}/${args.file_pattern}{${hashfile_extension},} \
159+
${args.download_dest}
158160
""");
159161
}
160162
} catch (Exception exc) {
@@ -302,7 +304,11 @@ void withHotCache(Map args, Closure body) {
302304

303305
// TODO: Remove me as soon as this is stable
304306
// Skip restoring "All unit tests" as it might take up to 30min due to massive 27GB and high disk utilization
305-
if (env.USE_STASHED_BAZEL_FOLDER == "0" || args.target_name in ["All unit tests", "C++ unit tests"]) {
307+
if (
308+
env.USE_STASHED_BAZEL_FOLDER == "0"
309+
|| env.USE_STASHED_BAZEL_FOLDER_CMK_DISTRO_BUILD == "0"
310+
|| args.target_name in ["All unit tests", "C++ unit tests"]
311+
) {
306312
body();
307313
return;
308314
}

0 commit comments

Comments
 (0)