Skip to content

Commit 1ecb88d

Browse files
committed
Avoid remote caching of remote persistent worker demo
The test wants to make sure that the actions are executed correct using either the remote persistent worker or running as individual actions on the remote execution system. Caching interferes with this test. This injects a cache-silo-key that changes each time to force a re-run of the action.
1 parent 9bd666e commit 1ecb88d

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

examples/persistent_worker/defs.bzl

+7
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ def _demo_impl(ctx: AnalysisContext) -> list[Provider]:
3434
ctx.actions.run(
3535
cmd_args(argfile),
3636
category = "demo",
37+
env = {
38+
# modify this value to force an action rerun even if caching is enabled.
39+
# `--no-remote-cache` does not have the desired effect, because it also causes
40+
# the action to be omitted from `buck2 log what-ran`, which interferes with the
41+
# test setup.
42+
"CACHE_SILO_KEY": read_root_config("build", "cache_silo_key", "0"),
43+
},
3744
exe = WorkerRunInfo(
3845
worker = ctx.attrs._worker[WorkerInfo],
3946
exe = ctx.attrs._one_shot[RunInfo].args,

examples/persistent_worker/test.sh

+18-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
set -euo pipefail
1010

1111
echo "::group::Local build without persistent worker" >&2
12-
echo '<file:.buckconfig.no-workers>' > .buckconfig.local
12+
cat >.buckconfig.local <<EOF
13+
<file:.buckconfig.no-workers>
14+
EOF
1315
buck2 clean; buck2 build : -vstderr
1416
echo "# Verifying Buck2 log" >&2
1517
buck2 log what-ran --show-std-err --format json \
@@ -33,7 +35,9 @@ buck2 log what-ran --show-std-err --format json \
3335
echo "::endgroup::" >&2
3436

3537
echo "::group::Local build with persistent worker" >&2
36-
echo '<file:.buckconfig.local-persistent-workers>' > .buckconfig.local
38+
cat >.buckconfig.local <<EOF
39+
<file:.buckconfig.local-persistent-workers>
40+
EOF
3741
buck2 clean; buck2 build : -vstderr
3842
echo "# Verifying Buck2 log" >&2
3943
buck2 log what-ran --show-std-err --format json \
@@ -60,7 +64,12 @@ echo "::group::Remote build without persistent worker" >&2
6064
if [[ -z ${BUILDBUDDY_API_KEY:+x} ]]; then
6165
echo "::notice file=$(realpath --relative-to=../.. ${BASH_SOURCE[0]}),line=${LINENO}::SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md" >&2
6266
else
63-
echo '<file:.buckconfig.buildbuddy>' > .buckconfig.local
67+
cat >.buckconfig.local <<EOF
68+
<file:.buckconfig.buildbuddy>
69+
70+
[build]
71+
cache_silo_key=$(date +%s.%N).${GITHUB_RUN_ID-0}
72+
EOF
6473
buck2 clean; buck2 build : -vstderr
6574
echo "# Verifying Buck2 log" >&2
6675
buck2 log what-ran --show-std-err --format json \
@@ -88,7 +97,12 @@ echo "::group::Remote build with persistent worker" >&2
8897
if [[ -z ${BUILDBUDDY_API_KEY:+x} ]]; then
8998
echo "::notice file=$(realpath --relative-to=../.. ${BASH_SOURCE[0]}),line=${LINENO}::SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md" >&2
9099
else
91-
echo '<file:.buckconfig.buildbuddy-persistent-workers>' > .buckconfig.local
100+
cat >.buckconfig.local <<EOF
101+
<file:.buckconfig.buildbuddy-persistent-workers>
102+
103+
[build]
104+
cache_silo_key=$(date +%s.%N).${GITHUB_RUN_ID-0}
105+
EOF
92106
buck2 clean; buck2 build : -vstderr
93107
echo "# Verifying Buck2 log" >&2
94108
buck2 log what-ran --show-std-err --format json \

0 commit comments

Comments
 (0)