Skip to content

Commit b50f2c6

Browse files
committed
Remote: Make --incompatible_remote_build_event_upload_respect_no_cache working with alias.
Fixes #14456. Closes #14461. PiperOrigin-RevId: 417637635
1 parent 99d2fbe commit b50f2c6

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,9 @@ private void parseNoCacheOutputs(AnalysisResult analysisResult) {
754754
}
755755

756756
for (ConfiguredTarget configuredTarget : analysisResult.getTargetsToBuild()) {
757+
// This will either dereference an alias chain, or return the final ConfiguredTarget.
758+
configuredTarget = configuredTarget.getActual();
759+
757760
if (configuredTarget instanceof RuleConfiguredTarget) {
758761
RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) configuredTarget;
759762
for (ActionAnalysisMetadata action : ruleConfiguredTarget.getActions()) {

src/test/shell/bazel/remote/remote_execution_test.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,6 +3318,33 @@ EOF
33183318
expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data"
33193319
}
33203320

3321+
function test_uploader_alias_action_respect_no_cache() {
3322+
mkdir -p a
3323+
cat > a/BUILD <<EOF
3324+
genrule(
3325+
name = 'foo',
3326+
outs = ["foo.txt"],
3327+
cmd = "echo \"foo bar\" > \$@",
3328+
tags = ["no-cache"],
3329+
)
3330+
3331+
alias(
3332+
name = 'foo-alias',
3333+
actual = '//a:foo',
3334+
)
3335+
EOF
3336+
3337+
bazel build \
3338+
--remote_cache=grpc://localhost:${worker_port} \
3339+
--incompatible_remote_build_event_upload_respect_no_cache \
3340+
--build_event_json_file=bep.json \
3341+
//a:foo-alias >& $TEST_log || fail "Failed to build"
3342+
3343+
cat bep.json > $TEST_log
3344+
expect_not_log "a:foo.*bytestream://"
3345+
expect_log "command.profile.gz.*bytestream://"
3346+
}
3347+
33213348
function test_uploader_respect_no_cache_trees() {
33223349
mkdir -p a
33233350
cat > a/output_dir.bzl <<'EOF'

0 commit comments

Comments
 (0)