diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java index df4e38cf5df2de..ad5775c65f2224 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java @@ -754,6 +754,9 @@ private void parseNoCacheOutputs(AnalysisResult analysisResult) { } for (ConfiguredTarget configuredTarget : analysisResult.getTargetsToBuild()) { + // This will either dereference an alias chain, or return the final ConfiguredTarget. + configuredTarget = configuredTarget.getActual(); + if (configuredTarget instanceof RuleConfiguredTarget) { RuleConfiguredTarget ruleConfiguredTarget = (RuleConfiguredTarget) configuredTarget; for (ActionAnalysisMetadata action : ruleConfiguredTarget.getActions()) { diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh index a963114f797102..871cb5aefa75f0 100755 --- a/src/test/shell/bazel/remote/remote_execution_test.sh +++ b/src/test/shell/bazel/remote/remote_execution_test.sh @@ -3318,6 +3318,33 @@ EOF expect_log "command.profile.gz.*bytestream://" || fail "should upload profile data" } +function test_uploader_alias_action_respect_no_cache() { + mkdir -p a + cat > a/BUILD < \$@", + tags = ["no-cache"], +) + +alias( + name = 'foo-alias', + actual = '//a:foo', +) +EOF + + bazel build \ + --remote_cache=grpc://localhost:${worker_port} \ + --incompatible_remote_build_event_upload_respect_no_cache \ + --build_event_json_file=bep.json \ + //a:foo-alias >& $TEST_log || fail "Failed to build" + + cat bep.json > $TEST_log + expect_not_log "a:foo.*bytestream://" + expect_log "command.profile.gz.*bytestream://" +} + function test_uploader_respect_no_cache_trees() { mkdir -p a cat > a/output_dir.bzl <<'EOF'