Skip to content

Commit

Permalink
Avoid remote caching of remote persistent worker demo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aherrmann committed Dec 18, 2024
1 parent 9bd666e commit 1ecb88d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
7 changes: 7 additions & 0 deletions examples/persistent_worker/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def _demo_impl(ctx: AnalysisContext) -> list[Provider]:
ctx.actions.run(
cmd_args(argfile),
category = "demo",
env = {
# modify this value to force an action rerun even if caching is enabled.
# `--no-remote-cache` does not have the desired effect, because it also causes
# the action to be omitted from `buck2 log what-ran`, which interferes with the
# test setup.
"CACHE_SILO_KEY": read_root_config("build", "cache_silo_key", "0"),
},
exe = WorkerRunInfo(
worker = ctx.attrs._worker[WorkerInfo],
exe = ctx.attrs._one_shot[RunInfo].args,
Expand Down
22 changes: 18 additions & 4 deletions examples/persistent_worker/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
set -euo pipefail

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

echo "::group::Local build with persistent worker" >&2
echo '<file:.buckconfig.local-persistent-workers>' > .buckconfig.local
cat >.buckconfig.local <<EOF
<file:.buckconfig.local-persistent-workers>
EOF
buck2 clean; buck2 build : -vstderr
echo "# Verifying Buck2 log" >&2
buck2 log what-ran --show-std-err --format json \
Expand All @@ -60,7 +64,12 @@ echo "::group::Remote build without persistent worker" >&2
if [[ -z ${BUILDBUDDY_API_KEY:+x} ]]; then
echo "::notice file=$(realpath --relative-to=../.. ${BASH_SOURCE[0]}),line=${LINENO}::SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md" >&2

Check notice on line 65 in examples/persistent_worker/test.sh

View workflow job for this annotation

GitHub Actions / linux-build-examples

SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md
else
echo '<file:.buckconfig.buildbuddy>' > .buckconfig.local
cat >.buckconfig.local <<EOF
<file:.buckconfig.buildbuddy>
[build]
cache_silo_key=$(date +%s.%N).${GITHUB_RUN_ID-0}
EOF
buck2 clean; buck2 build : -vstderr
echo "# Verifying Buck2 log" >&2
buck2 log what-ran --show-std-err --format json \
Expand Down Expand Up @@ -88,7 +97,12 @@ echo "::group::Remote build with persistent worker" >&2
if [[ -z ${BUILDBUDDY_API_KEY:+x} ]]; then
echo "::notice file=$(realpath --relative-to=../.. ${BASH_SOURCE[0]}),line=${LINENO}::SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md" >&2

Check notice on line 98 in examples/persistent_worker/test.sh

View workflow job for this annotation

GitHub Actions / linux-build-examples

SKIPPED Missing BuildBuddy token. See examples/persistent_worker/README.md
else
echo '<file:.buckconfig.buildbuddy-persistent-workers>' > .buckconfig.local
cat >.buckconfig.local <<EOF
<file:.buckconfig.buildbuddy-persistent-workers>
[build]
cache_silo_key=$(date +%s.%N).${GITHUB_RUN_ID-0}
EOF
buck2 clean; buck2 build : -vstderr
echo "# Verifying Buck2 log" >&2
buck2 log what-ran --show-std-err --format json \
Expand Down

0 comments on commit 1ecb88d

Please sign in to comment.