Skip to content

Commit 0711169

Browse files
authored
[ABLD-300] Unplug bazel from GitLab caches on macOS (#43604)
### What does this PR do? Introduce `.bazel:defs:cache:macos` (similar to `.bazel:defs:cache:windows`) cache configuration and migrate macOS jobs to use runner-specific cache locations instead of GitLab distributed cache. ### Motivation macOS runners use persistent temporary directories (`$RUNNER_TEMP_PROJECT_DIR`) that survive across pipeline runs on the same runner. Using GitLab's distributed cache (`.bazel:defs:cache:ephemeral` with `$CI_PROJECT_DIR/.cache`) was suboptimal -if not wrong- because: 1. macOS runners don't benefit from distributed cache across different machines, 2. the runner's temporary directory provides better locality and persistence, 3. cache configurations suitable for ephemeral containers shouldn't apply to macOS runners. ### Additional Notes `.agent_dmg` jobs: - replaced `.bazel:defs:cache:omnibus-transition` with `.bazel:defs:cache:macos`, - ... but restored `cache: - !reference [.cache_omnibus_ruby_deps, cache]` previously inherited from `.bazel:defs:cache:omnibus-transition`. `.tests_macos_gitlab` jobs: - replaced `.unit_test_base` (ephemeral cache) with `.bazel:defs:cache:macos`, - ... but preserved `FLAKY_PATTERNS_CONFIG` variable previously inherited from `.unit_test_base`.
1 parent 427de80 commit 0711169

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

.gitlab/bazel/defs.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
variables:
3636
XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
3737

38+
.bazel:defs:cache:macos:
39+
extends: .bazel:defs
40+
variables:
41+
XDG_CACHE_HOME: "$RUNNER_TEMP_PROJECT_DIR"
42+
3843
.bazel:defs:cache:persistent:
3944
extends: .bazel:defs
4045
variables:
@@ -54,11 +59,11 @@
5459
tags: [ "k8s-persistent:arm64", "specific:true" ]
5560

5661
.bazel:runner:macos-amd64:
57-
extends: .bazel:defs:cache:ephemeral
62+
extends: .bazel:defs:cache:macos
5863
tags: [ "macos:sonoma-amd64", "specific:true" ]
5964

6065
.bazel:runner:macos-arm64:
61-
extends: .bazel:defs:cache:ephemeral
66+
extends: .bazel:defs:cache:macos
6267
tags: [ "macos:sonoma-arm64", "specific:true" ]
6368

6469
.bazel:runner:windows-amd64:

.gitlab/package_build/dmg.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
mkdir -p $GOMODCACHE
2323
2424
.agent_dmg:
25-
extends: .bazel:defs:cache:omnibus-transition
25+
extends: .bazel:defs:cache:macos
2626
stage: package_build
2727
needs: ["go_mod_tidy_check"]
2828
rules:
@@ -46,6 +46,8 @@
4646
NOTARIZATION_ATTEMPTS: 3
4747
NOTARIZATION_WAIT_TIME: 15s
4848
timeout: 2h
49+
cache:
50+
- !reference [.cache_omnibus_ruby_deps, cache]
4951
before_script:
5052
# Since there is no virtualization on the macOS runners, we need to unmount the Agent dmg volume to avoid conflicts
5153
- sudo umount /Volumes/Agent || true

.gitlab/source_test/macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ include:
55
.tests_macos_gitlab:
66
stage: source_test
77
extends:
8-
- .unit_test_base
8+
- .bazel:defs:cache:macos
99
- .macos_gitlab
1010
rules:
1111
- !reference [.except_disable_unit_tests]
1212
- !reference [.fast_on_dev_branch_only]
1313
needs: ["go_deps", "go_tools_deps"]
1414
variables:
15+
FLAKY_PATTERNS_CONFIG: $CI_PROJECT_DIR/flaky-patterns-runtime.yaml
1516
TEST_OUTPUT_FILE: test_output.json
1617
script:
1718
- !reference [.retrieve_linux_go_deps]

0 commit comments

Comments
 (0)